Video Capture 102 - IVTC
Part 3 - TMPGEnc:
TMPGEnc while being an MPEG encoder at base, also has a very good IVTC code and can save it's output to both MPEG1/2 and to AVI (and thus DivX v3 or v4). It also supports batch jobs which makes it a very useful tool for the task at hand.
Starting a new project:
First thing you do after loading TMPGEnc is to reset the current project settings. Go to "File > New Project" in order to do just that (or press Ctrl+N).
Opening the Frame Served file:
Click the "Browse" button next to the video source and pick the ".VDR" file you saved in the VirtualDub frame server.
Selecting the correct field order:
Press the "Settings" button and go to the "Advanced" tab. Under the "Field order" setting, pick "Top field first (field A)". Highlight the "DeInterlace" option in the list and double click it to open the DeInterlace dialog. Select the "Even-Odd field (field)" Method. Left-Click on the video area and then using the keyboard arrows move to the right to frame-advance the video. If the motion is smooth, then the field order is correct, if it's all jumpy then exit the DeInterlace dialog, switch the Field order to "Bottom field first (field B)", re-enter the DeInterlace dialog and check that now the movement is smooth. When the correct field order is selected, make sure that the DeInterlace option is checked OFF! We only use it to check the field order, it must not be enabled for the final encoding.
Setting the IVTC filter:
Check the "Inverse Telecine" box, highlight the line and double click it to open the IVTC dialog. Once open, press the "Auto-Setting" button, select "24fps (flicker priority)", set the DeInterlace to "Automatic", press the "Enable when encoding" button and finally press the "OK" button to close the IVTC dialog.
Clipping unused image area:
Enable the "Clip frame" filter. Check the box and open the dialog by double clicking the line. Seek the timeline to a frame which is bright enough to see the edges of the video. Clip all the unused area surrounding the video, including the widescreen black bars if this is a widescreen video.
Setting the video resolution and Frame Rate:
Select the "Video" tab, set the resolution and the frame rate. If you are encoding a widescreen video, you may be required to do a bit of math to figure out the actual resolution required to maintain the correct aspect ratio.
Encoding the video, The First Pass:
Now, If you want to encode this to VCD or SVCD, that's up to you to set the various MPEG settings. In this tutorial, I will explain how to do fully Automated 2-Pass DivX v4 encoding. Press "OK" to close the MPEG setting dialog we used for configuring the filters. In the TMPGEnc menu select "File > Add current project to batch list > AVI File". A batch encode dialog should appear, select an AVI file name. This is NOT the name you want for the final encode, this is just a temporary AVI name you want for the first DivX v4 pass (I recommend something along the line of "firstpass.avi") Once the 2-Pass encode is complete you should be able to erase this file. If you are using DivX v3 or want to make only a 1-Pass DivX v4 encode, then select the final AVI name.
Now, next to the "Video" line in this dialog, on the right, there should be a button that will allow you to select the Video codec, it's possible that this button might be partially obscured so you only see it's edge (a bug in TMPGEnc). Press it, and select the DivX v4 codec. Press the "Settings" button to bring up the DivX v4 property dialog. Set the Variable bitrate mode to "2-pass, first pass" (if doing a 2-Pass encode, otherwise select the "1-Pass" setting). Set the Performance/quality to "Slowest", press on the "select" button on the lower right to select a log file for the 2-Pass statistics, I suggest using the same name you would use for the final AVI file, but with a ".LOG" extension. And lastly set the "Output video bitstream at" value to your desired bitrate. You can use any DivX v4 bitrate calculator to help you figure the correct bitrate value so that you can set it to match your desired output file size. You should be able to find a calculator at doom9.org. Once set, close the dialogs and return to the "Batch Encode" dialog.
Since this is the first pass, there is no point in encoding the Audio, so at this point uncheck the box next to the "Audio". If you are doing a 1-Pass encode, then you should set the audio codec (see below). Press the "Save" button, this will open up the job list dialog. At this point you can close it.
Encoding the video, The Second Pass:
Once again select "File > Add current project to batch list > AVI File". Once again open the Video codec and select DivX v4. This time, when opening the codec settings, select "2-pass, second pass", and set all the other settings exactly the same as the first pass.
On this pass, make sure the Audio box is checked, select the Audio codec (again, the button might be somewhat obscured on the right), I recommend the MP3 codec at 44.1khz 16bit Stereo at either 128kbps or 160kbps.
Now pick the final AVI name and press the "Save" button again. This time when the Batch Encode dialog opens, you should see both encodes listed. Pressing the "Run" button should begin the encoding process.
Additional notes (important, make sure you read this):
- When selecting the resolution, make sure the video width is a multiple of 32, otherwise certain cards will have
problems decoding the video.
- In some cases encoding the audio during the IVTC process may cause the audio to go out of sync. If that is
the case, you can have the audio encoded first and later merged back into the file through VirtualDub. To do that
in VirtualDub (before starting the frame serving process), select "Audio > Full Processing Mode",
then select "Audio > Compression", and set the codec and compression values (same as TMPGEnc audio).
And finally select "File > Save WAV", and pick a filename. This will encode only the audio to a WAV file.
To combine the audio back after the video encoding is complete, first load the Video in VirtualDub, select "Video > Direct Stream Copy", "Audio > Direct Stream Copy", "Audio > WAV Audio", pick the WAV file you saved earlier and then "File > Save as AVI". Make sure you do this on a freshly loaded copy of VirtualDub since you may have previous conflicting filters if you used VirtualDub earlier.
- If you're doing a 1-Pass DivX v4 or DivX v3 encode, you don't need to use the Batch Encode interface and can instead
select "File > Output to file > AVI File".
- You can do the image clipping in VirtualDub in order to save on some of the IVTC process computations
(less data to check), but when you do that, make sure to crop lines off the top/bottom in even numbers
(can crop 4 lines, but not 5 ... 12 lines but not 13... you get the point), otherwise the field order
may get reversed and confuse the IVTC code.
- If you are only using VirtualDub to cut unused frames and your source video was MJPEG or HuffYUV, then you
can save the frame serving process by saving the cut video with both Audio and Video set to "Direct Stream Copy".
You may need your hard disk formatted to an NTFS file system for this to work as the saved file may be over 4gb
- Normal Video aspect ratio is 1.333infinity (or 4 divided by 3), so if you need to do the math to figure out the
aspect ratio of a widescreen video after you scale it down to the desired width, keep that in mind.
- If you didn't like the file size, you can repeat just the second pass with a different bitrate as long as the
".LOG" files still exist.
- Once the encode completes to your satisfaction, you can erase the .LOG file and the first-pass AVI file.