PDA

View Full Version : Deshaker in AviSynth, preroll parameter


WarpEnterprises
3rd August 2006, 21:40
Once again I'm trying to use Deshaker (the great Virtualdub-filter) in AviSynth.
I still have two problems:

1) pass1 works only when "video output" is set to "none". When using "motion vectors" it crashes (access violation). Well, after I found the reason, this is no big problem anymore. Strange, because here (http://forum.doom9.org/showthread.php?p=449720#post449720) it seems it worked in the other case.

2) pass2 doesn't work (access violation) with the setting "use future frames" > 0.
I tried different values for the "preroll" parameter in the LoadVirtualdubplugin function - no effect. It even seems as if this argument is completely ignored.

Has someone else tried this?

smok3
3rd August 2006, 22:42
not yet, can you post your avs?

guth
3rd August 2006, 23:47
Yes, please post your avs and I'll look into it. I never really use Deshaker from AviSynth so I may very well have missed something.

Btw, if you find bugs in Deshaker, email them directly to me instead. I don't want the whole world to see how crappy my software is! :)

WarpEnterprises
4th August 2006, 08:47
@guth: I will do so if I actually find any bugs. This looked like AviSynth-related to me.

Here is the script:
LoadVirtualDubPlugin ("C:\Programme\VirtualDubAVS\plugins\deshaker.vdf", "deshaker", preroll=0) #version 1.9

Version.ConvertToRgb32.Trim(0,100).BilinearResize(352,288) #testvideo

#pass1, no motion vectors --> works
#deshaker("8|1|30|4|1|0|1|0|640|480|1|2|1|400|400|400|1500|4|0|1|2|5|40|300|4|C:\\Deshaker.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|100|0|0|1|0|0")

#pass1, motion vectors --> Avisynth read error: Avisynth: caught an access violation at 0x.... attempting to read from 0x00000000
#deshaker("8|1|30|4|1|0|1|0|640|480|1|2|1|400|400|400|1500|4|1|1|2|5|40|300|4|C:\\Deshaker.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|100|0|0|1|0|0")

#pass2, 0 future frames --> works
#deshaker("8|2|30|4|1|0|1|0|640|480|1|2|1|400|400|400|1500|4|1|1|2|5|40|300|4|C:\\Deshaker.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|1|1|30|0|0|100|0|0|1|0|0")

#pass2, 2 future frames --> Avisynth read error: Avisynth: caught an access violation at 0x.... attempting to read from 0x00000000
deshaker("8|2|30|4|1|0|1|0|640|480|1|2|1|400|400|400|1500|4|1|1|2|5|40|300|4|C:\\Deshaker.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|1|1|30|2|0|100|0|0|1|0|0")


- it does not matter what preroll value is used
- many other combinations of parameters worked flawlessly

(of course, I commented out all but the tested of the four case above...)

guth
4th August 2006, 12:01
A VirtualDub filter has the option to output graphics on the output video using a "device context" that is sent to the filter from VirtualDub. This allows the filter to draw text and stuff using functions built into Windows. But this device context doesn't seem to be valid when using AviSynth. I think I can check for this and not output any text or motion vectors when using AviSynth. It will be fixed in the next version to be released in a week or so.

But you will probably still want to get that preroll to do what we want. In the AviSynth manual it sounds as though it would do what we want, but I can't see that it does anything. Does anybody know what it's supposed to do?

WarpEnterprises
4th August 2006, 13:10
Then the crashes in pass2 do not come from the use of future frames but from the warning output ?

Maybe it then works with the preroll as supposed to:
At requested frame n the VD-Filter is called min(n, preroll) times with the frames n-preroll, n-preroll+1 and so on. There is no delay introduced depending on preroll, only the possible delay from the VD-filter (in our case the future frames) comes through.

Shouldn't it be possible to disable the device context from AviSynth? I found the following code in plugins.cpp which looks like the place in question:
if (src_needs_hdc || dst_needs_hdc) {
// throw AvisynthError("VirtualdubFilterProxy: HDC not supported");
vbSrc.hdc = vbDst.hdc = vbLast.hdc = GetDC(NULL);
}

guth
4th August 2006, 14:44
Right, both crashes were due to this device context thing.

I never saw that explanation of preroll. That's exactly how it works actually, but I still don't see how to use it properly. We want to start processing at frame x, where x is the number of future frames you have set. If you use preroll=x, AviSynth will call Deshaker with frames 0 to x for frame x, which is fine. But how do you make AviSynth start processing at frame x. The Trim function won't do, because that throws away the frames completely and we still need them in the preroll thing. But I'm no AviSynth expert, there's probably a way to do it.

The code you found doesn't make sense to me. I do tell VirtualDub that I need hdc for the destination, but that would mean that it is set to GetDC(NULL), which should never fail. And the hdc I get is NULL when using AviSynth. And setting hdc to GetDC(NULL) seems very weird. It wouldn't work if it really did that anyway.
I don't know what you mean by disabling the device context, but this is no big problem really. I just check if hdc is NULL and don't use it if it is. Which means no motion vectors or info texts of any kind.

guth
4th August 2006, 14:49
Ahh... I just found out you can use the Trim function on the output too. So this should work fine I guess.

guth
12th August 2006, 14:37
Now there's a new version of Deshaker available that (among other things) should fix the crashes when using it from AviSynth. Get it here (http://www.guthspot.se/video/deshaker.htm).

Fizick
12th August 2006, 16:54
thanks guth,
will try and compare with depan ;)