Return to Main Page

Movie Encoding with h.264



The encoding gods have smiled on us and presented us with a new codec that surpasses anything yet seen, in terms of quality per bitrate. However, it also requires a very long time to encode (6 to 7 hours for a 2-hour movie, typically). In other words, this is a codec for people who want the absolute highest quality in the smallest space, and are willing to devote hours and hours of CPU time to get it.

If you are not familiar with the basics of movie encoding, check out part I, part II, and part III of this series of guides. Also see doom9.net for a more in-depth (though less straightforward and formulaic) discussion of just about any part of the encoding process.

(We are not responsible for any laws you violate while using our guide; it is intended for legitimate backups of DVDs you already own.
With current legislation, it is impossible to know exactly what is legal without a lawyer, and we don't claim to.)

Required Programs

You'll still need OggDropXP, as Ogg Vorbis still pwns everything else (in my opinion), a ripping program such as DVD Decrypter or vStrip, and the GordianKnot package, which includes DGIndex for audio extraction, and GordianKnot itself, for generating an AviSynth frameserver.
You'll need Microsoft's .NET Framework, which is found here.
You'll need the encoding front-end MeGUI, which is found here.
You'll need the h.264 codec itself (specifically the command line interface part). It is found here.
Finally, you'll need MKVToolNix, a program for muxing (combining) audio and video in a Matroska container format. It is found here.

Setup

Install the .NET Framework, which probably requires a restart. Then install the h.264 codec, MeGUI, and MKVToolNix. I'll assume your ripping program, GordianKnot, and OggDropXP are already set up.

Encoding

Rip your DVD to a directory. Load all VOBs into DGIndex. Go to the Video menu, Field Operation, and select Honor Pulldown Flags. Go to the Audio menu, select Normalization, set it to 100%, and check the box. Go back to the Audio menu and set Output Method to "Decode AC3 Track to WAV", and also select your audio track (probably Track 1). Go to File and choose Save Project. DGIndex will spit out a D2V file and a WAV file into your encoding directory.

Open GordianKnot. Press "Open" on the lower pane. Find your D2V file and open it. Go to the Resolution tab, select NTSC or PAL as suits your DVD. Crop any black bars off the frame and select a resolution. Due to the amount of CPU power it takes to play back an h.264 video, I recommend selecting a resolution with total number of pixels less than 250,000 (total number of pixels is Width times Height). For a 4:3 movie, I recommend 576x432. For a 16:9 movie, I recommend 704x304. Go to Save & Encode on the video browser window and select "Inverse Telecine" in the Field Operations pane. Click "Save" and save your AVS file.

Now comes the unfamiliar part. Open MeGUI. It will probably ask you if you want to update. If it doesn't, go to Tools - Update, and update it fully, and import ALL profiles. You will need to close MeGUI and open it again if it updated anything. Once MeGUI is updated, you will see the Input tab. Click the "..." icon next to AviSynth Script. Browse to your AVS file and open it. A video browser window should appear, but ignore it. In the main window of MeGUI, find the pull-down menu for Container. You must choose MKV here. If you don't, your encode will be fubar. The Codec pull-down menu should be set to "x264" automatically. If not, set it. Now click the "Config" button near the Codec menu. A new window should appear. At the bottom, in the Profiles pane, select "CE - Highprofile" from the pull-down menu. Press the OK button, and the window should vanish.


In the main MeGUI window, go to the Tools menu and select Bitrate Calculator. A new window should appear. In the Total Size pane, enter 1120 MB (1/4 of a DVD-R). In the AudioTrack 1 pane, select Ogg Vorbis as the Type, then enter in the exact size in KB (kilobytes). A typical size is somewhere around 50,000 to 90,000 KB, depending on movie length. If you have a second audio track, select its type and enter its bitrate. If not, leave the Type field blank under AudioTrack 2. When you're done entering in all audio sizes and selecting your target filesize (which automatically includes audio), press Apply. Here's an example window.


Back at the main MeGUI window, press the Enqueue button in the UPPER half of the window. Do not press the lower Enqueue button, as this will result in an error. Both passes of the encoding are now queued. Go to the Queue tab, highlight the first of the two passes, and click Start. Your encode should be done in 6 to 7 hours, but the ETA can vary quite a bit depending on the length of the movie and your CPU's abilities.

When the encoding process is done, close MeGUI and open MKVToolNix, which appears as "mkvmerge.exe". Click the "add" button and select your output MKV video file. Click the "add" button again and select your OGG audio file (and again if you have two audio channels). In the "Output filename" pane, near the bottom, choose a name for the output file that is DIFFERENT than the one for the input video file. Simply type the new name into the path listed next to the Browse button. Now press "Start Muxing", and after a couple minutes, your file should be assembled. Check the new file to make sure the video and audio are working properly. If they are not, you probably did something wrong and should start over. If they are, delete the old MKV file (which is video only), the OGG audio file, and all the other encoding files. You are now free to rename the muxed audio/video MKV file to whatever name you like. The end file should be about 1.08 to 1.09 gigabytes in size. You're done!

I recommend installing the latest edition of FFDShow and using Media Player Classic. If you have trouble playing Ogg audio files, install the Ogg DirectShow Filters.

Happy encoding, folks!



PrimarScources