Encoding
So now you have a .trp or equivalent stream on your disk. Next we will be extracting the MPEG2 stream from this puppy! Grab the HDTVtoMPEG2 program included with this guide, and open your .trp stream in it. The program will automatically detect the stream location (0x11 or 0x21 for video, 0x14 or 0x24 for audio). Select the output location, and hit convert. Woot. Look at that sexy 1920x1080 MPEG2 file sitting on your hard disk. Hot yet? Let's have some fun with this baby.
Grab DVD2AVI and open the MPEG2 file. Enable Clip/Resize (I usually clip 16 off bottom/top and 8 off sides just for safe keeping, almost no lost data). When cropping it's important to crop in even number of pixels, otherwise some of the filtering we do later on may fail!. For the Audio conversion, if you want to let dvd2avi encode to mp2, then enable High or Higher Quality conversion, and set it to 44khz. If you want to encode to MP2 later, then simply select Demux in the Dolby Digital menu. Make sure you set the colorspace to YUV 4:2:2. Leave the rest as default, and hit the Save Project option in the file menu. Now you'll have a little .d2v file and a (relatively) big .wav file. Make sure you've got AVISynth installed on your computer now.
Before we move on, I am going to explain the theory behind what we are going to do. By doing this, I can quickly jump through the steps and you'll know what's going on. We're going to open the .d2v file (think of it as a frame server that allows you to open the MPEG2 file as if it was an avi), get the video at the correct frame rate, mux (combine) the audio back in, filter any problems out, and write the final file to the desired file format. The way we are going to do this is by opening the .d2v in AVISynth, and either IVTCing (When an interlaced source such as 1080i is used) or decimating (when a progressive source such as 720p is used) the video. Then we'll open that .avs script in VirtualDub, mux the audio in, cut undesired frames (Any sequence within the capture we don't wish to keep), and filter out film grain.
The idea of decimating really needs to be explained more clearly here. There are basically two HDTV formats. One has 1080 pixel rows of resolution, but it's interlaced. This is what we call 1080i. 1080i is 29.97 frames per second (the standard NTSC format for broadcast). The frame size is extremely huge in comparison to older formats, but the motion is very slightly jerky. Please note that unless you are an extreme videophile, you won't notice the jerkiness. 1080i is pretty easy to fix by simply using a standard IVTC method. The other format has 720 pixel rows of resolution, but it is progressive (meaning no combing effect). This comes in at roughly 60 frames per second (essentially 2*29.97). This is the more difficult video to fix up. The way the 60 fps video works is as follows. The original film is shot at 24 fps for most primetime shows. They take the 24 fps video and double one frame out of every 5. This pops the fps up to 30 fps. From 30 fps, they double every frame, which pops it to 60. To fix this we do the exact reverse. We take the 60 fps video and drop every other frame (SelectEven/Odd in AVISynth script). This gives us a 30fps video with one duplicate frame every 5. We take this 30 fps video and decimate it down to 24. The Decimation/IVTC filter that comes with this guide is recommended. This filter takes a 5 frame block and looks for the two frames that are most alike (in a row), and drops the second one. By dropping the second frame out of a 5 frame block we've taken the video to 24 fps. Now that we're down to film fps, and still have the exact same actual content as a 60fps video, we can continue on.
Now, let's actually do it. I have included two avs scripts with this guide. One is for 1080i video, and the other is for 720p. Copy the one that matches your video source, and edit the values to match the path locations to the filters within the script.
Now that you have your .avs set to input the .d2v and output a 23.976 fps video, open that .avs in VirtualDub. Once it's open in VirtualDub, hit the Audio menu, and select WAV Source. Locate the converted wav file (should be in same dir as the .d2v). Next add the Resize filter in the Filters menu.
Now here comes the tricky part, if your target file is intended to be DVD compliant you need to consider all sort of factors like Anamorphic aspect ratio. In this guide we won't touch on this but rather on AVI (DivX/XviD/Etc...) and SVCD.
With SVCD as the target format, resize to 480x360 with a precise bicubic of .75 (.6 is more accurate, but gives a softer image, and 1.00 is super sharp, and not needed for HDTV source), then check the box below it that says Expand Frame and Letterbox Image. Input 480x480 for the expanded frame, then hit ok. Now you have a 480x360 picture letterboxed into 480x480 window. When expanded, the picture will be 640x360, which is a 16:9 ratio (widescreen). Now that we're back at the filters menu, add Temporal Smoother of 2. This will kill most film grain (except on FOX stations which use 480p upconverts) left over after the resize. The coloring and sharpness should be fantastic since it's exactly what was broadcast, so removing the grain should be enough. If the grain is particularly heavy, you may have to switch filters (add a slight smart smoother? temporal cleaner instead? dynamic noise reduction?). Experiment with the filtering, but temporal smoother seems to work the best because it's time based instead of spatially based. Set the compression to HuffYUV and save as a "Segmented AVI" if your hard disk is formatted to FAT32 or normal "Save as AVI" if your hard disk is formatted to NTFS. We do this lossless (no image data loss) compression once so we can do multi-pass SVCD encodes without having the video processing recalculated for each encoding pass.
With DivX the only difference is to select the DivX compression codec, and resize to any resolution, but without extending the frame. Resolution such as 640x360 and 768x432 are recommended for the best quality. If you plan to do 2-Pass DivX encodes you may also want to save to HuffYUV first so that the video processing isn't recalculated for each pass.
That's pretty much what needs to be done to get a DivX or SVCD. The important part are the .avs scripts, since DivX/SVCD encoding is pretty well documented. It should be noted that the demuxed/remuxed wav file can get out of sync with the video on occasion. If this happens, simply use VirtualDub's interleaving option to sync the audio. Find whether the audio is too early or late, then try entering a value, then playing the file in VirtualDub to see how it works. This can be a bit tricky, but once you figure out how to do it, it only takes a minute at most. Then just save the .wav, and remux with the video, and you should be set.
PREVIOUS | NEXT |