-->
Save your seat for Streaming Media NYC this May. Register Now!

Guide to Great Web Video: Preprocessing Video

Size Matters, and so does how you get there

Along with reducing the frame rate, resizing video is one of the first ways we reduce the bit rate. An image that’s 320x240 is already ¼ the bit rate of the original full screen video. For modem rates, frame sizes are reduced even further. Filters are applied to the source image to achieve these reductions, and in turn they remove details that just won’t be seen in the smaller images. VirtualDub has several built-in filters for resizing, which we experimented with to determine their usefulness in various encoding tests.

First the easy part. The mathematics behind resizing works best if the dimensions are reduced by small integer factors. So, 640x480 to 320x240 or 320x240 to 160x120 works fine. With the factors the same in both horizontal and vertical dimensions the aspect ratio of the pixels and the frames are maintained as well. VirtualDub has a basic 2:1 filter and a high quality 2:1 filter built in for just this purpose. The manual recommends the former for certain types of computer generated content, but we didn’t come across any glaring differences when resizing our source video.

When resizing to frame sizes beyond 2:1, or to more complicated ratios, you need to apply a more sophisticated filter, using the general purpose Resize filter in VirtualDub. In the configuration box shown in Figure 5, you must enter the new frame dimensions and then chose a mathematical formula for the filter from the pull-down options shown. You will notice most of the effects in the model’s hair and facial features. Below is a description of the different methods and when to use them for best results:

Figure 5

  • Nearest neighbor – drops pixels, causing aliasing most noticeable as jagged diagonals. Not recommended for any type of quality results.
  • Bilinear – Uses a linear average of pixels in a 2x2 area (kernel) around the pixel of interest. Equivalent to the 2:1 frame reduction when resizing 320x240 to 160x120 in our tests.
  • Precise bilinear – Uses a larger area of interest to approximate the output pixel and therefore achieves sharper images, with less jagged edges when resizing to smaller frames.
  • Bicubic – Uses a quadratic average (curved rather than linear) in a 4x4 area around the pixel of interest. Offers higher precision over bilinear, especially when trying to go beyond 2:1 reduction.
  • Precise bicubic – Uses a larger area of interest to approximate the output pixel and therefore achieves sharper images, with less jagged edges. Best approach, and the one used by Photoshop and Cleaner 5. The 0.6, 0.75, and 1.0 parameters affect the curvature of the equation used to calculate the output pixel, but we found had no bearing on our results.

    Tip: The resize filter has a Show Preview option, whereby you can scroll through the video clip to see the effects of the filter on different types of details.

    With the power of using VirtualDub comes responsibility. It’s so flexible and open-ended that you do need to know what your doing, or you’ll get yourself into trouble. For example, a novice might consider resizing from 720x480 to 180x120 by applying the 2:1 Frame Reduction filter twice. Easy to do in VirtualDub, but not the best way to achieve high quality results.

    If you like what you see so far in VirtualDub, we recommend you download the Smart Resize filter from Donald Graft (http://sauron.mordor.net/dgraft/index.html). This adds functionality to the original resize filter using the Size calculator. This allows you to maintain aspect ratios, specify your new size as a percentage and keep your dimensions to multiples of some integer value automatically. We found this calculator useful when resizing our sources for use with On2’s VP4 codec, which requires frame dimensions that are multiples of 16. There is an excellent help file available with the filter, which explains all the nuances of how it arrives at a frame size given your parameter choices.

    Tip: Keep the aspect ratio of DV pixels correct using cropping

    One of the requirements in our testing was to create encodes that were 320x240 in order to maintain a completely level playing field for codec comparisons. Our DV source video, captured at 720x480, needed to be cropped prior to resizing, otherwise the image is distorted. If the resize is set to 2:1, you end up with a 360x240 image, with no distortion. If you simply ask the resize filter to create a 320x240 frames from the original, the pixels are distorted horizontally because 320 is not ½ of 720. Using the cropping tool inVirtualDub, you can remove 40 pixels from each side of the frame to get a 640x480 image that can then be scaled by 2:1 to 320x240.

    More useful applications of Cropping

    Cropping removes individual lines from the top and bottom of your video frames, as well as rows of pixels from the sides. Sometimes capture devices don’t frame the video properly, which results in the capture of the vertical or horizontal blanking that exists on standard television (or taped) signals. The transition from these black lines to the video image is unnecessary detail that you don’t want to feed to the codec, and so we crop.

    If you are working with video that has been shot as widescreen and then prepared for television, you might also see black bars on the top and bottom of the frames, known as letterboxing. This is a method of displaying the widescreen images (usually with an aspect ratio of 5:3) on standard television screens that have an aspect ratio of 4:3. For display on computer monitors, at less than full screen, you can crop the black bars and use the 5:3 frame since you are not restricted by frame size in most codecs.

    Most codecs do require frame sizes that are multiples of 4, and sometimes 16 (such as MPEG-4, and On2’s VP3 and VP4 codecs). Bear this in mind when applying cropping, taking off pixels or lines in multiples of 4 as well. If you need to use specific frame sizes, for instance you have a player application built for 320x240 video, then you will have to stretch the video frame back out after cropping. You’ll need the Smart Resize filter mentioned earlier to do this properly in VirtualDub.

    Garbage In = (Garbage Out)2

    Clean video is a must for encoding to low bit rates, because noise is just extra detail that chews up precious bits. It’s best to shoot with good lighting and equipment, and capture first generation masters, but sometimes the process is less than ideal. Most encoding applications, including RealProducer Plus and Windows Media Encoder 7, have noise reduction filters built-in. Software noise reduction can tend to soften images more so than broadcast quality hardware devices, but at a fraction of the cost. In addition, the blurring affect can lessen the task of the codec when allocating bits to highly detailed images, so it can be advantageous to apply at least a mild noise reduction to your video prior to encoding.

    When codecs were less sophisticated, compressionists often applied a general blurring algorithm to their video, in order to smooth out high details so the codec didn’t have to assign as many bits to them. Today’s codecs can code details quite well (see results of latest codec shootout), so blurring is not a recommended technique unless warranted by your source material. Our tkhd.avi is noisy, but even applying a mild general blur to it in VirtualDub resulted in too much lost detail, especially in the text. Discreet’s CleanerPro application has an adaptive algorithm that won’t blur your vital content.

    Page 3: Color Corrections >>

  • Streaming Covers
    Free
    for qualified subscribers
    Subscribe Now Current Issue Past Issues