HomeZoom Player › Guides

Video Capture 103 - Inverse Telecine with AVISynth

If you have no idea what IVTC is, make sure to read the relevant information in the previous IVTC article.

AVISynth Introduction:
Unlike VirtualDub and most video editors, AVISynth is a script based editor. It's not as intuitive, but it allows more dynamic video processing and additional flexibility.

AVISynth works by simulating AVI files. Your script files can be loaded by most programs that use AVI as an input format (not all programs though).

Color Space:
Most people understand color space as RGB (Red Green Blue). However, TV Broadcast and Video Capture work in the YUV color space. That's because YUV takes less data to represent a similar RGB image. As much as half the data. And since your capture card and all MPEG (and most AVI) formats use YUV in their encoding, converting the color space to RGB just slows down the encoding process. This is one of the downsides of using VirtualDub's filters as they required an RGB input.

AVISynth by default works in YUV (YUY2 to be exact, a subset of YUV). This makes AVISynth faster at image processing compared to VirtualDub. This also means that whenever you capture video, you must capture to a YUV format (preferably YUY2).

Basic AVISynth Commands:
Since AVISynth is script based (a bit similar to a programming language), I'll go over the basic syntax so you can understand how to work it. For the full command listing and the latest version of AVISynth head over to Videotools.net.

LoadPlugin("x:\path\filename.dll"). The "LoadPlugin" commands should always be the first commands in the script. These commands load additional capabilities into the basic AVISynth package.

AVI Sources:
The first two command deal with the loading of Video Content. In theory, you would want your sources to be either MJPEG or HuffYUV AVI files (best quality).

There are two commands to load an AVI file:

The difference is that "AVISource" accepts specific file names, one or more separated by a comma. "SegmentedAVISource" uses the specified file name and instead looks for segmented file names that contain the specified name as a base. In the example given above, it would actually look for "filename.00.avi", "filename.01.avi", etc... This is useful since a lot of capture programs use this syntax when capturing segmented AVI files (which is used to bypass the 4gb file limit under the FAT32 file system).

Once you typed one of these commands into an AVS file (any file name with ".AVS" extension, use any text editor to create), you should be able to load the file in VirtualDub (to test that the file loads correctly).

MPEG2 Sources:
Loading MPEG2 video sources is tricky. You must first obtain the "mpeg2dec.dll" plugin and add the LoadPlugin("mpeg2dec.dll") command to the beginning of the script. Next you need to use DVD2AVI (which can be obtained at doom9.org) to load the MPEG2 sequences and use it to "Save Project" and the resulting ".D2V" file is loaded using the MPEG2Source("filename.d2v") command.

The problem is, DVD2AVI will not relay the Audio, which would mean you will have to load it manually with the WAVSource("filename.wav") command and make sure that the Audio is in fact in PCM (uncompressed) Wave format first. With some MPEG2 capture cards, DVD2AVI will export an MP2 Audio file when saving a project, in such cases you can use WinAmps' File Writer output plugin to convert this into a WAV file.

Color Space Conversion:
Since our filters always work in the YUY2 color space. If you are trying to enter a source which is in the RGB color space, you must first convert the color format to YUY2. The Command is ConvertToYUY2(). You must only use it if the source is in RGB (most sources aren't), and the command must directly follow one of the AVI loading commands.

It is important to use "ConvertToYUY2()" rather than "ConvertToYUY2" due to a problem with AVISynth which can cause slowdowns if the "()" symbols aren't included in all commands.

Crop & Resize:
Then there are two very simple commands to Crop and Resize the image:

For example, if we had a 768x576 source image, which we would like to resize to 640x480. However, there are 4 black lines on the left and 8 black lines on the right, 2 black lines at the top, 3 black lines at the bottom which we would like to crop out before we resize. So what we would do is:

The idea behind Cropping is, you set how many pixels to cut on the left and top sides, and then you set the new width and height so that the bottom and right sides also get cropped.