|

Order Digital Video Basics
today and save $3.00 from the retail price.
BUY NOW!
Click
here to view pages from this book

Visit the "All Things Vegas" pages
 |
- A GUIDE TO USING DESHAKER
- ©2004 John Meyer
Quick note for the impatient: If you
already know about VirtualDub and don’t want to read all this stuff, click
on the link in the “Downloading Programs” section to download Deshaker,
and then skip to the “Basic Guide” section to see what settings to use.
Now, on to the guide …
You already know that
your camera should be mounted on a tripod. Blair Witch
Project and Bourne Supremacy actually made their
audiences sick, not because of content, but because of camera motion.
However, sometimes you don’t have time to set up, lock down, and compose.
You also may have to use
amateur footage. For these reasons, you
have probably wished you could motion-stabilize your video in post
production.
You can purchase several
software tools that stabilize video (Steadyhand
from Dynapel, and
Steadymove from a company called 2d3 are the two best-known
commercial products). However, the one I have found works the best is a
freeware utility called Deshaker. While Deshaker includes an
excellent guide, the settings and setup can be a little intimidating.
Since the program is so good, and since so many people in the Vegas forums
have expressed an interest in using it, I developed this guide. I have
written this with the Vegas user in mind, but people using other editing
programs can use the guide as well, as long as you don’t mind my
occasional reference to a specific Vegas feature.
|
View two different examples of processed
footage. |
|
File 1: |
|
|
|
File 2: |
|
|
Downloading the Programs
- Deshaker is
a “filter” that works with a freeware editing utility called VirtualDub.
“Filters” are the same as fX
plug-ins in Vegas.
-
- Download Deshaker here:
-
http://home.bip.net/gunnart/video/Deshaker.zip
-
- The author’s own guide for the program
is found here:
-
http://biphome.spray.se/gunnart/video/
-
- In order to use this program, you need
to download and “install” VirtualDub. Here’s the link to that program:
-
http://www.VirtualDub.org/download
-
- To save AVI files from VirtualDub, I
recommend you use some sort of codec. Unfortunately, the excellent DV
AVI codec in Vegas cannot be accessed by any other program. However, you
have three good options:
- This last codec is not a DV codec, but
is a lossless codec that also preserves a broader
colorspace than DV. Vegas can read AVI files encoded by
Huffyuv.
-
- If you choose not to install a codec,
you can save the file as an uncompressed AVI file. Be warned however,
that uncompressed video takes 90 GB per hour, compared to 13 GB per hour
for DV video.
Back to Top
Installation
- VirtualDub
does not include an installation program. You just open the zip file and
copy all the files to some folder on your disk. I chose to copy them to
the c:\program files\video folder. Make sure you tell your unzip program
to include folders in the unzip operation. Why? Some of the files need
to be in their own folder, and this information is included in the zip
file. In Winzip, you tell it to “Use Folder
Names.” If you get an error message telling you that “readme.txt”
already exists, then you definitely forget to tell your unzip program to
create the folders contained in the zip.
-
- Once you have copied the VirtualDub
files, open the Deshaker.zip file and copy
the “deshaker.vdf” file to the “plugins”
folder created by the VirtualDub install.
-
- You are now all set to start “deshaking!”
Oh yeah, baby, this is gonna be fun!
Back to Top
Theory of Operation
You want theory? Well, in
theory, you can motion stabilize video in Vegas. Open the pan/crop dialog
for a video event. Step through that event one frame at a time. For each
frame, look at the position of the video compared to the previous frame
and use the pan crop window’s left/right, up/down, and rotate controls to
make the video “line up” with the previous frame.
This is exactly what
Deshaker does.
- Of course if you tried to motion
stabilize video using the pan/crop tool in Vegas, it would take you
hours to fix just a few seconds of video, and the results would still
not be that good because it is very difficult to “line up” two frames of
video.
- Deshaker works its magic by using motion
estimation algorithms (similar to what are used for MPEG2 encoding) to
determine what has moved since the previous frame. This gets tricky,
because movement can be caused by the camera moving in the operator’s
hands; by the camera operator actually moving (in a car, on a dolly, or
just walking); or by the subject of the video moving. The trick of
stabilizing video — both for the software, and for you the person
setting the Deshaker controls — is to figure out what movement is caused
by unwanted shaking of the camera, and what movement is caused by the
camera moving or the subject matter moving.
Back to Top
Running VirtualDub
This section of the guide
is for those not familiar with VirtualDub. If you already know
about this program, skip this section.
VirtualDub is a very
simple video editor, but its main reason for being popular is that it
provides a simple way to let people use an amazing array of “filters” that
alter video, frame-by-frame. While some VirtualDub filters are duplicated
in Vegas, many are not.
To run VirtualDub,
double-click on the virtualdub.exe file in the folder you created during
installation. If you are going to use this program frequently, right-click
on virtualdub.exe, select “Create Shortcut,” and then drag that shortcut
to your desktop.
Next, click on File ->
Open Video File to open the AVI file you wish to stabilize. You can
stabilize large AVI files that contain many scenes, but I generally prefer
to work on AVI files that have just one scene.
The final step before
actually doing the stabilization is to load the Deshaker filter. This is
the same as clicking on the fX
button for a Vegas event and then loading the fX.
To load a VirtualDub filter, click on Video -> Filters.
In the Filters dialog, click on the Add button.
Look for the Deshaker plug-in, click on it, and then click on OK. You
should now see Deshaker dialog.

Back to Top
Basic Guide
Now that you have your
video clip loaded into VirtualDub, and you are looking at the Deshaker
dialog, what do you do?
If you are really
impatient, just read this one, short paragraph:
Change all the settings
to match the above dialog, click on Pass 1 and go back to the main
VirtualDub screen. Rewind and play to output. Return to the Deshaker
dialog, click on Pass 2, go back to the main VirtualDub screen, and save
the video.
If you want a little more
information, read the following. If you need more help than this, go to
the Advanced Setting section.
- Click on the big
“Pass 1&2” button at the top of the left column in the dialog box. Set
the Source Pixel Aspect to “Standard NTSC (0.911)”
or “Standard PAL (1.094).” If you are using some other type of video,
then make the appropriate choice.
- Change “Video Type”
to “Interlaced, lower field first” if your video is DV. If your video is
some other type, then make the appropriate choice.
- Change the drive
letter for the “Log File.” I don’t like storing things in the root
directory of my C: drive. The “Log File” will be used to store the X, Y,
rotational, and zoom information for each
frame of video in your clip.
- Click on the big
“Pass 1” button. You can leave all the values at their defaults, but for
better quality (but slower processing), change “Scale” to “Full (most
precise)” and “Use pixels” to “All (most robust).” There is a
significant speed penalty for doing this, and the results are often
“good enough” with the defaults (which are Scale: Half, and Use Pixels:
Every 4th).
- Click on the big
“Pass 2” button.
- Change the
“Destination pixel aspect” to match what you set in step 1. Set the
destination video size to 720x480 for NTSC DV video or 720x576 for PAL
DV video.
- Set “Edge
Compensation” to “None (large borders).”
- Put a check mark in
“Use previous and future frames to fill in borders.” Don’t change the
default of 30 for the previous and future frames.
- Set Motion
Smoothness values of 3000 (NTSC). Set Zoom to zero (to turn it off). You
can use larger values in order to make the motion smoother (I’ve used
settings up to 18,000), but the results may look somewhat artificial,
and you may begin to see unwanted artifacts that make the video look
like it was placed on top of a flag rippling in the wind on top of a
flag pole.
- Set all Max
Correction Limits to 99.
- Finally — and this
is important — click on the big “Pass 1” button (the one on top of the
center column).
You can now click on OK
to exit this dialog and then click on OK again to exit the Filters dialog.
- The Deshaker plug-in now needs to play
through the entire video in order to figure out what motion occurs from
one frame to the next. During this first pass, it stores this
information in the LOG file. To make this happen, press the rewind
button in VirtualDub |<
to put VirtualDub at the
first frame in your clip. Then, without doing anything else, press the
play to output button.
>o Make sure
you press the play to output button, the one with the little “o” next to
it, not the play input button (the one with the
little “i" next to it).
The left side of the
VirtualDub screen will show your video, and the right side will show the
motion tracking algorithms at work. If your video is interlaced (which it
probably is), you will see two screens at the right, one for the odd
fields and the other for the even fields.
Pass 1 takes a long time.
Be patient.
When Pass 1 has finished,
don’t touch any of the play controls in VirtualDub, and immediately open
the Filters dialog again, click on the Deshaker plug-in, and then click on
the “Configure” button. Since you have already configured Pass 2, all you
need to do is click on the “Pass 2” button, and then click on OK, and then
on OK again in the Filters dialog.
Before you save the
results, you need to choose the codec you want to use to save the
resulting, stabilized video. Click on Video -> Compression, and choose the
output codec you want. If you decided not to install a video codec, you
can skip this step and the video will be save as uncompressed video, which
will consume 90 GB per hour of video.
- If you have used Virtual Dub for some
other project, make sure “Full Processing Mode” is selected in the Video
menu.
- Once you have chosen a codec, you don’t
need to do this again until you quit and then re-start VirtualDub (see
below about saving settings between sessions).
Now, click on the rewind
|<
button again, and this time, save the results,
using the “Save As AVI” option in the File
menu. When you start the save operation, Deshaker will begin the second
pass. This goes much faster than Pass 1.
When the save has
finished, you will have a nicely stabilized video file that you can bring
into Vegas. I usually put it on a track above or below the original video
and then use the track solo or mute buttons to A/B compare to an external
monitor. I line it up exactly with the original video, and I use then use
the audio from the original video. Another excellent approach would be to
add the video as a take. To do this, find the video event that is the
original that you used as input to Deshaker
and then use the right mouse button to drag the file from the Vegas
explorer to the video event. You will get a pop-up asking giving you
several options, and you can choose to “Add as Takes.” You can then press
“T” on your keyboard while playing the clip to alternate between takes.
If you want to “play
around” with various settings in Pass 2, you can run Pass 2 over and over
again, without running Pass 1 again. This can be very useful if you want
to experiment with different “Motion Smoothness” settings.
Back to Top
Special Considerations
One thing you will find
if you followed the directions above, is that your stabilized video has
thirty frames of blank video appended to the beginning, and the end is
thirty frames short. This is explained in the Deshaker guide referenced at
the above site. This is the result of Deshaker
accessing past and future frames. You can easily fix this problem by
appending at least thirty frames of video before starting Pass 2 (where
you save the AVI file). To append video, click on File -> Append AVI
Segment, and pick a short clip of just a few seconds. You need a clip that
is at least as long as the Future Frames setting (which in this guide is
30 frames). If it is longer, it won’t make the final clip any longer. It
doesn’t matter what is in the clip because the actual video isn’t used.
This is simply a way to get around one of the few rough edges in the
plug-in.
You may get a “livelock”
warning from VirtualDub at the end of Pass 1. Ignore it and proceed. It
appears to be a harmless bug in either Deshaker
or in the latest version of VirtualDub.
Back to Top
Saving Settings
- Once you get settings that work, you
sure don’t want to enter them each time you use the plug-in.
Fortunately, you can save everything about
your current setup.
-
- In VirtualDub, click on File -> Save
Processing Settings and enter a file name. The next time you use
VirtualDub, simply click on File -> Load Processing Settings, choose the
same file name, and the Deshaker plug-in will be loaded, with every one
of the settings restored to the values you saved. The video compression
settings will also be restored, so you don’t have to specify your codec
again.
-
- Thus, for the next project, you just:
-
- Load your video
- Load the processor
settings
- Click on Pass 1,
rewind, and then play the video to the output screen
- Click on Pass 2 and
save the video file
Back to Top
Advanced Settings
- The settings in the basic guide works
pretty well for the usual situation where you are standing still, with
the zoom set to telephoto, and you are not panning. If you don’t think
you are getting enough correction, you can increase the motion
smoothness parameters in Pass 2. I have used settings as high as 18,000
for horizontal, vertical, and for rotation. Since video is almost never
supposed to rotate, the author recommends setting the rotation
smoothness setting quite high, perhaps as high as 20,000.
-
- If you set these too high, and you have
Edge Compensation set to none, you will begin to see some pretty wild
things happening to the edges. You will occasionally see these artifacts
even with smaller settings, but usually they will not be seen on most
television monitors: They usually get lost in the
overscan, so I don’t bother to remove them. If they are a
problem, you can use “extra zoom” setting in
Deshaker, or the pan/crop tool in Vegas, to zoom in on the video
slightly and thereby eliminate the edges.
-
- For more complicated situations, you
might need to adjust some of the other settings. Here are a few things
you might want to do:
-
- If the video still looks too shaky, even
after you have increased the motion smoothness parameters in Pass 2,
then the motion vectors were probably not set correctly during Pass 1.
-
- To improve the motion tracking, you
need to help the software focus on the part of the video that is moving
because of the camera motion, and ignore the part of the video that is
supposed to be moving.
-
- Deshaker provides a great tool to do
just that. At the bottom of the Pass 1 column, you will find the “Ignore
Image Area” controls. You can use this to define either which area of
the frame you wish to ignore, or which area you wish to include when
saving the motion information for each frame. Usually, the center of the
video contains the actor or something else that is supposed to be
moving. The edges of the video are usually the background. Therefore,
the most common way to improve the motion tracking is to tell Deshaker
to only track the pixels around the outside of the frame, and ignore
everything in the center. To do this, put a check mark in the “Inside”
box in the Ignore Image Area section, and enter the number of pixels you
want for the border at the top, bottom, left, and right side. For
instance, if I want to only look at the top quarter and bottom quarter
of the video (which is a very common situation), for 720x480 NTSC DV
video, I would enter 120 in both the top and bottom Inside Image Area
settings. When you now run Pass 1, you will see video only at the top
and bottom of the output preview screen.
-
- If you use the ignore settings, make
sure that video that remains after the masking process has a lot more
pixels than the “Block Size” specified at the top of the Pass 1 column.
I don’t know how to define “a lot” but with a 30 pixel block size, I
would want to make sure that a 30 pixel block in the center of the first
frame of video never (or at least seldom) disappeared. Thus, the shakier
the video, the less you are going to be able to mask. The author says
that he often uses smaller block sizes to improve motion tracking (down
to block sizes of 16), but only if “Use Pixels” in Pass 1 is set to “All
(most robuts).”
Back to Top
Camera is Moving
- If the camera is in motion (you are
walking or driving), it is much more difficult for Deshaker (or any
motion stabilization software) to figure out which motion to eliminate,
and which motion should be retained.
- One setting that is designed to deal
with this is the Pass 1 setting called “Discard Motion of Blocks That
Move >x Pixels in the Wrong Direction” (one of the longest names ever
devised for a setting). If the camera is moving, and you are not getting
good results, then try increasing this setting from the default 5 to
something more like 15, perhaps even as high as 30. During Pass 1, you
can see the effect of this in the output pane of VirtualDub. You will
see all sorts of arrows, showing how Deshaker thinks pixels are moving
in each section of video. If you see red arrows, this indicates
that Deshaker is going to ignore the motion in this part of the picture
when computing its “deshaking.” Ideally, you
should see red arrows only around that part of each frame that are
actually moving, and should see white arrows around the portions of the
image that are moving only because of the unsteadiness of the camera.
- Using the “Ignore Image Area” setting
can also help.
- If you still are not getting the results
you want, you can try changing the “Discard motion of blocks that have
match value <” setting. The default is 300. Try increasing it by to 500
or 600. If that doesn’t do anything, or makes things worse, try
decreasing it to 150.
- As the guide that comes with
Deshaker describes, the “Discard motion of
blocks” settings are normally designed to let you make changes to avoid
problems when a large part of the frame has indistinct objects, like
blue sky, calm water, etc. In these situations, there are few distinct
"objects" that can be tracked, and therefore you want to throw out the
spurious, random motion matches that the tracking algorithms might
generate just from random noise. In extreme cases, you might actually
ADD shakiness, rather than reduce it. However, the setting can sometimes
also be used to fine-tune the results from a camera that is moving.
- Back to the “Wrong
Direction” setting for a moment. For normal stabilization (as
defined in the Basic Guide above), the author actually recommends
setting this at 1 instead of the default 5.
Back to Top
Stabilization Limitations
- When the camera moves, it blurs the
image because the “shutter speed” of a video camera is normally quite
slow. If you step through shaky video on the Vegas timeline, one frame
at a time, you will see the video go out of focus at the point where the
camera shakes. Usually this blur doesn’t bother the viewer, because your
eye doesn’t see moving objects sharply. However, when you look at a
stationary object, you expect it to be in focus. The problem is that
once the image is stabilized, and the objects in the video that were
moving are now stationary, those objects are now out of focus. The
out-of-focus frames are the ones where the camera was moving. There is
absolutely nothing you can do about this. You’ll have to decide which is
more annoying: The shaky video, or video that pops in and out of focus.
I generally prefer the steady video.
-
- If you know you are going to be shooting
video hand-held, and you suspect you might want to use Deshaker later
on, there IS a way to avoid this problem: Use the “shutter speed”
control on your camera to increase your shutter speed. Although this
does impart a slightly different “feel” to the video, it will completely
eliminate the focus problem. This is especially important when you are
filming from a moving vehicle or other situation where even your
professional, rock-solid, hand-held camera techniques will not be able
to stop some fairly violent camera motion.
Back to Top
Other Uses
If you don't own and
can't afford Steadicam equipment, you can use
Deshaker to generate a “poor man’s” version of
Steadicam. The results can often be quite
good. For instance, if you plan ahead, and do a little work, you can use
this technology to "approximate" a dolly shot. You can walk with the
camera, using the camera's own steadying mechanism, plus a cheap steadying
device, use the Deshaker software, and end up with something that is VERY
stable. Also, if your hand-held camera technique is good, and you can
maintain a steady aim, then this software can often make the result 99% as
good as video taken on a tripod. This is especially true if you have
optical image stabilization enabled on your camera. That feature usually
gets rid of the shake, but the video will still “wander” slightly.
Deshaker can often remove the residual
drifting and wandering.
One possible use,
suggested by one user, is to set the horizontal, vertical, and rotational
motion smoothness settings to -1. As described in the
Deshaker documentation, this causes Deshaker
to never move the camera from its original position, even if it means
moving the video violently and destroying the edges. I have used -1
settings, and didn’t find them useful. However,
what I forgot is that the LOG file created by this process is in essence a
set of instructions for how to keyframe a video to exactly match the
motion of this clip. Thus, if you could use the “Ignore Image Area” and
also the -1 settings to force Deshaker to
track the motion of one portion of the video, then you could load a
different video into Deshaker, and perform
a pass 2 using the LOG file from the first video clip (and with the
motion smoothness settings on -1) in order to make that clip match the
motion of the object in the first clip. You would then render this to an
AVI file, line it up in Vegas, and then composite it with the first frame,
thus giving you a composite track that would match the motion in the child
track. Again, this is theory, but it is intriguing theory nonetheless.
Again, the central part of the idea is to use the stored motion vectors
from one clip to introduce identical motion in a second clip, so
that the two would track.
Back to Top
Conclusion
Deshaker is a great tool to salvage shaky camera footage. It can be
used to make amateur hand-held video look like professional hand-held
video, or make professional hand-held video look like it was taken on a
tripod. You can also use it to approximate the results from a
Steadicam (notice I used the word
“approximate,” not duplicate). With care and forethought, you can even use
it to produce moving camera results that begin to look like they were
taking on a track dolly. It is a very useful tool to have in your
bag of tricks.
View
more tutorials from VASST
|