Skip to content
Features

Digital Video Cleaning without the Elbow Grease

Learning how to capture video is one thing. Cleaning it up is a whole 'nother …

Matt Woodward – | 0
Story text

Part 2 of 3: Video Cleaning featuring VirtualDub and the AviSynth frame server

Introduction

This guide is the second in a series on the Art of Video Capture, Clean-up, and Compression (Part I is here). This guide deals exclusively with the second step: Video Clean-up. While many of the lessons to be learned in this guide apply to all platforms, this guide is written from the perspective of PC-based hardware, running Microsoft Windows (and is largely MS OS version agnostic).

In Part 1, we covered the basic steps to properly capture video from an analog medium such as a television broadcast or your VHS VCR using a video capture card. We also mentioned that there are other ways to import your analog video to your computer via analog-to-digital DV bridges and DV cameras. Whichever way you get your video into your computer, this second part of the series will cover certain techniques such as Cutting, Cropping, De-interlacing, Inverse Telecine, Filtering, Noise Reduction, and Intermediary Recompression. Simply put, this guide will teach you how to clean up your video and set you up for final destination (compression), which will be covered in Part 3.

Capture Overview

In this guide we will be covering the following aspects of Video Clean-up:

  • Recommended
    Computer Requirements
  • Downloading
    and Installing the Required Software
  • AviSynth
    and VirtualDub
  • Introduction to VirtualDub
  • Cutting and Cropping
  • Combing: What is it?
  • De-combing: The 2 Methods
    • De-interlacing
    • Inverse Telecine (IVTC)
    • When
      to use each Technique
  • Basic Filtering and Noise Reduction
    • For most sources
    • For VHS video
  • Advanced Filtering and Noise Reduction
    • Using AviSynth
    • Decombing: When to use each Technique
    • Motion Compensation De-interlacing with AviSynth
    • Inverse Telecine (IVTC) with NTSC video
    • Performing Inverse Telecine with AviSynth
    • Decombing PAL/SECAM video
    • Deciding which method to use with PAL/SECAM
    • A Fancy Alternate Method
    • Hybrid Video Streams
    • The Advantage of AviSynth
    • AviSynth Noise Filters
    • The Filter Chain
    • Using the Crop() function
    • Further Experimentation
  • Intermediary Recompression

Recommended Computer Requirements

  • x86-based
    PC with both MMX and SSE support
  • 256+MB
    RAM
  • 40+GB
    of Free HD space
  • Microsoft
    Windows98/Me/2000/XP

These are the minimum recommended requirements to perform video clean-up on the Windows platform. It is entirely possible to do video clean-up with less than this configuration, but the elapsed time for clean-up will be significant longer. Some filters require that you have CPUs with MMX and/or SSE support. Obviously, a faster CPU, more RAM, and more HD space will make this job easier and faster.

Downloading the Required Software

All the pieces of software that we will be using, except for one, are freely downloadable. If you want to work through this as a tutorial, please download each specified software package, filter, and codec.

  • VirtualDub 1.5.x or higher
    (get the Regular -or- Pentium4 optimized version)
  • VirtualDub
    Filter: Dynamic Noise
    Reduction (get the MMX version)
  • VirtualDub
    Filter: 2D
    Cleaner Optimized 0.9 (get the Pentium3 -or- Athlon version)
  • VirtualDub Filter: Chroma
    Noise Reduction
  • VirtualDub Filter: flaXen VHS
    Noise Reduction
  • VirtualDub Filter: Deinterlace
    – Area Based
  • AviSynth 2.0.8 (While it is
    true that AviSynth 2.5.x is no longer in beta testing, we have written this
    guide around version 2.0.8)
  • AviSynth
    Filter: Donald
    Graft’s Decomb
  • AviSynth
    Filter: TomsMoComp
    Filter
  • Codecs:
    • HuffYUV 2.1.1
    • PICVideo
      MJPEG

The PICVideo MJPEG codec was previously given away for free by Pegasus Imaging for non-commercial use. The latest versions of the PICVideo MJPEG codec can still be downloaded for free, but contain a watermark in the upper right corner of the video. The watermark-free codec can be licensed for a mere $18. Also note that AviSynth 2.0.x is NOT compatible with 2.5.x type filters. Nor can AviSynth 2.0.x and 2.5.x be installed at the same time either. For advanced users, it is possible to use 2.0.x filters with AviSynth 2.5.x, but it requires you to perform a somewhat complex LoadOldPlugins procedure. For now we just recommend that you download and install AviSynth 2.0.x and its respective 2.0.x filters.

VirtualDub: Cutting, and Cropping

Installing the Required Software

If you’ve read Part 1 of this guide, you may have already installed VirtualDub. If not, unzip the files in the VirtualDub ZIP file to its own directory. Make certain you retain the folder structure noted in the ZIP file. Similarly, unzip the Dynamic Noise Reduction filters, 2D Cleaner filter, Chroma Noise Reduction filter, flaXen VHS Noise Reduction filter, and Deinterlace – Area Based to the “Plugins” directory.

Next, launch the AviSynth auto-installer. Once AviSynth is installed, unzip the Decomb and TomsMoComp filters and place the files in the “C:Program FilesAviSynth2plugins” folder (or wherever your plugins folder resides). If you do not have the Huffyuv and the PICVideo MJPEG codecs installed, please follow the instructions for each and install them.

AviSynth and VirtualDub

We will be using two pieces of Open Source software: AviSynth and VirtualDub. In the first part of this series, we talked about VirtualDub and how it has an excellent Video Capture function. In this guide, we will be using VirtualDub to do Linear Video Editing. To supplement our Linear Video Editing, we will be using AviSynth, which is a powerful Frame Server. AviSynth is not a program that operates on its own, nor does it have a Graphical User Interface. In fact, this frame server is only useful when it interfaces with another program like VirtualDub. Despite these limitations, AviSynth does offer a potent scripting language to do things that would be unreasonably complex (or even impossible) to do in VirtualDub.

Introduction to VirtualDub

If you have never used a video editor before, some of this may seem a little daunting. But do not worry; VirtualDub is rather easy to use. First, we are going to help familiarize you with the interface. Start by going to “File” => “Open Video File” and pick an AVI file to open. If you used Part 1 of this guide, feel free to use one of the videos that you captured. In the lower-left corner of VirtualDub, you should see a set of controls:

The following is a table of their respective functions:

Stop – Stops video playback or the current operation in progress.
Input Playback – Starts playback of video file. Shows what video
looks like before
any filtering from VirtualDub takes place.
Output Playback – Starts playback of
video file. Shows what video looks like both before and after
filtering from VirtualDub takes place.
First / Last Frame – Moves pointer to the beginning / end of the video.
Back / Forward 1 Frame – Moves back / forward one frame at a
time. Both buttons will update the “before” and
“after” video windows.
Scan Back / Forward to Next Keyframe – Plays backward or forward
in “Input Playback” mode to next keyframe. All frames are
keyframes for Huffyuv and MJPEG codecs, so these buttons are not very
useful. It is more useful with MPEG and DivX since they use only a few keyframes
and lots of update frames.
Scan Back / Forward to Next Scene Change – This is a useful
function if you are trying to edit a video that was captured from your
home movies. Instead of moving forward and backward with the slider, you
can let VirtualDub find the next scene change for you.
Mark In / Out – Use these buttons to create selections
for processing or deletion.
Slider – Grab the slider and move to any point in the video.
Click to the left or right of the slider and move back or forward 50
frames, respectively.

Cutting

To cut video out of the timeline, use the above described buttons to move to a certain frame and select the “Mark In” button. Move to a later frame and select the “Mark Out” button. You will probably notice the selection appear in blue on the slider bar. To delete the selected video, press the Delete key on your keyboard. You can do this multiple times throughout your video timeline.

Cropping

Depending on the video that you are editing, you may want to crop your video. For example, you may want to eliminate VHS noise along the edges of the screen. Or perhaps your video is of a television show that is in letterbox format and you want to crop out the black bars on top and bottom. We accomplish this by activating one of VirtualDub’s internal filters.

Open the Video Filters dialog box: Select “Video” => “Filters”

Click the “Add…” button, select “null transform” from the Add Filter window, and click “OK”. With the “null transform” filter highlighted, click the “Cropping…” button.

This excellent television show is in letterbox format. As shown here, to crop out the black boxes, the Y1 and Y2 offsets have been moved 60 pixels each. Obviously, every video capture will vary and will probably require you to make your own personal adjustments. The major advantage of cropping out the black bars is to speed up filter processing as well as use less disk space and/or increase video quality when re-compressing. When cropping, we recommend keeping the X and Y dimensions to multiples of 8. Most encoders compress using 8×8 pixel blocks and will have often have difficulty, sometimes smearing the image, if the dimensions are not multiples of 8. If you find that your video does not crop perfectly at intervals of 8, you can either crop out a few extra lines of video until you reach an interval of 8, or you can choose to add thin black “letterbox” bars using the resize filter with the “expand frame and letterbox” option. If you use the resize filter to letterbox, make certain that the “New Height” and “New Width” fields are set to the current dimensions of your video to prevent this filter from actually resizing the video. (If the dimensions you enter are the same as the current dimensions, only the “letterbox” portion of the code will engage.)

Combing: What is it?

As shown in this still frame, we have Arby’s new mascot: The Dancing Oven Mitt. While there is nothing particularly special about Mr. Oven Mitt or the Roast Beef sandwich he is dancing around Mmmmm… Roast Beef…., we did want to point out what “combing” is. In the enlarged example, it is easy to see that this ugly video phenomenon looks strikingly like the tines of a hair comb. Thus the term.

Why does such a strange phenomenon occur? And why does this never appear on a TV set?

To understand this, we need to travel back in time to the 1930s when cathode ray tubes (CRTs) were still rather new and transistors had not been invented yet. Back then, science had progressed far enough so that it was possible to send “black and white” images over the airwaves. Engineers were given the task of coming up with a standard for transmitting television, but this proved to be a difficult objective. The primary goal was to achieve:

  1. A smooth
    stream of images (high refresh rate)
  2. with a high enough resolution (high line count)

The main challenge, at the time, was getting the electron beam in the CRT to do both. The engineers were able to create CRTs with a high number of lines (around 480), but were only able to get the electron beam to reliably refresh all the lines in around 1/30th of a second. As many of you can imagine, a refresh rate of 30hz would produce a lot of flicker and literally cause headaches for its viewers. Whether this was due to the limited hardware (vacuum tubes), the primitive CRTs, or the narrow frequency spectrum allotted, the engineers just could not produce 60 full frames per second. To get around this limitation, they decided that they could get the same resolution and nearly the same fluid motion of 60 frames per second by transmitting 60 fields per second instead.

What is the difference between a “frame” and a “field”?

In the world of television, a frame is a single electronic picture just like a frame of film on a motion picture reel. On the other hand, a field is half of a frame. More specifically, a field is either all the odd horizontal lines (1,3,5,7…) or all the even horizontal lines (2,4,6,8…) of one frame. When a video camera operates, it “sees” a certain amount of frames per second. For each full frame that the camera sensor “sees”, it only captures and stores one field (half of a frame). This would be either all the odd-numbered lines or all the even-numbered lines. Instead of taking the time to to store both fields of the same point in time, it moves on to the next frame and, again, it only stores only one field.

Here is the important concept that may not be obvious: Each field that is captured takes place at a unique point in time. When you watch television in the US, you are actually watching 60 half-frames per second. By taking 2 half-frames (“fields”), one “odd” and one “even”, it is possible to construct a whole frame by weaving the odd and even lines together. This “weaving of the lines” is known as interlacing.

To help you better visualize what is going on, we have a few animated GIFs of a “clock” whose hand appears to be running rather fast. (Click “Reload” on your Browser if clock motion has stopped or is out of sync.)

Real Life (Fluid Motion) – Ok, so this is not
a real clock or fluid motion. (It is supposed to be about 20 frames per
second, but animated GIFs are not known for their speed, so it might be
less.) Just pretend for
a minute that you are looking at a the hand of a real-life clock moving with very fluid motion.
Individual Fields – Discreet even and
odd fields
alternate in succession. Running at 20 fields per second, this is what
it would look like if each field were shown individually, one after the
other. (In reality, the blank white lines in between the active lines
fade to black on your TV set. We just chose to fade to white since it
will look better in the PDF version.) Click
here to observe a single field.
2 Fields per Frame (PC) – Most computer video
formats work exclusively with frames. Consequently, every 2 fields are
constructed into a single interlaced frame. As shown here,
wherever there is motion, the “combing effect” occurs. Because
every 2 fields are merged into one frame, the video runs at half-rate.
In this case, around 10 frames per second, which explains the less fluid
motion.
Interlaced Fields (TV) – The phosphors inside the
TV are designed to stay lit just long enough for 2 fields to be drawn.
As soon as the second field is drawn, the first field needs to be drawn
again (and vice-versa). The TV is not forced into creating frames from
fields like with the PC, but rather the fields are drawn in an
alternating fashion. The long persistence
of the phosphors blend each field with the next to prevent the dreaded “combing
effect”. The resulting illusion is that full
frames are being drawn at a full frame rate.

We want to point out that in reality, no television set runs at 20 fields per second. We only chose this rate because it was fast enough to convey fluid motion, yet slow enough for you to still see and examine the individual frames/fields. For the US and Japan (NTSC), the real rate is around 60 fields per second (~59.94 to be more precise). For most of the rest of the world (PAL or SECAM), the rate is exactly 50 fields per second. If it is not obvious enough already, the major advantage to using fields is that only half the bandwidth is required to achieve the same effect as full frames. This nifty little analog compression trick made television a viable reality using 1930s technology. Unfortunately, this leaves us with a bit of a problem when trying to deal with computers.

De-Combing: The 2 Methods

As we just noted in our comparison table of animated clocks, most computer video formats work exclusively with frames. Consequently, every 2 fields are constructed into a single interlaced frame. (Fields 1 and 2 = Frame 1, Fields 3 and 4 = Frame 2, Fields 5 and 6 = Frame 3, etc.) Wherever there is motion in the frame, the combing effect will occur. Our primary objective is to remove (or “decomb”) the interlacing. This is done through various decombing techniques. Fortunately for you, we are here to explain the many ways to de-interlace, their advantages / disadvantages, what is the best method, and how to do it.

Method #1: De-interlacing

We will start by examining a single interlaced frame of this race car speeding down the track. The first thing that you should probably notice is that there is a lot of motion in this frame. Not only is the car moving very fast, but the camera has to pan with the racecar to keep up with it. The interlacing on both the car and the background should be very obvious. In fact, you should be able to clearly see duplicate images of the objects in the background (click on the picture to see a larger version). This is a classic example of the ugly effects of interlacing. The following images in the table following the first example will show some of the various common methods of handling interlacing, detailing the pros and cons of each action.

(NOTE: All images shown are magnified 2x for detail. You can click on each image to see more of the frame.)

Interlaced Frame – The enlarged image at the
left shows interlacing wherever there is motion. It should be
evident that with quicker movements, the disparity of the two
fields will produce what appears to be two separate images in
one frame. (Note the # 27 on the car door.) As we mentioned
before, this is because each field takes place at a different
point in time. So each frame records two separate time points
approximately 1/60th of a second apart from each other for
NTSC. (PAL/SECAM is 1/50th.) Depending on the output
format/destination, leaving your video interlaced like this
may actually be a smart idea. This will be covered in more
detail in Part 3 on Video Encoding. For now, we will assume
that this is a bad idea and that it should really be
de-interlaced.
Blending
–
The enlarged image at the left shows the results of
blending the two fields together. This is probably the easiest
and fastest type of de-interlacing. By the same token, the
blending of fields creates an image that is less crisp and
less detailed than other de-interlacing options. Because this
method utilizes both fields, the duplicate images still exist
(see the # 27 on the car). While some people say this blurred
duplicate image is annoying, others will say that it is not
that noticeable during playback. In reality, it just comes
down to personal preference.

Smart Blending –
Some de-interlacing filters use algorithms to detect the parts
of the frame that appear interlaced, only the interlaced areas
of the frames are blended together. This takes a little longer
because each frame needs to be analyzed, but it does preserve
more detail in the frame.

Interpolation – The enlarged image at the left
shows a much sharper, clearer image. By discarding a field
(either all of the even lines or all of the odd lines) and
then interpolating (using the data from the lines above and
below the discarded lines), a crisper image is produced. But
notice that more noise has been introduced into the frame.
Also realize that on edges where there is high contrast,
“jaggies” appear. (see the front fender off the car.)

Smart Interpolation – Just like smart
blending, algorithms can be used to detect and remove only
parts of the field that are interlaced. By removing only parts
of the image, more detail is preserved and less noise is
introduced into the frame. It is important to note that these
interlacing detection algorithms are hardly perfect and
sometimes certain portions of a frame are not de-interlaced
when they should be and vice-versa.

Motion
Compensation –
The enlarged image at the left shows the
sharpest, clearest image of the bunch. Not only is noise
reduced in the frame, but the sharp, high-contrast edges are
left free of the dreaded “jaggies” (see how smooth the front
fender is). Motion Compensation works similarly to
Interpolation, but instead of completely discarding the one
field within the frame, it uses advanced algorithms to analyze
the difference between the two fields. It then takes parts of
the discarded field and uses it to reconstruct a more accurate
image within the frame.

Although there are other
types of de-interlacing, Motion Compensation is clearly one of
the best methods of de-interlacing. The only real downside is
that it can be somewhat CPU
intensive.

Method #2: Inverse Telecine (IVTC)

By now you may be thinking to yourself that this Motion Compensation de-interlacing technique is the way to go and that you should apply it to every thing you see that has combing effects. Well, we have to break the bad news to you: Not every video that displays this combing effect is interlaced. What you may see on the screen may look like interlacing, but in reality what you may be witnessing is something called Telecine (or telecined video). So what is this “Telecine” that we speak of? Unfortunately, we do not have a concise definition, so we are going to have to break out some more drawings, diagrams, and go into a short discourse into what it is and what to do about it.

The majority of television shows and all motion pictures these days are being shot using either movie cameras (read: film) or a relatively new digital video camera format called “24p”. In both cases, the end result is that the TV stations have to deal with video that runs at 24 progressive frames per second. As we mentioned before, the NTSC format runs at 30 interlaced frames per second (or 60 fields per second, depending on how you want to look at it.) So, the quandary for every TV station is to convert 24fps progressive to 30fps interlaced (aka. 60 fields per second.)

How is 24fps progressive converted to 30fps interlaced? In a nutshell, every 4 frames of progressive video needs to be stuffed into 5 frames (or 10 fields) of interlaced video. But it needs to be done in a fashion such that motion within the video appears smooth and seamless. While it would be possible to duplicate every 4th frame to fill in as the 5th frame of interlaced video, this would result in jerky video. To get around this, the answer lies in treating all the progressive frames of the source video as if they were fields. In other words, 4 frames are broken into 8 fields. Two of the 8 fields are duplicated and evenly distributed making 10 fields. These 10 fields are then reassembled into 5 frames.

At the top of the diagram, we start with 4 progressive frames. For illustrative purposes, we numbered each frame 1 through 4. We also used only a dozen or so lines (instead of hundreds like on your TV set). Additionally we colored the odd-numbered fields red and the even-numbered fields blue to help you differentiate between the fields as we progress. Green arrows were also inserted to show how the frames are broken apart, manipulated, and reassembled. The telecine process works as follows:

  • Step 1 – Disassemble the 4 frames into 8 fields. Each
    frame is separated into pairs of fields and placed into an “odd,
    even, odd, even” order. (i.e. red, blue, red, blue)
  • Step 2 – Create 10 fields out of 8 fields by duplicating 2
    fields.
    While this process may seem tricky, it is actually
    rather simple. We start by keeping the first 2 field pairs
    together (Red-1, Blue-1 and Red-2,
    Blue-2) and moving them down to the 3rd
    row in the diagram. Next we make our first duplicate field by
    using Red-2 again and we pair it with
    Blue-3. Then we pair Red-3 with Blue-4.
    And finally, we use Blue-4 again, but
    keep it paired with its original partner, Red-4.
  • Step 3 – Reassemble the 10 fields into 5 frames. Each
    pair is simply reassembled into frames. We now have 5 frames where
    we previously had 4. And this stream is played back at 30 frames
    per second (or 60 fields per second), but yields the illusion of
    the original 24 progressive frames per second.

You may be inclined to think that the 2 combed frames would stand out next to the progressive frames, but as we learned before, the television was designed to work with fields, not frames. So if you examine the 3rd row (instead of the 4th row), you will notice a pattern of 2 fields from the one frame, 3 fields from the next frame. It is this uniform alternation between 2 and 3 fields which makes the video stream appear smooth. (Undoing this effect is therefore called 3:2 pulldown.) In addition to the alternating 2 / 3 / 2 / 3 field pattern, you should notice that the new video stream produces 3 progressive frames and 2 combed frames. Both the field and frame progressions repeat ad infinitum and are signature characteristics of Telecine.

Inverse Telecine (IVTC) works by just reversing this process. Frames are split into fields. The duplicate fields are detected and removed. The fields are reordered properly and are then re-assembled into frames once again.

When to use each Technique

Now that we have covered the theory of two decombing techniques, we want to briefly cover when to use them and when not to use them.

  1. If every frame of your video (in the motion areas)
    appears combed, then you will want to use Motion
    Compensation de-interlacing
    . If you attempt to use Inverse
    Telecine, you will end up decimating valid frames and your video
    will appear very jerky.
  2. If the frames of your video (in the motion areas)
    alternate between progressive and combed, then you will
    want to use Inverse Telecine. If you attempt to use
    de-interlacing instead, you will just end up saving redundant
    field data and wasting your precious video bandwidth on these
    extra fields.

Basic Filtering and Noise Reduction

Unless you are dealing with video from a high-quality source like DVD or your miniDV Camcorder, virtually all video that you deal with will require some of the most basic filtering. This typically consists of adjusting video levels and noise reduction. In this section, we are going to show you how to apply what we have learned using VirtualDub and the filters available for it. These filters are GUI-based, easy to use and understand, and are all rather effective in most cases.

Filtering and Noise Reduction for most sources

All video has a certain level of (what could be construed as) “noise”. Well mastered DVDs contain tiny amounts of noise to make still scenes look more real. Cable TV, especially the analog variety, has noise. Depending on how much noise your video has, you are most likely going to want to apply at least a little bit of Noise Reduction (sometimes called “denoising”) to improve the visual quality of your final output. Aside from most noise being distracting to the viewer, noise also does not compress very well. The noisier the video, the more bandwidth is required to compress the video. Or in situations where there is only a limited amount of bandwidth available, the compressed image quality can really suffer due to the noise.

What we are about to teach you are the most basic principles of noise reduction. While there is a lot to learn about noise reduction, what you learn here should get you started in the right direction. You should also know that the filter recommendations we give here will not work in every scenario, but they should work most of the time. You can only improve through experimentation and discussion with others. When you get more comfortable, you can start experimenting with the dozens of other noise reduction filters.

To perform Filtering and Noise Reduction for most sources, we will to go back to VirtualDub’s filter screen and create what is known as a “filter chain” because it is literally a chain of filters. It is important to note that each filter in the chain creates a cumulative effect, so the order of each filter is just as important as which ones we use. In our basic filter chain, we will be using the following 4 filters: Deinterlace – Area Based, Levels, Dynamic Noise Reduction, and 2D Cleaner.


Deinterlace – Area Based – This will be the first filter in
our filter chain. It is a “smart” de-interlacer much like the
ones described previously in the section that covered deinterlacing
theory. Unfortunately, it is not able to perform motion compensation or
inverse telecine (IVTC). What it does allow you is a very easy and
effective way of deinterlacing those interlaced frames in your video.

This filter has 3 major options: Threshold, Edge Detect, and a
Blend/Interpolate toggle. The default options are actually quite good, but
if you want to mess around with the filter, it is good to understand what
each option does.

Threshold tells the filter how much to de-interlace. Higher
values de-interlace less, lower values de-interlace more. If the
threshold is too high, the filter may de-interlace areas that are not
interlaced. Similarly, if the threshold is set too low, areas that should
be de-interlaced will go untouched.

Edge Detect helps the filter tell the difference between
interlaced lines and real edges. Higher values leave more edges in tact,
but can allow more interlaced lines to slip through. Lower values will
tend to de-interlace better, but also smooth edges more.

Blend instead of Interpolate is a toggle that allows you to
choose which style of de-interlacing you desire. See
this page on de-interlacing
again to compare blending vs.
interpolation to see which style you like better.

Levels – This filter will be the second in our filter chain. This filter can be used to adjust the overall brightness or
darkness of the video. Unlike the “Brightness/Contrast” filter,
this allows the light intensity (“levels”) of the video to be
adjusted without incurring the undesirable clipping effect (covered
here in Part 1). It is important to use this filter to adjust the video levels first so
that the noise reduction filters can more easily pick out the noise later
on down the chain.

The controls for this filter consist of 5 triangle-shaped
sliders. We suggest that you do not change the Output
Levels. This leaves us with the Black, Grey, and White triangle-shaped sliders of Input
Levels.

As shown in the screen shots at the left, we have activated the
“preview” mode and sampled a black frame. As you can probably
see in the histogram, the black frame is not truly “black”. Black
in the RGB color space has a value of 0, and White has a
value of 255.

If the frame sampled were truly black, the spike in the histogram would
be at the very left side. Instead the spike is offset from the left side meaning that the majority of the values are probably in the low teens
making this frame a very dark shade of gray. In order to correct this
problem, slide the black triangle just to the left side of the spike on the
histogram. (Do not slide it past the left side of the spike or you will
start to clip the black levels.) As you slide it from the left towards the
spike, you will probably notice the
“filter preview” window turn from a dark gray to a true, uniform
black. (if you have a particularly dark monitor, you may need to turn the
brightness up on your monitor controls in order to see this happen…)

Once you have the black levels corrected, we may need to do basic gamma
correcting. If your monitor came with color/brightness calibration
software, we suggest you install it. Most monitors, by default, are not calibrated
properly. If you attempt to gamma correct without a properly calibrated
monitor, your final result may be too bright or too dark.

To gamma correct, move to a
frame of video in the “filter preview” window with an average
lit scene. Chances are the black level correction made the video darker
than before. In order to correct this, slowly slide the gray triangle left
towards the black triangle. If you move it too far, your video will be overexposed.

Unless your capture is way too dark, we recommend that
you not exceed a gamma correction of 1.300. More than that and your video
risks being too bright, especially if your target is ultimately to create
a video that will be viewed on your TV. (Remember, if your monitor is not
calibrated properly, it could be your monitor that is too dark, not your
capture…)

Dynamic Noise Reduction – This
filter is the first of the real noise reduction filters and is considered
a temporal cleaner –or- 3D cleaner because it operates by
analyzing pixels in multiple frames (Z axis). By analyzing the frames in front of
and behind the current frame, the filter then compares the differences
between them and then applies changes to the current frame based on these
differences. When used correctly, this filter will remove the
majority of the video noise.

If the noise threshold is set too high, too much cleaning takes place
and ugly artifacts appear to trail from moving objects in the video. If
the noise threshold is set too low, very little cleaning takes place and
the noise remains. By default, this filter is set to 12. We feel that this
is too high. From our experience, the highest it should be set to is 10
and often should be set lower. When in doubt, err on the side of setting
the noise threshold too low.

2D Cleaner Optimized – This
filter is the next in the chain of noise reduction filters. It is called a
2D cleaner -or- spatial cleaner because it only operates on the pixels
in a single frame (X and Y axis). As defined
in the help file, 2D Cleaner works by “averaging the source pixel with the surrounding pixels. Higher thresholds blend more.”
The X and Y Radii settings “define the area around the source that will be considered by the filter. The bigger the radius, the better the noise reduction can be…”
The major drawbacks to setting the radius too high is that it takes more
time and the areas that are blended tend to get smoothed far too much,
thus ending up with loss of detail and a very soft image.

This filter
comes last because sometimes the Dynamic Noise Reduction
filter can leave behind minor artifacts or miss some of the more subtle
noise. The general effect of the 2D cleaner is to lightly smooth out these
anomalies without removing any significant detail.

We recommend setting the X and Y radii to 1 and 1
which will yield a 3×3 matrix. The Threshold setting should be set
between 8 and 20 for optimal results. More than 20 tends to blend too
much of the frame. Less than 8 tends to do very little.

Filtering and Noise Reduction for VHS Video

Cleaning up video from a magnetic tape source can be a rather tricky proposition. While this is somewhat true of media like Betamax, 8mm, and Hi8, this is especially true with VHS video. This section will address the 2 major problems with VHS Video: Chroma Noise and Image Stability.

Chroma Noise Reduction – This filter addresses an annoying anomaly that frequently appears on all types of video, but it tends to rear its ugly head most on videotape. The phenomenon known as “chroma noise” looks like a shimmering “rainbow” of light red, green, and blue colors. This rainbow can most frequently be found in areas of the video where high-contrast checkerboard or parallel line patterns appear in the video, but it can show up elsewhere as well.

Unlike most video where chroma noise may only appear briefly, VHS video will frequently have chroma noise littered throughout the video. This filter will allow you remove most of the chroma noise from your video so that it will be less noticeable. Unfortunately because every video is different it requires that you play with the settings to achieve the right results.

In the test video clips that we tried, we found that the default settings (shown here) were a little too strong and tended to leave residual “after images” during many scene changes. To counter act this, you can reduce the filter strength (Y-axis/Vertical slider) on both Chroma1 (U) and Chroma2 (V) to reduce the intensity of the residual artifacts. You can also reduce the temporal persistence (X-axis/Horizontal slider) on both so that the residual artifacts only appear for a short time (1 or 2 frames).

This filter also has the option of performing chroma shifting for you if you find that your colors are not aligned properly on the video. The Chroma shift slider will push the colors back in line with the rest of the video.

If you find that your video contains very little chroma noise, you may want to consider skipping this filter altogether.

Before talking about this filter, we thought it prudent to bring up the topic of using high-end VHS machines and Time Base Corrector (TBC) devices. (We discussed this at the end of Part 1 of this Video Guide.) If you are serious about converting VHS to digital video, re-read that passage. If you are not, then the flaXen VHS filter may be able to fix your video stability problems.

This filter is actually 4 filters in 1. Although, we recommend that you only attempt to use the “Stabilizer” part. The other 3 functions are not as useful and/or do not function as well as other filters available for VirtualDub.

We fully recommend that you read the documentation that comes with this filter because each video requires careful tweaking of each parameter to obtain the best results. Please use caution since this filter has the very good potential of making your video actually look worse.

At this point, you should have a fairly good idea how each filter works and how to construct a filter chain with these filters. If you managed to add each filter and adjust the parameters, the Filters Window in VirtualDub should look something like this:

Choosing your Path

At this point, we have explained all the major technical details with video clean-up and we have shown you an easy and practical way of cleaning up your video. You now have a choice:

  1. You can Learn about advanced filtering and noise reduction techniques using AviSynth.
  2. You can Skip to the end and learn how to use intermediary compression.

Advanced Filtering and Noise Reduction

Welcome to the section on Advanced Filtering and Noise Reduction. This section is going to be a little bit more difficult than the “basic” section, but the power and effectiveness is a lot greater. Before we get started, we would like you to download and install a variant of VirtualDub called VirtualDubMod (be sure to download the latest version labeled “all inclusive”). While the original VirtualDub is a fine choice for this section, it does not have the nice built-in script editor that we are going to be relying on to dynamically tweak our scripts.

Using AviSynth

Now that we have covered the most basic filtering, we are going to move forward and teach you how to use the AviSynth frame server to do all your dirty work. As was mentioned before, AviSynth does not function on its own nor does it have a Graphical User Interface (GUI) like VirtualDub. Rather AviSynth is merely a DLL that other programs can use and call on to do work. AviSynth acts as a “frame server” because it takes basic instructions from VirtualDub like “Send me the next frame”. As a frame server, AviSynth also gets to work on the video frames before VirtualDub does. Despite all this, AviSynth does utilize a powerful scripting language which enables you to do many different and creative things that cannot be done with VirtualDub alone.

Normally, the chain works as follows: Input AVI => VirtualDub => Output AVI.
Using AviSynth, the chain is modified: Input AVI => AviSynth => VirtualDub => Output AVI.

Just like our VirtualDub filter chain, we are going to show you how to assemble an advanced filter chain consisting of more powerful AviSynth filters.

Decombing: When to use each Technique

Recalling what we learned in the theory section on Decombing, we are going to quickly recap when to use each technique.

  1. If every frame of your video (in the motion areas) appears combed, then you will want to use Motion Compensation de-interlacing. If you attempt to use Inverse Telecine, you will end up decimating valid frames and your video will appear very jerky.
  2. If the frames of your video (in the motion areas) alternate between progressive and combed, then you will want to use Inverse Telecine. If you attempt to use de-interlacing instead, you will just end up saving redundant field data and wasting your precious video bandwidth on these extra fields.

Motion Compensation De-interlacing with AviSynth

Since Motion Compensation is the best tool for the job of de-interlacing true video, we are going to use a filter for AviSynth called “Tom’s MoComp”. It is important to realize that outside of just serving frames, AviSynth has its own agenda when it is executing the script that you have written for it. In our case, we are going to have AviSynth load the TomsMoComp DLL into memory, open the AVI, and then perform Motion Compensation on a frame whenever VirtualDub requires another frame. Because AviSynth is acting as a proxy between the Input AVI file and VirtualDub, you may notice that the VirtualDub interface may seem sluggish. This is particularly true as your AviSynth script becomes more complex and CPU intensive.

To create our Motion Compensation De-interlacing script, launch VirtualDubMod and open the Script Editor under the Tools menu (Ctrl-E). Insert the following code, tweak the AVISource parameter to match the AVI file you want to work on, and save this script as “script.avs” (the .avs extension is required.)

AVISource(“C:video.avi”)
TomsMoComp(1,5,1)

This script is rather easy to follow.

  • Line 1: Open the AVI file for processing. Open the file “C:video.avi” using the “AVISource” call.

  • Line 2: Perform Motion Compensation with the “TomsMoComp” call.

Perhaps you are wondering what the (1,5,1) on TomsMoComp does. Fortunately, this has already been well documented by Tom Barry, himself. The following is an abbreviated version of his documentation:

TomsMoComp(TopFirst, SearchEffort, VerticalFilter)

TopFirst – assume the top field, lines 0,2,4,… should be displayed first. The default is the supposedly more common BottomFirst (not for me). You may have to bring it up in Virtualdub and look at a few frames to see which looks best (0 = Bottom Field First, 1 = Top Field First). Setting TopFirst = -1 will automatically pick up whatever Avisynth reports.

SearchEffort – determines how much effort (CPU time) will be used to find moved pixels. Currently numbers from -1 to 30 with 0 being practically just a smarter bob and 30 being fairly CPU intensive.

VerticalFilter – If turned on will very slightly blend each pair of horizontal lines together. This loses only a small amount of vertical resolution but is probably a good idea as it can somewhat hide remaining deinterlace artifacts and will probably also make your clip compress a bit better. (0 = no filter, 1 = filter)

It is our recommendation that you do not use -1 for TopFirst. Because the AVI file format is unable to store information about field order, AviSynth is unable to detect which field comes first. Instead, try using both 0 and 1. You will be able to tell which is the wrong one by examining individual frames near scene transitions. The results will typically look like strange pixelated artifacts.

We also recommend that you start with a SearchEffort of 5 (which is the default). You can experiment with using a higher search effort value, but know that this uses more CPU time and sometimes actually yields worse results. As for the VerticalFilter, if you are using a very pure source like Hi8 or digital-quality material, you may want to disable this setting (0) to preserve as much detail as possible. Otherwise, we recommend leaving it enabled (1) to help hide any de-interlacing artifacts.

To launch your AviSynth script, you can just open the AVS script like you would an AVI file in VirtualDub. Despite it being a text file, VirtualDub knows to pass the script on to AviSynth and everything should function just as if you opened an AVI file. If you want to mess around with the parameters in your script, just go to the Script Editor (Ctrl-E) and edit the desired variable. When you are done, select Save and Refresh (F5) from the Script Editor window. This will re-save your script and load the new script. You can then step through frame by frame to see how your changes affect the video.

Inverse Telecine (IVTC) with NTSC Video

Working with Telecined Video can be handled in many ways. One way would be to use our Motion Compensation de-interlacing technique to convert the 30fps interlaced video to 30fps progressive video. Things would look reasonably smooth and we would have a perfectly usable video stream. But as we noted before, when converting from 24fps to 30fps, redundant data was created by duplicating fields. So instead of using de-interlacing, we are going to perform Inverse Telecine (IVTC). By having the computer exam the video on a field-by-field basis, the duplicate fields can be detected, removed, and the original frames dynamically reassembled. The end result is a complete recovery of the original 24fps progressive video stream. The major advantage of this process is two-fold:

  1. Since the video has been reverted to progressive video, it will be easier and more effective when we apply cleaning filters. (Cleaning interlaced video can be tricky.)
  2. Because the video is now 24fps (instead of 30fps), more bandwidth can be allocated per frame, thus improving the overall quality of the final compressed video.

Performing Inverse Telecine with AviSynth

To create our Inverse Telecine (IVTC) script, we are going to use an AviSynth plug-in called “Decomb”. Launch VirtualDubMod and open the Script Editor under the Tools menu (Ctrl-E). Insert the following code, tweak the AVISource parameter to match the AVI file you want to work on, and save this script as “script.avs” (the .avs extension is required.)

AVISource(“C:video.avi”)
Telecide(guide=0)
Decimate(cycle=5)

This script is also rather easy to follow.

  • Line 1: Open the AVI file for processing. Open the file “C:video.avi” using the “AVISource” call.

  • Line 2: Use the “Telecide” function to analyze the fields and create a progressive video stream with every 5th frame being a duplicate of the previous frame.

  • Line 3: Use the “Decimate” function to analyze groups of 5 frames at a time and eliminate the duplicate frame.

If you are curious what Telecide(guide=0) and Decimate(cycle=5) do exactly, the HTML documentation for these functions can be found in the same directory that Decomb DLL was installed in. In a nutshell, the “guide=0” parameter for “Telecide” is an auto-detection method for determining what type of telecine is being dealt with (ie. NTSC or PAL). If you know for certain that you are seeing NTSC or PAL telecined video, then you can set “guide” to 1 for NTSC or 2 for PAL to improve results. The “cycle” parameter tells the “Decimate” function to destroy 1 out of every X frames, where X is the number you specified. (X is usually set to 5 for NTSC.) Both Telecide and Decimate have more parameters, but these are the primary ones that are used most frequently.

Decombing PAL/SECAM video

Decombing video for PAL/SECAM can be a bit trickier than for NTSC. Unlike NTSC where 99% of the situations can be divided up into 2 scenarios, PAL/SECAM is based on 25 frames per second (50 fields per second) and have many situations going on. Sometimes these are extremely difficult to identify just by stepping through the video frame by frame. Here is a brief outline of some of the scenarios:

  1. Video converted from 24fps => 25fps by duplicating every 24th frame (24 => 25).
  2. Video converted from 24fps => 25fps by speeding up the video by ~4%. (24 => 25).
  3. Video converted from 24fps => NTSC (30fps) and then to 25fps (24 => 30 => 25).
  4. Video converted from NTSC (30fps) => 25fps (30 => 25).
  5. Video that was natively shot at 25fps.

Deciding which Method to use with PAL/SECAM

To decide which method to use with each scenario, we are going to create a script in AviSynth that will make it easy to determine which is best for us. Launch VirtualDubMod and open the Script Editor under the Tools menu (Ctrl-E). Insert the following code, tweak the AVISource parameter to match the AVI file you want to work on, and save this script as “script.avs” (the .avs extension is required.)

AVISource(“C:video.avi”)
SeparateFields()

Open this script in VirtualDubMod and step through the video frame-by-frame and examine the results for about 10 to 20 frames. If you notice:

  1. Repeating fields, then use: Telecide(post=false)
  2. All Unique fields, then use: TomsMoComp(0,5,1) -or- TomsMoComp(1,5,1) [depending on field order]

A Fancy Alternate Method

As an alternate to the detection method above, we have decided to include a script that shows off the capabilities of AviSynth. This script splits the video into two streams and does processing on both streams and stacks them next to each other so that you can do a side-by-side comparison.

AVISource(“C:video.avi”)
A=Telecide(post=false).Subtitle(“telecide”)
B=TomsMocomp(0,5,0).Subtitle(“tomsmocomp”)
StackHorizontal(A,B)

Open this script in VirtualDubMod and step through the video frame-by-frame and examine the results. One will look better than the other. Once you decide which is better you can alter your current script and reload. For example if you decide that “telecide” works better, change the script so that it looks like this:

AVISource(“C:video.avi”)
A=Telecide(post=false)
return(A)

We deleted the subtitling because we do not need that in our video and we deleted the TomsMoComp line since we are not using it. We then tell AviSynth to return all frames from the “A” clip. For more information about the language syntax and grammar of AviSynth see the ScriptGrammar documentation at AviSynth.org.

Some old time users of AviSynth will notice that these scripts never use the LoadPlugin call. This is because all recent versions of AviSynth utilize auto plug-in loading. If your plug-ins are stored in the “plugins” directory of AviSynth, then you will never have to use the LoadPlugin function.

Hybrid Video Streams

One thing that you might run into is something that some of us refer to as “hybrid” video clips. As far as we are aware, there is no “best way” to deal with the issue, but we just wanted to point out the phenomenon and how to recognize it. In our experience, the most common “hybrid” clip is typically a video stream that contains a mix of both 24 fps progressive and 30 fps interlaced video. Yes, you read correctly: Both 24 fps and 30 fps video. The progressive 24 fps is telecined up to 30 fps so that it is compatible with the interlaced 30 fps stream. But this leaves a problem when attempting to decomb. Do you do IVTC (and destroy perfectly good fields from the 30 fps interlaced stream)? or do you de-interlace (and leave duplicate fields from the 24 fps progressive stream)? Tough to decide. If you ever get this far in video processing, we recommend that you visit the Ars Audio/Visual Club and post a question asking the video veterans what to do. (A lengthy discourse will probably ensue over what you need to do in your particular situation…)

The Advantage of AviSynth

At this point you may be wondering why we are using AviSynth to do our noise filtering when we could just use the VirtualDub filters we learned about in the “basic” section. While it is true that VirtualDub filters are easy to use, here are a few reasons why we think AviSynth is better:

  1. VirtualDub operates in the RGB colorspace. In contrast, our captured video and DVD video work in the YUV colorspaces (YUY2 and YV12). As we mentioned in the first guide, converting back and forth between YUV and RGB can cause deterioration of color accuracy.
  2. RGB colorspace requires more bits. VirtualDub requires that all filter operations take place in the RGB colorspace. Compared to YUY2 which only uses 16 bits per pixel (bpp), RGB uses twice as much at 32 bits per pixel (bpp). More bits means more math. And more math means longer processing times.
  3. Most AviSynth filters are heavily optimized. While it is true that many filters for VirtualDub are also well optimized, there are many that are not. Most filters written for AviSynth have been heavily optimized using assembler code to squeeze the most out of every CPU cycle.
  4. AviSynth has a wider variety of filters available. Nearly every filter written for VirtualDub has since been ported to AviSynth. In addition to all these filters, there are other filters available exclusively to AviSynth. Many of which are much faster and/or more powerful than any similar filter written for VirtualDub.

AviSynth Noise Filters

Like the “basic” section where we construct a filter chain to clean up the analog video signal, we are just going to introduce a few of the more popular filters and explain how they most effectively work together. Many of AviSynth filters we introduce here are much like the ones available for VirtualDub, yet they are more powerful and a bit more advanced. We will be working with the following filters: Levels, Guava Comb, Peach Smoother, Convolution3D, and Chroma Noise Reducer 2.

Filter Filter Description (==> all filters listed here can be downloaded from this link <==)
Levels

(internal)

Levels is an internal AviSynth Filter. It performs gamma correction, as well as brightness and contrast. Because this filter has no GUI like the Levels filter in VirtualDub, it was designed to accept parameters just like the VirtualDub version. Unlike VirtualDub’s Levels which only works in RGB, this filter operates in both RGB and YUY2 colorspaces.

Example: Increase Gamma by 25% (leave input/output ranges untouched)
Levels(0,1.25,255,0,255)

Guava Comb Guava Comb is a “comb filter” (like the one in most “digital” TVs) used to help poor Luma/Chroma separation in broadcast sources. It is very effective at removing video artifacts such as dot-crawl, and to a lesser extent, color crosstalk “rainbows”, and some kinds of shimmering. We will use Guava Comb primarily to minimize dot-crawl. (Click for an example of dot-crawl. Guava Comb only operates in the YUY2 colorspace. Guava Comb only works temporally and thus only eliminates stationary dot-crawl/crosstalk. Guava Comb should be used before any de-interlacing/IVTC filters. Guava Comb can be used on NTSC and PAL video, but not on SECAM. (See link at the left for more details.)

Example: Use default settings w/ NTSC-type video
GuavaComb(mode = “NTSC”)

Peach Smoother Peach Smoother is an adaptive temporal noise reduction filter with a spatial filter that kicks in when the temporal noise filter fails. It is particularly effective at cleaning up TV signals and automatically fine tunes itself to handle the signal quality. It has plenty of parameters to tweak if you so desire. Peach Smoother operates in the YUY2 colorspace and works most effectively with relatively raw video. It is recommended that Peach Smoother come immediately after comb filters (like Guava Comb), but before de-interlacing/IVTC filters. (See link at the left for more details.)

Example: Use default settings w/ Spatial filter disabled
PeachSmoother(DoSpatial = FALSE)

Convolution3D Convolution3D is a spatial smoothing filter like the 2DCleaner filter that we talked about in the “basic” section. But Convolution3D is different in that it has temporal elements as well. So instead of being just two-dimensional, it is called 3D (the third dimension being “time”.) This filter has a myriad of settings, but features a few presets to make your life easier. These presets include: movieHQ, movieLQ, animeHQ, animeLQ, animeBQ, vhsBQ. (See the link at the left and the text file included with the filter for more details.)

Example: Smooth video from a Low Quality Movie (a good choice for TV captures)

Convolution3D(preset = “movieLQ”)

Chroma Noise Reducer 2 (CNR2)

(optional)

Chroma Noise Reducer 2 (CNR2) is a filter that was inspired by the Chroma Noise Reduction (CNR) filter that we used in the “basic” section. The output of CNR2 is nearly identical to the output of the original CNR, yet CNR2 is 3 to 5 times faster. CNR2 operates in the YUY2 colorspace and lacks a GUI. You can use the original CNR filter in VirtualDub and then transfer the values to CNR2. The default parameters for CNR2 are also rather good. (This filter is optional since it has the potential to introduce artifacts into your video. Some would say that this filter is best reserved for VHS conversions.)

Example: Remove Chroma Noise from video using default settings
CNR2()

The Filter Chain

To construct out filter chain script, launch VirtualDubMod and open the Script Editor under the Tools menu (Ctrl-E). Insert the following code, tweak the AVISource parameter to match the AVI file you want to work on, and save this script as “whatever.avs” (the .avs extension is required.)

AVISource(“C:video.avi”)
GuavaComb(mode = “NTSC”)
PeachSmoother()
Telecide(guide=0)
Decimate(cycle=5)
Levels(0,1.2,255,0,255)
Convolution3D(preset = “movieLQ”)

Following the script step-by-step:

  • Line 1: Open the AVI file for processing. Open the file “C:video.avi” using the “AVISource” call.

  • Line 2: Use “GuavaComb” in the NTSC mode with default settings to remove dot-crawl and color crosstalk.

  • Line 3: Use “PeachSmoother” in default mode to remove noise from the video.

  • Line 4 & 5: Perform IVTC.

  • Line 6: Gamma correct the “Levels” with 20% increase. (Leave input and output ranges untouched.)

  • Line 7: Lightly smooth the video using Convolution3D’s “movieLQ” preset to rid the video of any remaining noise and make it more compressible.

As noted above, GuavaComb and PeachSmoother work best on unprocessed video, so they come first in the filter chain. Next, we perform Inverse Telecine to decomb our video. (As we discussed before, you will need to determine on your own whether the video requires Inverse Telecine or De-interlacing. We just decided to use IVTC in this example.) After that, we apply gamma correction. (You will have to use your own judgment on how much correction your video needs, if it needs it at all.) Gamma correction comes before Convolution3D because Levels may sometimes cause subtle banding of colors. Convolution3D helps smooth out the banding and makes the video look more natural again.

Using the Crop() function

In the beginning of this article, we covered Cropping via VirtualDub and its filters. AviSynth has its own way of accomplishing this same tasks through the use of the Crop function. The basic syntax for performing a crop like we showed you in the beginning would look like:

#Crop the top and bottom by 60 pixels; leave sides untouched
Crop(0,60,0,-60)

Typically you would want to insert the Crop function right after the “AVISource” call and immediately before any other filter. The advantage of inserting the Crop function here is that it immediately reduces the amount of data that each filter needs to look at. Thus making your processing times shorter.

See the Crop documentation at AviSynth for more details on the correct syntax and usage.

Further Experimentation

By this point, you should have a good feeling for AviSynth and some of the internal and external filters available. But like any tool that you have just started using, you must continue to use it and experiment with it in order to become more proficient. To get you started, we have a short list of things to try:

  • Replace PeachSmoother and Convolution3D, with Dust (a slower, but much more powerful filter available only to AviSynth 2.0.x)
  • Try the latest version of AviSynth 2.5.x which is faster and has support for more filters/features.
  • Try the original filter chain, but replace Convolution3D with MipSmooth (a filter exclusive to AviSynth 2.5.x)
  • Explore other filters found at AviSynth.org
  • Remember, if you want to use 2.0.x filters in AviSynth 2.5.x, please read this page on LoadOldPlugins.

Intermediary Compression and conclusion

By now, you should have all your decombing and denoising filters in place. All that is left is to kick off the processing job and let VirtualDub do its thing. But before we click the SAVE button, we need to select a compression codec. While you might want to pick a final destination format like DivX or MPEG-2, we recommend that you first save to an intermediary format. You may find that sometimes you will want to save to various destination formats. Since filtering takes a long time to process, it makes sense to save using a lossless format to a temporary AVI file. Even if you are only planning on saving to one final destination format, saving to an intermediary file still saves you time if you are planning on using multi-pass compression like MPEG-2 or DivX. To see what we mean, examine the following diagram:

As you can see in this example, going straight to 2-pass compression (like DivX), requires that we filter the same material twice which takes 12 hours. That is 50% longer than had we filtered right to a lossless intermediary format, like Huffyuv, before doing the 2-pass compression. The trade off is that Huffyuv will consume a lot of hard disk space. If you have enough free hard disk space available, you should definitely filter only once to an intermediary format like Huffyuv. If you are short on space, you can compress to MJPEG @ 19 and still get very good results. One thing to note: the longer your filter chain is, the more worthwhile this technique is. If you find that your filter chain is rather short, then you may want to skip using intermediary compression since it may actually be marginally slower. Although since we have not educated you on encoding yet, you should stick with using this intermediary compression technique for now.

Compressing your video

Select your intermediary compression codec (Huffyuv 2.1.1) from the “Video” => “Compression” menu in VirtualDub. If you are using VirtualDub filters, make sure that “Video” is set to “Full Processing Mode”. If you did all your filtering in AviSynth (and decided not to use any VirtualDub filters), you can select “Fast Recompress” in the “Video” menu to preserve your video in the YUV colorspace and make your compression go a little faster. (Note: you may receive a warning from VirtualDub about this when you save, just acknowledge the warning.) To kick off the processing job, choose “File” => “Save as AVI”, to save your video to a new AVI. VirtualDub should pop-up a small window with statistics about the processing job and will give you an estimate on how long it will take to complete. You may want to adjust the processing priority from “Normal” to “Lower” so that VirtualDub does not hog your CPU. (Your system may become somewhat unresponsive, otherwise…)

With this, you will be set up for the Video Compressing guide, where we will talk about various destination formats such as VideoCD (VCD), SuperVideoCD (SVCD), DVD, DivX, XviD, and more!

N.B. Part 3 has not been written yet. No ETA at this time.

A big thanks goes out to Wotef for making some really sharp suggestions. And kudos to one of Ars Technica’s best and brightest: Richard Berg. Thanks for all the help and all the great insights into AviSynth.

Revision History

Date Version Changes
7/23/2003 1.0 Release
0 Comments

Comments are closed.