View Single Post
Old 29th September 2012, 19:52   #2  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 407
Hi @all,

I'd like to drop some notes about my experiences with deshaking, and propose some methods that I hope might find a friend or two.

Probably the deshaker among free software is Gunnar Thalin's DeShaker for VirtualDub.
Please read the manuals, the Wiki or various posts, or the attached scripts, on how to use DeShaker from AviSynth.

However, even a good tool gives better results if used with brain.

Deshaking divides up into
1) motion estimation
2) motion compensation
3) maybe border handling

DeShaker uses an 'intuitive' algorithm for motion estimation, that differs from the algorithms used for e.g. the MPEG codecs. Most important, it only estimates motion for blocks that are clear enough to be tracked, and leaves the rest of the frame 'unestimated'.

Long time ago, I contacted Gunnar Thalin when I wanted to deshake a scene with an aircraft takeoff. In that scene, DeShaker's motion estimation jumped between the aircraft and the ground, as the aircraft was hiding and revealing some observers on the ground.
At that time, we did not share the same opinion if deshaking should really freeze some part of the image or try to smoothen the average speed of all objects. Today, I would support the opinion, that no motion for the background is better than slow panning especially for playback on all those liquid crystal displays. When the eye follows objects on these displays, details smear on the retina - that is the neccessary drawback of all non-flickering displays.

But the example still shows that different situations require different approaches.

1) For the motion estimation, I prefer MVTools2's MDepan(). See attached DeShakerPrep.txt.
MDepan() writes a log file that DeShaker can read. The motion estimation is similar to MPEG methods and works well even with bad source material. My example is slower than DeShaker, but you can download the manual and speed it up.

2) For the motion compensation, DeShaker has the advantage that it uses the complete motion history over other approaches that average only some previous/future frames. On how to use it inside of AviSynth, see DeShakerExec.txt. Inpand() is part of the MaskTools and needs separate download. You might need to adjust the path strings. Not all Deshaker options are configurable here; e.g. I never found adaptive zoom useful.
A one pass alternative is DepanStabilize() from the DePan plugin. My example DeShake.txt also needs the Undot plugin. All tools can be found via the well-known AviSynth sites.

3) Finally, you might like less obvious black borders. All my examples are in RGBA mode and provide a mask to be overlayed over a background. If you do not need that, you may strip them down which will also make them faster.

See my next post for more on this topic.
Attached Files
File Type: txt DeShakerExec.txt (1.2 KB, 185 views)
File Type: txt DeShake.txt (1.9 KB, 146 views)
File Type: txt DeShakerPrep.txt (874 Bytes, 131 views)

Last edited by martin53; 19th November 2012 at 21:38. Reason: update of DeShakerPrep
martin53 is offline   Reply With Quote