OT - DeShaker Batch render?

vicmilt wrote on 5/18/2007, 8:04 PM
Hi all -
Have seriously studied and applied all Vegas Forum suggestions to DeShaker image stabiliztion and am happy with results.
This is aerial work and slowing down the stabilized footage about 46% (in Vegas) yields wonderful stuff.
Workflow is M2t to CFHD intermediate to Virtual Dub to DeShaker to stabilized HDV 1080i Intermediate.

So now I've got about 50 - 20 second AVI HD intermediates to destabilze.

Is there a "batch render" technique that I can use to:
Open Virtual Dub
Load next video
Open filter
Set to Pass-1
Analyze movie
Set to Pass-2
Save stabilized movie
Close source
REPEAT with next video

Does this exist or can it be scripted somehow?



UKAndrewC wrote on 5/19/2007, 4:40 AM
You can run scripts based on saved configuration files

Google: VirtualDub Scripts

johnmeyer wrote on 5/19/2007, 10:23 AM
I kept having to do this for a film project I was working on. Enough time elapsed between projects that I couldn't quite remember the steps. So, I wrote down the steps. I have adapted those steps to remove references to AVISynth (I was also creating batch scripts where the script for each clip needed to be different). Hope this helps.

1. Set up Deshaker for Pass 1 and set all the pass 1 variables.

2. Put all the AVI files you want to process into some folder.

3. Open the Job Control in VirtualDub.

4. In the VD Job Control dialog, select Edit -> Process directory ... and have it open all the files in the folder that has your AVI files.

5. Click on Start to start the batch processing.

If you clicked on Append in the first column of the Deshaker dialog, all the vectors for all the files will be stored in a single LOG file. You'll have to parse that into individual LOG files for each AVI file during PASS 2.

This part of the batch process is covered here:

How to batch convert things in virtualdub (Flash Demonstration)

If you want to further automate the process, read this document:

VirtualDub's scripts

It describes how you can take the job control file, created by the process above, but before you actually run the jobs, and edit that file to further automate the process. By editing this file you can, for example, use the "RunNullVideoPass();" instead of SaveAVI and avoid filling up your disk with useless AVI files during pass 1.

Here's a link where someone describes his approach to batch processing files for Deshaker, using some of the above steps:

Batch Deshaker

Search about 2/3 of the way down the page for a post by "khmann" dated 17th April 2005, 21:00.

riredale wrote on 5/19/2007, 2:51 PM
This is great.

On my current documentary project, about 10% of the shots are "walking around" shots, and it's been a pain to manually load pass 1, run VDub, append a dummy clip, load pass2, etc.

The effect from DeShaker is always mesmerizing to me. The camera just floats along, gently bobbing up and down due to my stride. There is a slight loss of vertical resolution, but when downconverted to DVD it's not an issue. It will be when I release a project in HD. Hopefully by then the author will have figured out a way to recover that vertical sharpness.
vicmilt wrote on 5/20/2007, 9:16 AM
Thanks John -

Exactly what I have been searching for!!

Am about to jump into new computer - and have asked this on other threads, but...

I can get a E6700 with the usual garbage (2 meg RAM, 320Gig HD, Gigabit ethernet, etc.) for $1,9999 at Tiger Direct. It looks "right" to me, but...

Should I spring for an extra $1,000 - $1,500 for a QX6700?
Workflow is essentially long form HDV - render to HDV and SD (widescreen) plus "too much" DeShaker.

I've seen some posts saying the quad QX6700 doesn't really utilize the extra power in Vegas...
any thoughts?

johnmeyer wrote on 5/20/2007, 10:47 AM
I've seen some posts saying the quad QX6700 doesn't really utilize the extra power in Vegas...

I'm still working on a computer that is 3 1/2 years old (single thread, single CPU, single core 2.8 GHz). Thus, I can't offer any first-hand experience. However, there was a thread just a few days ago about HDV render times and I think it pretty conclusively showed that, for render, Vegas will use all the CPUs and all the cores (of a Quad core computer) and result in some amazing render times.

However, for performance on the timeline (the speed of preview playback), you may be correct. I don't think that additional cores helps there.

With all this talk about doing batch render of Deshaker files, perhaps I need to finally look into a workflow for this. The ideas I gave earlier in this thread are certainly the right way to start, but they won't get you all the way there. What people really want is a way to push a button and have all the AVI files in a folder "deshaken." I think I can come up with a way to do pass 1 with one click and then pass 2 with a second click, but it will take some work on my part to come up with the additional software. The key thing is creating and then using the LOG files that contain the motion vectors. You will either need to create some sort of variable in the script file that will produce new LOG files for each AVI, or you will have to append all the AVI files into one (easy to do in VD) and then create one giant LOG file. The problem with the second approach (which is really easy) is that I don't know what will happen at the boundaries between AVI files when then are combined into one.
Jøran Toresen wrote on 5/20/2007, 11:53 AM
Thank you for your initiative, John. In an earlier post “dreamlx” said he has written a little script for Vegas for deshaking using DeShaker. I quote:

“I also bought DynaPel's SteadyHand some time ago, but I get better results using deshaker in VirtualDub. I have also written a little script for Vegas for deshaking using deshaker. Using this script you select events on the timeline. The script will render every selected event to file, run deshaker on it, and add the deshaked file as take to the event. The script is currently part of a bigger project, but if there is any interest, I can split the script apart an publish it.”

You find the discussion here:

John, maybe you can cooperate with “dreamlx”?

Best wishes,
Jøran Toresen
dreamlx wrote on 5/20/2007, 12:28 PM
This script was published on www.luxmemories.lu, so feel free to check it out.
Jøran Toresen wrote on 5/20/2007, 1:05 PM
dreamlx. Can you tell us more about the bigger project you are working on? I’m just curious.

Thank you,
Jøran Toresen

johnmeyer wrote on 5/20/2007, 1:55 PM
I'd completely forgotten about that excellent script. Now that I look at it, that is clearly a much better way to do things than all the ideas I was thinking about. My approach was going to be to create a batch file that would then feed parameters to the VirtualDub script. However, that is too nerdy for most people. The dreamlx approach of spawning the VD process from within Vegas, and then doing both Deshaker passes before proceeding to the next AVI file makes a lot of sense. The only nerdy step still required is that most people will still need to edit both the deshake.js and also the vds file to meet their particular requirements. Adding a few comments to each file and doing a little reorganization so that all the lines that need to be modified appear at the start of each file would probably make that a little easier.

However, I am impressed with this approach and would definitely recommend that everyone reading this use the dreamlx approach.
dreamlx wrote on 5/20/2007, 9:24 PM
I currently have many projects in progress, so I don't have lot of time to modify the script. Feel free to modify whatever you like. I can also host your modified script. Another thing that could be nice would be changing the script so that it uses a configuration file, and writing a GUI for setting parameters and writing configuration files. I think this would make things easier for many people.
johnmeyer wrote on 5/21/2007, 12:23 AM
I spent quite a bit of time on improving the excellent script. It took awhile to get it all running, but once I did, it sure is fantastic. Just click on any event, and with one push of a button, all selected events are "de-shaken" with the improved video added as a take.

While I agree with your priorities on what needs to be improved next, I had one that was even higher, namely the ability to add the necessary "dummy" video and then offset the result so that, when using "Use Previous and Future Frames to Fill in Borders" you don't end up with one second of dead video at the beginning. This took quite a bit of work because of the crude nature of the VirtualDub script language, but I now have that working perfectly.

I also want to go back and look at various posts from people that have complained that the resulting video is "soft." I have not experienced this myself, and want to find out if this results from one of the following:

1. People don't remember to specify "interlaced," and thereby end up accidentally converting to progressive;

2. People use a substandard codec when processing the output of VirtualDub;

3. Some folks may forget that any movement, when taken at a normal 1/60 "shutter speed," is going to result in motion blur.

I also want to look into the possibility that video could be frameserved into VirtualDub, thus eliminating the time and disk space of a render. I don't think this can be done, because I don't think the Satish Frameserver can be batched, but it's worth a few minutes.

Finally, I thought it would be easy to turn off the fX prior to render, but it doesn't appear that this can easily be scripted. Instead, it will require storing all the fX and keyframe settings. There's got to be an easier way, and this is actually pretty important to do.
Grazie wrote on 5/21/2007, 12:28 AM
I for one would ADORE to have a one click . .or 3 or 4 . .solution to apply to my Events.

I do use SH, but it is a bit clumsy with 16:9 - I need to go into each and every event and reset the PAR to wide-screen - eh . .. ?

Now, if you guys can put a "Grazie-Proof" Beta out there for me, I will DEFO apply my User-Inabilities to understand it.

I reckon, you's on a winner!! - SH is good. For the type of "tightening" I need - to get from so-so footage to "woah" footage it does it for me. SteadyMove - the plug for Prem is better. But if you could "trump" a script that would plug to VEGAS!?!?! Using all your s/w then . . Wohhoho!

Totally absorbed in this thread . .

riredale wrote on 5/21/2007, 7:57 AM

The developer himself mentions that vertical resolution is lost in the process, because from what I gather he is working on fields, not frames, so the resulting DeShaken images will be limited to the field vertical resolution which theoretically is just half of the theoretical maximum resolution of the frame. In practice I suspect the hit is not this bad.

As for codecs going to and coming from VDub, I made several posts over the past few weeks about my new best friend, the Pegasus M-Jpeg codec. When used with quality setting of 19 the round-trip looks transparent and the file sizes are significantly smaller than HuffYUV. Plus, it's blazingly fast in the encode/decode. The image softening was the same when I used HuffYUV in the past; as mentioned, I think the "fault" lies with the limitations of interlace.

As for motion blur, it's an easy artifact to spot in DeShaken footage. I have one particular clip in mind. I was shooting some kids in a 747 on takeoff. Midway through the run we hit some bumps on the runway and the resulting jerkiness in the video was painful to watch. DeShaker took care of smoothing things out, but you can still see how the sharp outlines of the side windows suddenly get fuzzy for a fraction of a second. DeShaker has lined up the moved frames, all right, but can't do anything with the fact that the image was slightly blurred because of that motion. Still, I'd take the DeShaken version any day. It really is a magical effect, and in any event the slight loss in vertical resolution is never seen on down-convert to DVD. Nonetheless, I can see why Hollywood goes to great lengths to get smooth footage via SteadiCam in the first place.

I almost forgot. Is your script finished and available for the masses? I am eager to try it out. I also think one should not worry too much about storage requirements in these days of 500GB drives for $120. Thanks for working on this.
johnmeyer wrote on 5/21/2007, 8:11 AM
OK, I added the code to remove all pan/crop and all fx prior to rendering. That fixes one major issue, so that effects and pan/crop settings don't get applied twice.

As for making it "Grazie-proof," that's a good challenge. I don't know how much more time I want to spend on this, and adding a decent UI is probably more work than I can afford, but I might be able to add four presets that would let you DV & HDV in either NTSC or PAL. The idea would be to just have a package of about four files (VirtualDub, the VD script, the Deshaker plugin, and the Vegas script) which you would put in one folder on your computer. Just run the script on your selected events. Nothing more. Just like a real plug-in. Thanks to dreamlx, that's almost what we have.
michaelshive wrote on 5/21/2007, 8:26 AM
Any chance this revised script will be posted at some point so we can give it a run? Thanks!
Grazie wrote on 5/21/2007, 8:29 AM
John! Sounds just the ticket.

As to the Perfect GUI, what you are suggesting seems plenty.

I would create a folder to be used for "Team-DeShaker", with what's needed, that would do me with a simple "5 Steps to Heaven" Notepad TXT.

That would be kinda "Grazie-Proof"!

I am very excited!

Yours, trembling (. . that's pre- FX!!),

Graham "Grazie" Bernard
dreamlx wrote on 5/21/2007, 9:17 AM
Well I have not noticed any loss of sharpness during deshaking (except for the one of resizing pictures to get rid of borders), but I am working exclusively in progressive. Also if you want an example on how deshaker performs, the walcheren.wmv found on luxmemories.lu is shot entirely without tripod. Everything has been stabilized using deshaker.
riredale wrote on 5/21/2007, 10:16 AM

That sounds great. One thing I often do is to try to run two instances of DeShaker at the same time, in order to max out my x2 CPU. In order to do so, I have to of course keep track of two different sets of processing settings that refer to two different log files. If this is not easy to implement, that's okay--just having an easy way of calling DeShaker from within Vegas would be wonderful.
johnmeyer wrote on 5/21/2007, 11:43 AM
I haven't tried the two instances yet.

Things I have done this morning:

1. The script selects the render template based on project vertical resolution. If 480, then NTSC DV; if 576, then PAL DV; if 1080, then HDV. I need to pass these resolutions to the VirtualDub script.

2. Added some code so the script will still work even if you forgot to save your Vegas project.

3. Added code to render each event to the TEMP directory specified by your computer's system variable. This gets rid of one item that the original script required the user to specify.

4. Temporarily removed all pan/crop and all fX keyframes before passing the video to VirtualDub, so you don't end up with these being applied a second time when the deshaken video is added as a take.

5. Modified the script so that extra frames are added to equal the number of "before/after" frames used by Deshaker to fill in the borders. This means that you can use this feature without losing any frames at the beginning or end of the event, and that the resulting take lines up perfectly with the original video. This is probably the most important change I've made so far.

I am still trying to figure out how to "Grazieize" this whole thing. The simple thing is to just put VirtualDub, Deshaker, my script, and the VirtualDub script into a zip file and require that the user install it in the C:\deshaker directory. Assuming the license for VirtualDub and Deshaker would allow this (packaging with the scripts) I could even have the zip file put into an EXE that would automatically create the directory. So, double-click on the downloaded EXE, fire up Vegas, select a few events, run the script, and voila, deshaken takes automatically appear.

I haven't tried two instances, but dreamlx (David) noted in the original script that this didn't work. I haven't tried it yet, so I don't know what problems might happen.

The final thing I need to get working -- and I'm still not sure how I want this to behave -- is passing parameters to Deshaker. I really don't want to develop a GUI, because that is tough to do without a development environment (I have one installed on another computer, but I haven't used it in a long time). Coding dialog boxes by hand is not fun. However, since I can pass parameters to Deshaker from the Vegas script, I could, in theory, emulate the Deshaker dialog and let you set that from within Vegas. Like I said, I won't be the one to do it, but I can at least do a few things under program control. At the very least, I need to set the NTSC/PAL/HD settings to match the render template in Vegas.

One question for all: Should I just do everything using Uncompressed video? This would mean creating an uncompressed video from Vegas for each event (although only one of these would exist at a time, and each one is deleted after VirtualDub/Deshaker creates a deshaken version). The more I think about it, the more I realize that I should just do that. The question then becomes whether I should create all the deshaken video using uncompressed. It sure makes life easy, but the downside (besides disk space) is that that playback performance on the Vegas timeline will stink.

OK, back to finish this thing off ...
dreamlx wrote on 5/21/2007, 12:53 PM
I noted that 2 instances don't work as my script would pass the same log file for the 2 instances. If you create different names for the logfiles, multiple instances should work.
Grazie wrote on 5/21/2007, 1:06 PM
WTG John!!!!!

. . . " see you in the NEXT one " JimiH. . 9:00pm here .. .
riredale wrote on 5/21/2007, 1:11 PM
It seems to me that the best way to make this flexible yet still efficient would be for the user to manually go into Deshaker the first few times and create the mix of Pass1/Pass2 settings and the compression codec he wants and then to save that configuration via the "Save processing settings" menu item. Then a script just calls up those settings.

The reason I bring this up is because I find the M-Jpeg codec very efficient (and cheap). Someone else might want Cineform. To deal with uncompressed would be to create some very large files and also would probably cause the deshaking process to run very slowly.
vicmilt wrote on 5/21/2007, 1:50 PM
John -

Words can't express the value of your work here, to many of us!


Please let me contribute a video to your personal library... I've got all kinds (all made by me...) - just email me your street address and whichever you like - you can see the selection on my site: www.VictorMilt.com at the "store" -

anyway, your prior instructions, etc., were enough to get me going and it's all looking pretty "smooth". I will be mounting some samples in the next day or so, for everyone to see.

And to the rest of you Vegas lurkers... if you're gonna rush out and start "DeShaking" everything, I can give you tip #1: Doing high speed stuff like sports (or Aerials in my case) - use a higher shutter speed than "normal". My stuff at 1/250th is a beautiful thing to behold, but in fairness, once I shot, then "DeShaked", I slo-mo-ed the footage to 45%. In the aerials it looks fab-o. I think it would be very sexy to shoot sports like this, as well. The combo of high shutter, steady shots and slow motion, should all add up to magnificence. Go for it.

Will reveal all by Wednesday (am rendering with Pentium 920 - steady but slow - errr.... by todays standards! By two years ago standards, well things are RACING along!)

Thanks again from all of us shaky shooters.

johnmeyer wrote on 5/21/2007, 4:43 PM
Got sidetracked by a VirtualDub bug. Turns out you can get VirtualDub into a state where it diddles the levels in the output video. Very similar effect to having the 16-235 flags messed up. Uninstall/Reinstall of VD didn't fix the problem, nor did the Auxsetup "Remove personalized settings from registry". Finally went into the registry and killed the key for VirtualDub. All working now.

Hopefully it will happen again so I can figure out exactly what is going on.

Almost finished.

Good idea about running VirtualDub and then saving settings in order to determine the compressor. I'm not sure I can write the code to parse that file and extract the compressor. It would be dirt easy if I programmed all the time, but I only do this once in a blue moon, and haven't done real programming since the 1970s. All I have to do is look for this string:

and extract those two funny-looking strings.

What I actually post will probably require you to edit the Vegas script in notepad and copy those two things yourself.

As for the multiple instances, if the only problem is the log file, I may be able to do something about that ... we'll see.