Deshaker
Studio Examples
Old Cinema
Logoaway(Studio)
Deshaker

 

Deshaker
Motion Stabilizer

The filter is tested with Liquid Edition 6.1, AVID Liquid 7.x and Studio 9.3.
 

Used files:

 

 

 

deshaker.zip

V2.0

 

 

Installation:
Save the files in the Studio installation folder “ ..\plugins\rtfx\virtualdubfx”

Use together with vdub2rtfx > V7.0

Installation

Download the file deshaker.zip from the virtualdub-filter list and extract the deshaker.vdf-file into the folder ..\plugins\rtfx\virtualdubfx

 

Usage

Studio Users:

  • Switch off background rendering
  • Apply this effect to a clip (start with a short one, the filter is slow)
  • Edit the effect
  • Select Pass 1 - for parameter suggestions see parameter list
  • Goto “create Video” (“Film erstellen”) and let the video render to a temporary video file
  • Realtime preview does only show the original clip
  • The result shows the original clip with motion vectors (for interlaced video the result shows the upper and lower frame in the same frame)
  • If somethings wents wrong the result is a blank rame
  • Do not interfere with the rendering!!
  • after rendering finished edit effect again
  • select <Pass 2> - for parameter suggestions see parameter list
  • Goto “create Video” (“Film erstellen”) and let the video render to the final video file
  • Realtime preview does only show the original clip
  • Check the created video and play with the parameters to get optimal results.
  • Import the rendered video and use it in your final video.
  •  

Parameters:

Parameter

Description

Suggested value

Source pixel aspect

Tells the filter what pixel aspect ratio the source clip has. It's very important that you set this correctly, or the rotation (for example) won't be made correctly.

“Standard PAL”
“Standard NTSC”

Video type

Selects between progressive video and interlaced video (for input and output). If the video is interlaced you must also determine if the video has the first or last field on the first line. In general, DV uses lower field first and all other formats use upper field first. You can easily check that your setting is correct by looking at the motion vectors for the two fields when there's motion in the clip. If the vectors point in opposite directions most of the time the setting is incorrect.
 

This parameter is set automatically by the plugin according to the timeline settings

Log file

The name of the log file to write in pass 1 and read in pass 2.
If you use deshaker on several clips in a timeline, use different names for the logfile for every clip.
i.e. deshaker01.log, deshaker02.log ...

deshaker01.log
deshaker02.log

Append to file

If checked, it appends to the log file instead of overwriting it. (This function is not save to use in LE)

Do not use

 

 

 

Video output

What kind of output to generate during pass 1. If you select Motion vectors you will see the previous image with arrows showing how to move the blocks to match the current source image. Only white arrows are used to calculate panning, rotation and zoom factor. For interlaced video both of the fields are shown, the first field above the last.

“Motion Vectors”

Block size

The width and height of the blocks used during the image matching.

30

Scale

The maximum scale to do the image matching on. Full is best but very slow.

“Full” - the other values do not work for me with DV-Video

Use pixels

How many pixels in the blocks to actually use when matching. All is best but very slow.

“Every 4th”

Color mode

The image matching can be made in color or grayscale. Grayscale is a little faster but the matching is worse. This setting has nothing to do with the color of the final output of pass 2.

“RGB”

Initial search range

In the most reduced scale this percentage gives the maximum shift while matching. Lower = slightly faster.

“40”

Differential search range

When going from a reduced scale to twice the size, the filter already has approximate shifts. The differential search range is how many pixels up, down, left and right from these approximate shifts to look when matching. Lower values make processing a lot faster but if you have very fast/big rotations and/or zooms, matching can fail for some blocks.

“4”

Discard motion of blocks that have match value less than X

If the best match value found while matching a certain block is below X this block is discarded. The blocks in higher scales that depend on this block are also discarded. These discarded blocks show no motion vector in the output video of pass 1.

”300”

Discard motion of blocks that have 2nd best match larger than best minus X

If the second best match value found while matching a certain block is close to the best match value, this means that the best shift found isn't very reliable. It could just as well be this second shift that's the correct one. For example a blue sky has good match values for all shifts. Setting this parameter correctly discards those unreliable blocks. The blocks in higher scales that depend on these blocks are also discarded. These discarded blocks show no motion vector in the output video of pass 1.

“4”

Discard motion of blocks that move more than X pixels in wrong direction.

When calculating the best values for panning, rotation and zoom based on all motion vectors, the filter soon discovers that some blocks have motion that don't quite fit in with the "main motion". If a block has a motion vector that is more than X pixels off this main motion it is discarded in order to get more precise values. The motion vectors for these blocks are drawn in red in the output video of pass 1 and are not used in any way. Since the panning, rotation and zoom are all done in only 2 dimensions, it's possible to get a lot of these blocks that don't seem to fit in with the main motion when the effect of perspective gets big. This happens when the camera is set to wideangle and not just rotating (along any axis), but actually moving. Here you should use high X values (or maybe limit the matching area to the most distant parts). When zoomed in a lot or when the camera is stationary, the perspective effect is low and you should use low X values (even 1) to discard motion of objects moving even very slightly.

“4”

Skip frame if less than X percent of blocks are ok.

If less than X percent of all blocks are ok (i.e. the rest of the blocks have been discarded), skip this frame (set panning and rotation to 0 and zoom scale to 1)

“5”

Ignore image area outside area

Only area is used during matching. If you check Let area follow motion, the area will move along with the motion vectors between different frames. You can use it if you want to stabilize on a moving object instead of the background. Just don't expect this to work perfectly :)

Set these values according to your video
(I never used these values)

You can set different values per clip

Ignore image area inside area

area is not used during matching.

Set these values according to your video

You can set different values per clip

 

 

 

Destination pixel aspect

Tells the filter to generate video with a certain pixel aspect ratio. If you plan to watch the clip on a computer monitor you'll probably want to use square pixels.

“Standard PAL”
“Standard NTSC”

Destination video size

The size of the output video you want from pass 2.

This parameter is set automatically by the plugin according to the timeline settings

Resampling

The algorithm to use when calculating pixel colors from the source image. Note that none of these are very good when the destination size is a lot lower than the source. Instead, add a separate 2:1 reduction filter (or something) after the Deshaker to reduce scale a lot.

“bicubic”

Edge compensation

A side-effect from stabilizing video is black borders. You can choose between doing nothing about this or lower the amount of black borders by applying an adaptive zoom. The second option determines, for each frame, how much zoom is needed to avoid the borders. This additional zoom is then smoothed using the zoom smoothness parameter, so the borders still become visible sometimes. The difference between Adaptive zoom and Adaptive zoom only is that the first one applies the smoothness parameter to both the zoom stabilizing and the adaptive zoom whereas the second one only applies the smoothness parameter to the adaptive zoom and uses no zoom stabilizing. Use the latter if there's no zooming in the video clip. You can also choose Fixed zoom. The filter will then zoom into the video just enough to eliminate the black borders. Use low correction limits (see below) to lower the amount of zoom.

“Fixed zoom”
(I did not get good results with the other values)

Previous and future frames to fill in borders

This is a kind of additional edge compensation. When the current frame doesn't contain any image data in the "real world area" we want in our output, it can search in past and future frames and use that image data instead. As long as that area is part of the object (or background) that was stabilized on in pass 1, this usually works perfectly. But when other objects move in these areas, it can look a bit strange. It's usually better than black anyway, so I strongly recommend using this feature. Just make sure you crop any borders from the source clip before deshaker. Otherwise this won't work very well at all.

If the current frame is number 50, it searches frames in the following order to find the image data it needs: 50, 49, 51, 48, 52, 47, 53, 46, 54 etc. So for each pixel the closest frame (chronologically) is always used. You can set how many frames to store internally for this feature. More is always better but keep in mind that each frame needs appr. 1.5MB of memory and it can take a long time to search through all frames for image data.

Since VirtualDub filters can't access future frames, the filter uses a little trick. It collects frames and delays the output by as many frames as you've set for future frames. This causes a couple of problems that can be dealt with pretty easily once you know how. First you need to delay the audio. You can do that in the VirtualDub menu Audio/Interleaving. While collecting frames, a text in the output video will tell you how many milliseconds to delay the audio. Second, you must offset the end marker in VirtualDub by the same number of frames. Otherwise you won't get the last few frames. If you don't have enough frames in the end, just append any clip. Those source frames won't be used for anything anyway.

When not using this feature you can move randomly in the clip in pass 2. But with this feature it doesn't work anymore. When using future frames especially, you must walk through that collecting phase before the actual encoding starts. Basically, if the clip you want to encode has 100 frames (numbered 0-99 in the source clip), and you use 30 future frames, you should first step manually from 0 to 30. Then, directly after that, encode the frames 30 to 129.

Try using this feature on a clip with lots of panning, and zoom out by setting Extra zoom factor to something like 0.6. Then you'll get a panorama like effect. It's slow, but fun. :)

Do not use this function
(this destroys the synchronisation of video and sound and is not working correctly)
The plugin will automatically disable this function regardless what values you enter.

Extra zoom factor

An additional zoom factor to apply to the video. This can for example be used together with fixed zoom edge compensation to zoom out just enough for the borders to become slightly visible but still remain hidden in the overscan area of the TV. Then you will see more of the video while still not seeing any borders on the TV.

“1”

Motion smoothness

These values determine how smooth the motion will be. You can set a parameter to 0 to turn off the smoothing completely. This can be useful if you don't want to stabilize zoom for example. But you must use a rather high zoom smoothness if you use adaptive zoom as edge compensation, or the video will zoom in and out very fast to avoid the borders. The motion smoothness calculation is not time-based but rather based on frame count, so you'll need to use larger values for interlaced video to achieve the same effect. If you enter -1 as smoothness you will get "infinite smoothness", meaning the camera will appear to be stationary at the position of the first frame that was processed in pass 1. This feature usually doesn't work perfectly, though.

all values “-1” or other high values

Max. correction limits

To keep the corrections (that cause the black borders) small during fast pans (for example), you can limit the maximum corrections. Especially when using fixed zoom as edge compensation these settings keep the zoom from being too large. What these settings really do is automatically lower the motion smoothness values in certain parts of the video when it becomes necessary.

Horizontal: 100
Vertical: 100
Rotation: 90
Zoom: 100

Some hints:

  • Do not try to edit a deshaker-effect while another effect is rendering. This may interfere with the render result.
  • If something wents wrong during rendering the result is a blank frame.
  • Do not use other effect or transition on the clips you want to deshake
  • First deshake, then fuse the clip, then attach other effects is the safest way to use this effect.

Links:

http://biphome.spray.se/gunnart/video/
http://www.sundancemediagroup.com/articles/deshaker_guide.htm
http://www.codecpage.com/Deshake.html
 

 Some sample Parameters:

 

 

 

 

Autor: Harold Linke, E-Mail: harold.linke@t-online.de ,Datum: 28/08/07