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.
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.
Plugins
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 commands 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:
AVISource("filename1.avi","filename2.avi","filenameN.avi")
SegmentedAVISource("filename.avi")
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 (used to bypass the 4GB file limit under the FAT32 file system).
Once you have typed one of these commands into an AVS file (any file name with a ".AVS" extension), you should be able to load the file in VirtualDub to test that it 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 (available at
doom9.org) to load the MPEG2 sequences and use
it to "Save Project." The resulting ".D2V" file is loaded using the
MPEG2Source("filename.d2v") command.
The problem is, DVD2AVI will not relay the Audio, which means you will have to load it manually with the WAVSource("filename.wav") command. 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; in such cases, you can use WinAmp's 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 entering a source in the RGB
color space, you must first convert the format to YUY2. The command is
ConvertToYUY2(). This must only be used if
the source is in RGB, and the command must directly follow one of the AVI loading commands.
It is important to use "ConvertToYUY2()" rather than "ConvertToYUY2" due to a syntax requirement in AVISynth that can cause slowdowns if the "()" symbols are omitted.
Crop & Resize
Then there are two very simple commands to Crop and Resize the image:
Crop(X_Offset,Y_Offset,Width,Height)
BicubicResize(New_Width,New_Height)
For example, if we had a 768x576 source image which we would like to resize to 640x480, but there
are 4 black lines on the left, 8 on the right, 2 at the top, and 3 at the bottom to crop out:
Crop(4,2,756,571)
BicubicResize(640,480)
The idea behind Cropping is that 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.
| NEXT |