Filtering VHS recordings in Virtualdub

Digital post-processing of grabbed VHS video in Virtualdub.
The post-processing is needed to get a good picture,
and it also enables effective compression.

Typical filter chain and standard filters
Filter chain for cartoons and anime
Filter chain for faded old films

Primary note

In a first step we have to edit and correct audio. Video processing should be the second step.
A delay between sound and image must be corrected before you cut the video.
See Sync Audio to Video

Typical filter stack in Virtualdub

Let's assume that you already have digitized your VHS video with a video grabber.

Now it comes to editing and correction in Virtualdub with this typical filter cascade.

Virtualdub filter chain for VHS
Figure: Typical filter cascade for processing grabbed VHS videos

Deinterlace / removing incorrect deinterlacing

If your grabber just mixes two fields without deinterlacing, you must first remove the wrong deinterlacing before you process, edit or scale the image. You can not step back to deinterlacing when you already have applied other video filters!

before and after deinterlacing.
Figure: A frame before and after deinterlacing.

Which deinterlacer is to use?
To decide which deinterlacer fits best for your task you have to deinterlace some some critical seconds of the movieo by using different deinterlacings, and watch the results. Keep an eye on:

  1. Are all of the interlacing artefacts washed away? How does the picture look like?
  2. Are fine details obtained? Look at patterns and folds in clothing or details in faces.
  3. Does noise increase? Does the image look stable?

If in doubt, you can help yourself with some screenshots to compare the results of different interlacers. You can scroll through the screenshots using Irfanview.

My Favourites for deinterlacing (2010):

1. Deinterlace (area based)
2. ASVZZZ deinterlace: removes comb artifacts very well, but losing more details

Deinterlace - area based
is my favorite, good, keeps details of the picture
does not double frame rate
is also suitable if only parts of the image have interlace strips However sometimes is choses chroma information from the wrong subframe (see Screenshot)

Deinterlace area based adjustments
Settings of Deinterlace – area based

ASVZZZ deinterlace
removes comb artifacts very well
but losing more details

More deinterlacers for VirtualDub
http://www.guthspot.se/video/#fieldshift
Smoth shift field generates interpolated intermediate images from odd and even frames
doubles frame rate

Deinterlace 'Muksun'
I do not have experience with it

QS deinterlace
emerged from Donald Graft's Smart Deinterlace, but 10 ... 15% faster
no experience with it

MSU Field shift fixer
works only with AVIsynth
tried whether the odd lines to fit better into predecessor or successor frame.

MSU Deinterlacer
commercial product, costs several thousand dollars

Correct chroma delay (chroma shift)

correction of VHS chroma delay

Poor VHS recorders delay chroma color information compared to the luminance signal. Often, the color (chroma) image is shifted a few pixels to the right. In addition, Chroma information can be shifted one or more lines downwards. After repeated copying this can result in dramatic offsets, because this shift summs up every time the video is copied.

You need to correct chroma offset before cutting the edges of the video.

Flaxen VHS filter for chroma delay
Figure: Good tool to correct Chroma delay: Flaxen VHS. The figure shows typical settings for a VHS video that has been copied two times.

FXVHS filter also can reduce temporal noise und it stabilizes color of each pixel over time. Nonetheless this stabilizer section works extremely slow. I do not use it.
The NR Filter in FXVHS works to heavy with standard settings.

I only use the chroma delay section of the Flaxen VHS filter.

ChromaShift (Simon Walters)
While Flaxens's operates in RGB colourspace and shifts I and Q relative to Y this filter works in YUV and shifts U and V relative to Y. So sometimes it could give a slightly different effect and no colourspace conversion.
current version: 2.7 (2003)

Remove Noise

VHS video signals are always a bit noisy, even if they were recorded from DVD.
The noise can be removed by averaging.
The final file size of your compressed video highly depends from how good the noise has beeen removed bevore. Modern compression algorithms for video expect that large parts of the image are preserved from one frame to the next. This is not the case in a video where dynamic noise superimposes the frames. Then compression needs a much higher bit rate.
A well denoised video requires with the same quality setting only 1 / 3 of the final file size (Xvid or X264)!

Typical denoising methods:
a) averaging the image area
loses detail, makes the image slightly blurry
well suited to reduce color noise, since VHS color has much lower resolution than luma

b) averaging over time
Each pixel is avaraged with the same pixels from preceding or succeeding frames.
very effective especially in scenes with little changes or slow movings.
Most details will remain so long as the picture is stable and there is no jitter.
This filter is my favorite.

c) MSU Denoise
This filter has both strategies, but in my material it provided no better results than Temporal clean.

Proper values for Temporal clean:
4: In most cases to small
5: Barely acceptable, is recommended for noisy video sources.
7: Moving parts draw about 0.5 seconds long streaks.

I have cleaned most of my VHS tapes with a temporal smoothing factor of 5 (mostly documentaries).

Super temporary cleaner (Stolyarevskiy Sergey)
It has an option to show areas that contain noise.
500 weak effect
2000 (maximum) With this setting this filter reduces not as much noise than Temporal clean with setting 5, which leads to a larger video file after encoding. I don't use it.

Tip: If you video is very noisy you'd try multiple filters, rather than increasing the value of temporal clean. However, you should first try noise filters with a short test scenet. Heavy filtering can destroy details.
When a video is very noisy I reduce the temporal smoother value to 4. Otherwise the picture looks artificial stabilized with sudden changes in certain pixels. A reduced but constant dynmaic noise does draw so much attention.

Remove overscan, cut picture

Digital PAL (stored as a file on DVD) has a resolution of 576 lines and 720 pixels witdh, which are scaled to a 768 pixels wide picture when shown at a monitor.
Analog PAL (TV signal) uses only 576 lines of the 525 lines for the image.

A overscan was necessary for tube televisions to ensure that flickering image borders were not visible on the screen. About 3% of the image were cut off at each border. During production of videos and TV broadcasts this is beard in mind so that to analog videos an additional image area is added that can be removed later.
In most real TV sets only 550 of the 576 lines are visible.

Overscan at a TV
Overscan test pattern from www.homecinema-fr.com display at my tube TV. Note that there are 5% missing at each border.

Even the standard for DVDs considers that only 702 of the 720 pixels are shown on the TV.
(www.digitalfaq.com/guides/video/capture-understand-sources.htm#overscan

At VHS recordings the edges of the image are shown very fluttering. Due to overscan you wan't notice this on a TV. But in the grabbed video edges are visible, because the full video pixel range is captured by the grabber.
You have to crop the video manually to cut off these nasty borders. Otherwise they will cost bandwidth when compressing the video. And they do not look nice. As said before, during production of the video it has been assumed that about 3% of all sides of the picture will not been displayed.

To maintain the aspect ratio of the video, you should cut off the same percentage away with reference to width and height of the target format.

The following table shows for different percentages (based on an image format of 768 × 576), how many pixels must be removed per side.

%             768px    720px   576px
CCIR 601 1.33%  9,6      9
1%              7,7      7,2     5,8
2%             15,4     14,4    11,5
3%             23,0     21,6    17,3
4%             30,7     28,8    23,0
5%             38,4     36,0    28,8

Table: Number of pixels that are cut off by overscan for different percentages.

For example:
Your grabbed video has fluttering areas at the left and right side. Above are about 4 pixels black, and the lowest part of the picture flutters permanently due to video head switching distortions.
You want to crop the image without distorting it.
From the table you choose a 2% trimming. Since the grabber puts out 720 pixels in width, you cut 29 pixels summed up from the left + right side (2 × 14.4). Above and below you cut off 23 pixels (2 × 11.5).
Only if you can accept a slight image distortion, you may use fewer pixels and cut off only the unwanted areas.

Resize

Now the image is scaled to the target resolution.

These are the important variables

Video Type VHS Analog TV S-VHS, Hi8 DVD Betacam
Bandwitdh (MHz) 3 ... 5 5,5 7,4 up to HD-TV!
Width (Pixel) 320 440 534 720 (768) 670...1080
Visible optical line resolution 240 330 400 576 500-800

Table: Effective visual resolution of video signals (www.edv-tipp.de/2000/08/20/aufloesung/)

As you see in this table the visual resolution of VHS is much smaller than the number of pixels that your video grabber captures. Data refer to square pixels.
High-grade VHS recorders (starting from about 500 €) reach a better resolution almost as good as analog TV, but still smaller than 720 × 576 pixels. However, it is important that you first grab with 576 lines, so you can remove the interlacing later. This is only possible if no lines are mixed.

When you store the video to a file you only need a resolution which is big enoug to reproduce your visible optical resolution.
In the table below I have shown some reasonable resolutions for 4:3 video.

  %  %File         Comment
 50      384 x 288 
 54      416 x 312 no multiple of 16!
 58      448 x 336 is enough for VHS, low blurr
 62  40  480 x 360 Analog TV, high-quality VHS, 40% file size, usually sufficient
 66  56  512 x 384 minimum more detail than 336p, sharp enough for analog TV and VHS
 75      576 x 432 no multiple of 16!
!83  75  640 x 480 full details of VHS copies, native NTSC resolution
 91      704 x 528 
100 100  768 x 576 minimum more details than 480p, for analog grabbing from DVD (S-Video)

Destination image formats for 4:3 VHS material (with a pixel aspect ratio of 1:1)

The following table shows values that can be used for 16:9 video. Since width and number of lines should always be multiples of 16, in some formats a small deformation from the ideal 16:9 aspect ratio will result.

%  % file   W x H    Deformation Comment
256 x 144 0 368 x 208 0.5% 384 x 216 0 400 x 224 0.5% 480 x 272 0,7% 40% file size, usually sufficient 512 x 288 0 624 x 352 0.3% 640 x 360 0 no multiple of 16! 656 x 368 0.3% 768 x 432 0 more pixels in width, less lines than DVD, enough for analog TV 100 1024 x 576 0 more pixels in width, full number of lines

Image formats for 16:9 VHS material (with a pixel aspect ratio of 1:1)

On a DVD a 16:9 video is stored in an anamorp compressed standard 4:3 resolution of 720 × 576.
During playback, this image is stretched laterally to 1024×576. That is, the actual optical resolution is only 720 pixels. For 16:9 video, it may be reasonable to switch to non-square pixels, which is different from a 1:1 pixel aspect ratio so that the resulting video file gets smaller. It has no sense to save pixels, which do not contribute to the optical resolution.

If you are not using 1:1 pixels, you have to make sure that allways the correct pixel aspect ratio is preserved when the video is recoded.

Helpfull pixel aspect calculator: aspect.fre3.com/

Resize configuration for low quality VHS
Resize settings for a poorly resolved VHS Video (4:3)

These are my default settings for resizing old, fuzzy VHS recordings (Picture above).

Adjust black levels (Levels)

Some grabbers capture parts outside of the video image that are blacker than black. This leads to an image which is too light and has bad contrast. By using the filter levels you can correct the black level of the image.

Levels adjust black value
Fig: Virtualdub filter "Levels"

Adjusting correct levels:
Activate preview. Pick some dark movie scenes to get a meaningful histogram. Click on "snapshot". Then move the left slider in the histogram to chose a new black value without cutting off any part of the hill of black values on the left (see figure).
Now you can look for a very bright scene with many whites tones in it. Move the white level so far to the left, that all of the white values are still detected in the image.
You can see well in the preview, if you reduce white level to much. Then bright areas drown in white color.
In general, you do not need to reduce the white level. Also the gamma setting should remain untouched.

[×] Operate in luma instead of RGB ensures that darkened areas do not get an unnatural color saturation.

Notice: If you have scaled gray levels to the range 0 … 255, you can get problems when encoding MJPEG. Initially MJPEG has been used to store gray levels only in the range 16 … 235 (TV levels). The PicVideo codec which we use in Virtualdub is able to proper process PC levels. But Avidemux (and other software) does not recognize PC levels in MJPEG video. As a result gray levels below 16 and above 235 are thrown away and the range of 16 … 235 than is scaled to 0 … 255. The resulting image looks harsh.

Enhance colors (optional)

This is only necessary, if the signal from the VHS recording had bad colors (for example, if the movie was copied from another video cassette).

a) increase color saturation with the filter HSV Adjust
This also increases the color noise. Sometimes useful, sometimes not better.
Adjust carefull. The maximum useful value is reached when the colors in the preview do not increase further.

Improve color saturation
Increase color saturation

b) MSU Smart Colors
This plugin creates a vivid perception of color, but it changes dramatically the color composition of the image.
It must be applied very carefully.
Adust the slider Correct Colors only to the first stage. Disable "Auto levels", otherwise the colors will get dramatically intense, especially in dark scenes. Then the basic color of a scene is lost. In case of wrong white balance this may be sometimes desirable.
(Be careful, the plugin also darkens overexposed areas.)

MSU color enhance
MSU Smart Colors

Sharpen (optional)

In rare cases, the picture qulaity will profit froam a slight sharpening. But the visual impression will become quite frustrating when the edges are emphasized too much.
In general, as well as in the photo-editing: The effect should be hardly noticeable and not sting the eye.

Important Note
The proper order of the filters also depends on the source material. Generally, it is usually wise to sharpen after a Temporal noise filtering which has averaged the noise out, but has preserved image details.

With VHS videos with a very blurry picture, the temporal noise filter smoothes too much, because it finds no details in the image. This results in stepwise color changes in faces (cartoon effect). If the resulting picture is sharpened, this effect even gets stronger. (!)
In this case it is better, gently raising sharpness before the temporal filter, so that it gets more details (MSU sharpen: small overall). After that apply temporal smoothing with a factor of 4 ... 5.

a) MSU Smart Sharpen
This filter applies a band-pass filtering, which emphasizes details of the picture, and - to a smaller amount - also amplifies fine-grained noise. The coarse details are more enhanced than the fine-grained noise. The visual result looks quite nice. Other sharpen filters much more aggressivly raise noise. In addition, an unsharp mask can be applied (Borders). This should never be applied to such an extent that the edges in the image become to hard.
Therefore I only use the normal sharpness filter (small overallor overall).

b) Sharpen [internal]
very fast, sharpness can be adjusted, emphasizes more the higher frequency components than MSU Smart Sharpen.

Flaxen Warp sharpen
only enhances edges analogical to unsharp masking. Use with care.

PCVideo Image Processor Filter - smart sharpen
mphasizes more the higher frequency components than MSU Smart Sharpen.

Msharpen (Donald Graft)
moves pixels to the borders, so noise will be not enhanced. Mostly for anime.

Xsharpen (Donald Graft)
moves pixels to the borders, so noise will be not enhanced, but you get rought edged borders.

DSharp 1.0 (Alexander Zavalishin)
Deconvolution filter for refocussing blurry footage. Unfortunately no hep files are given for proper parameter adjustment.

More filters (optional)

VHSrest Restore line sync
With bad line syncronisation lines have an different horicontal offset. Vertical lines get rippled.
This filter tries to find and correct vertical lines in the frame.
Attention! When the signal is very noisy the resulting output can become much more disturbed than the input has been.

Smart Smoother High Quality, Smart smoother IQ (remove chroma ringing, rainbow artefacts)
In some recordings black and white patterns generate rainbow colors.
These filters use different algorithms to smoothen our these artefacts.

Chroma Smoother (internal)
Has presets for typical sources of chroma ringing, dependend from the codec that has produced them.

Filter chain for Cartoon

cartoon correction in virtual dub

This is my Filter chain for VHS cartoons. The results look very good (see screenshot). This filter chain works extremely slow, mostly because of the MSU Cartoon restore filter (multipass, medium strength). With this setup the framerate of my system slowed down from 5.5 fps to 1 fps only.

If plain-coloured areas still have noise, it may help to insert at the end of the filter chain a second temporal smoother (4) and a second MSU Cartoon Restore filter.

Virtualdub filter chain for VHS cartoons
Figgure: My filter chain for grabbed VHS cartoons

Filter chain for faded old films

faded film and color correction in virtual dub

Cause of color fading

The individual layers of old films fade with varying degrees and at different rates. First loses the cyan / blue layer its color, then the yellow / green layer. The last fading layer is magenta / red. This leads to a loss of whole ranges of color.
In addition, even image contrast bleaches out and gamma shifts. Because the overall contrast has been stretched to full range (black = 0 and white = 255), the image often looks too hard. The movies then look as if they were copied several times by a photo copy machine.

Correct colors

This thread recommends the following approach:

1. First adjust gradation of gray values.
Old movies often have very dark and harsh shadows and the lights are faded and pale.
Therefore as a first step, an S-shaped gradation curve should be applied, which softens contrasts of the shadows and pulls more gray values into the lights.
Assumption is that the levels are already set to the full range of 0 .. 255 (Level Filter).
Now you have to avtivate temporarily a grayscale filter, because you get a better impression of the brightness.
Insert Gradiation filter: apply a soft S-curve for brightness (value), which compresses the histogram in the bright region, but stretches it in the very dark area

Visual inspection:
How look dark, medium and light tones?
How are skin tones?
Numerical control: Clouds are white, grass has about 67% gray value, skin is at 160...180

This small freeware tool CSamp helps to measure pixel color values.

Gradation value setting for old film on VHS Gradation saturation setting for old film on VHS
Figgure: Gradation settings of value and saturation for faded old film

With this basic correction, the image usually improves significantly.

2. Now followes color balance
What colors are over-represented in the film? Which are missing?

The video can originate from a faded copy of movie or it come from a faded negative master of the movie. Therefore, corrections in RGB or CMYK area may be appropriate. You can conclude from the remaining colors that still are present which channels have to be processed.

Remaining colors of faded old film
Figgure: Remaining colors of faded film and their correction.

For a movie that contains only red, purple and blue, the green layer is bleached. Probably in the blue layer the bright blue colors also are faded, but dark blue has remained. As a compensation the green portion has to be increased, but probably also the bright blue tones have to be enhanced.
For a movie that contains only red, orange, yellow and green, the blue layer is bleached. Probably in the green layer the bright colors also are faded, but dark green has remained. As a compensation the blue portion has to be increased, but probably also the bright green tones have to be enhanced.

MSU smart colors
This filter automatically achieves very nice results, but in scenes with little contrast (credits) it creates fantasy colors that look inappropriate. Therefore it should be used for certain scenes only, but never globally for the whole movie. (!)

More coherent results are obtained with manual adjustment of colors.

a) ColorMill
easy to use
allows to gain or attenuate each color channel separately for low, mid and light tones.

b) CMYK Film Color Correction
For films, which consisted of CMYK layers

c)RGB-EQ by Eugene Khoroshavin
This is not quite as intuitive as Color Mill, but much more powerful.
In addition to gamma settings (also for each individual color channel), luma, saturation and color channels (RGB and YMK) this tool also offers an exceptional option to sharpen or smooth pixels, depending on their brightness.

You start with the global gamma adjustment for film, then possibly you have to change color saturation and then it goes into the individual color channels in order to enhace or weak certain intensity ranges of that color. If the 3 controls for dark, middle and hights affect the color balance to global, RGB EQ can show up to a total of 17 sliders in each channel which can control small areas of brightness of that color.
As a control you should observe the color of gray areas (walls). They shall not show any brightness-dependent color tints.

When the colors look fine, you can sharpen or blurr specific ranges of brightness.
Often it is useful to soften very dark and very bright areas, as they usually look hard and jagged. In dark gray ranges you can sharpen the image, because there have been preserved most of the image details.
With this settings details in the image are enhanced, without increasing noise.

RGB-EQ sharpness setting for old film on VHS
Figgure: RGB-EQ sharpness setting for old film on VHS

Scaling down (Resize:Lanczos3) of the image should be applied after this sharpening, so that interpolation characteristics of the resizing are not emphasized.
If a film is very blurred, skin tones in faces sometimes look jagged after the temporal filtering. In this case it is useful to slightly sharpen the image before applying the Temporal Smoother (MSU smart sharpen: small overall). So the noise filter will find more details.

Virtualdub filter chain for faded old film from VHS
Figgure: A Virtualdub filter chain for faded old film from VHS

Download filter chain (if there are any version conflicts with your plugin versions, you can customize this file in a text editor).

screenshots of a film before and after the color improvement

Remark: An expensive tool for professional color processing is Color Finesse.

Render the movie again

If all filters are set, you can render the movie again. In most cases I you will need also to adjust the audio track of the video. The final rendering of the video can need some hours. Thats why you can store the video in an intermediate data format. For this I use the PICVideo codec with quality = 19 setting. If you reduce your picture to 384p, the generated file needs about half the size of your original video (about 4.5 GB per hour).

Warning:I you have stretched gray levels to the range 0...255 and you use the PicVideo codec, you must decode the resulting video also with the PicVideo codec (using Virtualdub) when doing the final encoding. Or you have to use another codec.

There are currently big flaws in the implementation of MJPEG decoders in many software. This goes back to how the orgininal Microsoft codec handeled luminance levels. Unfortunately there are two different definitions of luminance levels used in video. In analog video grey levels are used in a range from 16...234 (tv levels). Digital video uses the full range of 0...255 (pc levels). When displaying a (captured) analog video on a digital screen the values should be stretched from 16...234 to 0...255 to get a good image contrast.
The problem is that some of the MJPEG decoders do this scaling each time a video file is opened, even if the values in the file are already in the pc levels range. Then a lot of details in the dark and light areas of the image get lost. If you store such a file with new encoding, the details get lost forever.
However Virtualdub with the PicVideo codec processes the video correct.

MJPEG grey pattern test clips with pc levels (0-255) and tv levels (16-234).

With the option "Encode normalized YUV" the PicVideo v.3 MJPEG Encoder puts an APP1 marker in each frame telling the PICvideo Decoder that for this frame any automatic color space conversion is forbidden.
Other MJPEG decoders automaticly stretch tv levels to pc levels without asking.

Final encoding of video and audio I do later.

If you had an delay between video and audio, and you have corrected the audio track, you must instruct Virtualdub to use this corrected track instead of the audio track that is in stored in movie file:

Virtualdub > Audio > Audio from other file... : Then select the corrected audio track you have stored.

Before saving, you should test the result. Select different positions of your movie and check for whether the corrected audio track is in sync with the running video. Is everything okay, you can re-render the video.

Virtualdub > File > Save as AVI...

What happens next

The final endcoding is done with Virtualdub or Avidemux. Some times it is better to put the final video in an MKV container than placing it in an AVI container. In MKV you can define chapter markers.
With the X.264 codec you get a good compression. Some stand alone DivX DVD players requiere using the Xvid codec.

I use the following settings in Avidemux to encode captured VHS videos:
Video:
Codec: X.264 with a quantizer of Q = 22 or
select Xvid for highly disturbed videos with Q = 4 and MPEG quantization matrix

Filter: Mplay hqdn3d noise filter with a setting of: 0-2-6

Audio:
MP3, 192 kBits or less, 44,1 kHz

Container
AVI or MKV

Detailed description of final rendering of VHS recordings.

Links

Virtual dub filters index  – List of virtualdub filters with short descriptions and downloads, filters are also suitablepassend for Video Enhancer
Doom9.net: Postprocessing video using VirtualDub – mainly about correcting various chroma artefacts
Vdub Filters by Donald Graft (German) –
Hawk's Captureanleitung (German) – Guide for grabbing and filtering VHS video
Free Test patterns DVD (in French, as an ISO file)

Flattr this I appreciate this site.

[Counter]