CodecPage
 video encoding&cleaning


Deshaking

Codecpage News


These experiments with Gunnar Thalin's Deshaker filter don't by al means reflect everything you can do with it. The objective here was to have a replacement for the stabilizer function missing in older camcorders.

Here is an example, 8 seconds from a longer tape. Note that the video player windows will oly appear if Flash is installed on your machine. You may also download full resolution DivX (5.1) versions of these videos (see links).This source wasn't extremely sharp anyway, but ideal for a demonstration. You can of course also use Xvid to play the DIVX versions (smaller installation) if you don't have Divx on your machine.

I think this is indeed quite impressive. It blows away anything that I have seen from any other stabilizing software.

Original video
Deshaked video

The objective with these tests was to find some settings that work well on entire movies.

With older filter versions there were some issues with scans that have been mended in version 1.8. Shots from moving cars may still be difficult but that's probably close to impossible in many cases. Anyway, there is a small but unavoidable loss of crispness with deshaking: Shifting images basically works only in steps of 1 pixel, but this would look quite restless in detail. For a smooth motion, the algorithm needs to adjust positions by fractions of pixels therefore usually requires some interpolation and hence blurring. A little crispening afterwards can compensate for this but not 100%.

For best results it would therefore be appropriate to decide scene by scene if to stabilize or not. This is a huge lot of work and even more so if stabilizer settings would be optimized for each scene. Absolutely unrealistic if we want to process piles of raw tapes recorded with older unstabilized camcorders.

The filter settings shown here are therefore optimized to be used on entire raw tapes, so one could later on select which scene to take from the raw and which from the stabilized version, for example opening both with Pinnacle Studio and dragging scene after scene to a new file, or open the files in a multi camera mode as e.g. in Video Deluxe 16 plus, and switching between 'cameras' according to content.
This is still far more convenient than to use the filter separately clip by clip.

 

Now for the procedures:

I avoided any zoom factor, because resizing with interlaced material is always problematic and I didn't want to sacrifice too much sharpness.

With the usual border clipping of TVs, the small black rims remaining with the scheme presented here are no problem anyway. It was however a bit tricky to use the border filling. Camcorders (at least analog ones) don't fill the entire image area, so the filling function would replicate black border lines. Some clipping hat to be done and some new black borders had to be added afterwards to get it right.

Instead of this resize filter, a small zoom factor (1.03) and directly setting 720x576 in the deshaker filter pass 2 could also do the job. The advantage: No black borders. Some additional blurring could occur. Such a small resizing, requiring to double only every 30th pixel, has hardly hardly any visible effects, with photos or progressive video pictures. With interlaced material like DV however, it always has twice as large effects in vertical direction at least, and perhaps additional problems with motion.

Note that deshaking should normally be done before any crispening or denoising :
- The blur introduced due to shifting by fractions of pixels forfeits any prior sharpening efforts.
- Temporal cleaning or smoothing relies on as little movement as possible and will either not work or blur details in shaking images.

Deshaker works in 2 passes.
Here is the filter set for pass one:

Note that the output file size is set to only 8x8 pixels as saving a real video file here would only cause unnecessary waste of time.

The Null Transform filter is used for cropping. Press cropping and enter the following:

The border cropping eliminates black borders from camcorder shots and allows Deshaker's border filling to work appropriately. Experiment the right setting for your equipment, because it may be different. Use even numbers for the total of y clipping, otherwise you get really bad effects with the interlacing.

The 1st Deshaker pass looks like this:

The high skip frame limit disables the filter in uncertain situations. The Ignore Outside setting should eliminate border areas, the Ignore Inside is to avoid stabilizing persons or animals in closeups while shaking the background. Both can be omitted and are only shown here for example.
Give a new log file name for every film.

The filter setup concludes with selecting full processing for video and None for image compression. Audio can be omitted in the first pass.

Instead of "saving" an avi file you may start the first pass by just pressing the output play button. This may especially be useful if you want to watch the motion vector display without recording it. The status window in this case has to be activated manually with the "options" menu.

Be prepared that the filter is slow, especially, in pass one, so try it with short clips for the beginning.

Avoid any further shuffling through the file after pass 1 as this could damage the log file. Copy the logfile to somewhere else to have a safety backup.

 

Now here comes pass 2:

We have added a resize step to get the original image size back by adding black borders. This step can't be present in pass 1, or we would produce a full frame size uncompressed dummy video, that would be extraordinary big.

 

The deshaker settings for pass 2 are these:

We use a 1 second (25 frame) area to get filling data for the borders. This will delay the output video by 1 second, but not the sound. You may enter an audio delay value (1000 msec. /audio/interleave) in VirtualDub to compensate for this. Other ways to cope with it are cutting off the start second when encoding MPEG2 and inserting the audio separately, or, just doing a direct stream copy with VirtualDub, with 1 second cut off and audio delayed 1 second. This takes some time and space but works in any case.

Max. Correction limits are not used, I also saw no obvious effects of that. Avoid to enter any low values here in any case, because this may cause a very long delay time at the start of pass 2.

The motion smoothness numbers of 2000 all over are optimized to avoid edge effects with pans while maintaining a very good smoothing effect.

The resize filter us set like this:

 

The pass 2 filter set is completed by setting video compression to DV or to MJPEG, whatever you use. You will of course, like always, need an appropriate codec, like MainConcept DV or PIC MJPEG.

Note that something in this filter set reverted field order in my test. I can't say if it's the resizer or the deshaker or if it's reproducible in any setup. It's not a big problem but you have to tell your MPEG encoder. With CCE, set offset line to 0 instead of 1, if the file format is DV.

 

A comparison: Magix Video Deluxe's standard stabilizer

Here we have taken the old unstabilized file as shown above and processed it in Magix Video Deluxe 16 (not the additional stabilizer that comes with the premium version, but the one that is built into the software anyway). The handling is much simpler than with Deshaker, but the results are less dramatic.
The procedure: right click on the clip, select the stabilizer, start it. We only changed the time base from 800 to 1600 to get a bit more smoothness with larger bumps.
With this setting, Video Deluxe takes about as long as Deshaker. Selecting larger search areas will slow it down further.
What this software does not offer, is to fill in borders with material from prior frames. So you either have to accept fluctuating black borders or some amount of picture zooming.

Video Deluxe w. borders
Video Deluxe zoomed

Here we have the results: not really a match for Deshaker, but for a quick job just reducing some normal camera jitter it may be OK.

 


 



Copyright (C) 1998-2011; all rights reserved. All materials in these pages are presented for scientific evaluation of video technologies only. They may not be copied from here and used for entertainment or commercial activities of any kind.
We do not have any relation to and do not take any responsibility for any software and links mentioned on this site. This website does not contain any illegal software for download. If we, at all, take up any 3rd party software here, it's with the explicit permission of the author(s) and regarding all possible licensing and copyright issues, as to our best knowledge. All external download links go to the legal providers of the software concerned, as to our best knowledge.
Any trademarks mentioned here are the property of their owners. To our knowledge no trademark or patent infringement exists in these documents; any such infringement would be purely unintentional.
If you have any questions or objections about materials posted here, please
e-mail us immediately.
You may use the information presented herein at your own risk and responsibility only. We do also not guarantee the correctness of any information on this site or others and do not encourage or recommend any use of it.
One further remark: These pages are covering only some aspects of PC video and are not intended to be a complete overview or an introduction for beginners.