View Full Version : Is it possible to stabilize shaky video automatically?
EHarlen
16th October 2016, 16:00
I am looking for an Avisynth plugin/script to stabilize shaky video automatically?
If it is possible can you please help me?
johnmeyer
16th October 2016, 17:05
AVISynth: try Depanstabilize (you can search this forum)
VirtualDub: Deshaker
StainlessS
17th October 2016, 23:17
You are not gonna have much success at doing it fully automatically, but if you mean in a single script then perhaps see here for auto two pass solution,
http://forum.doom9.org/showthread.php?t=173953
(script, a work in progress).
johnmeyer
18th October 2016, 02:12
You can Google my name and "deshaker" and you'll find a long guide that I wrote, and also several scripts that automate the process of using Deshaker within Sony Vegas. The scripts first get the video out of Vegas, then pass it to VirtualDub where a VirtualDub "script" passes it back to Vegas.
Depanstabilize actually works pretty well for simple stabilization and is used in both VideoFred's film restoration script, and in my adaptation of his script. Here is a link to the first of two posts where I provided that script:
film restoration script, based on work by videoFred (http://forum.doom9.org/showthread.php?p=1595606)
The key lines from that long script are these:mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstabH,dymax=maxstabV)
stab=DePanStabilize(cropped_source,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15)The two maxstabH/maxstabV parameters are typically set to between 5 and 20.
So, using just these two lines, you should be able to achieve some level of stabilization.
Of course, as already mentioned by other people, if you want really good stabilization, you should consider Mercalli. It is quite expensive, but you can download a trial and see if its additional capabilities make it worth the money. I think you will find the results from Mercalli more pleasing than those you get with either Deshaker or Depanstabilize.
Here's a simple before/after showing what an older version of Mercalli could do. The newer version is substantially better. (note: Jerry Am Ende, the author of this test, is one of the finest wildlife photographers I've every encountered. Check out some of his other videos if you have an interest in such things.)
Mercalli Before/After (https://www.youtube.com/watch?v=A1HUJXF-GBA)
goorawin
18th October 2016, 04:29
Yes, it is possible to stabilize shaky video automatically.
I have been doing it for a number of years thanks to StainlessS great scripting. It is all done using avisynth scripts which call on deshaker to do the stabilization.
Normally I batch encode maybe 100 to 300 clips, which takes me about 10 minutes to setup. Encoding can then take awhile because I do everything, noise reduction and general enhancement, all in one pass. I have a number of deshaker presets which are used according to what is required.
I mostly use deshaker in 32Bit for now, but would like to change to 64Bit because of its speed advantage.
I have and still do use Depan on occasions. It has one advantage but many disadvantages. Its main advantage is is can deal quite well with a shot that has an object passing by close to the camera. However it does not handle rotation or smooth its action nicely like deshaker. As well it does not compensate for a rolling shutter.
I can upload short samples of the deshaker results for anyone who is interested.
StainlessS
18th October 2016, 04:49
Goorawin, almost got DS_Tools done, (DeShaker_Tools, as was G_ForceProcess, currently only done 32 bit, gotta add 64 bit).
I'll also Incorporate auto 2 pass within the script if selected via additional arg, so can then script your own 'Preset script' functions, which set only the non-default args, and call ShakeRattleAndRoll() for auto 2 pass deshake.
goorawin
18th October 2016, 05:47
Great news. How about getting some sleep!!!!!!!
StainlessS
18th October 2016, 06:01
Sleep is for wimps.
I'm gonna keep (for now) the long arg names, but if you would prefer args as eg
ShakeRattleAndRoll(c,Pass,p3,p4,p5,p6,p7, ... ,p65, Auto, Debug)
then could do that a little later, would make preset stub functions shorter.
I'll make Auto default true if Pass==1, or False if Pass==2 (and error if Pass==2 and called with Auto==true).
Answer on above in your thread.
goorawin
18th October 2016, 07:28
Long arg names are not really a problem at this stage. Really only about a small number of the parameters change the way I use it. I have about 3 or 4 presets however the log file name and location is important. The log file names is normally the clip name.
I'll make Auto default true if Pass==1, or False if Pass==2 (and error if Pass==2 and called with Auto==true).
I think that should be OK
By the way I'm a wimp.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.