MPEG-2 Bad, MPEG-4 Good

So at this point, you have the files in MPEG-2 format, they’re on your PC, and they’re playable on your PC. Aren’t you done?

The answer is no, you probably aren’t. Given the realities of network bandwidth and hard drive cost, MPEG-2 storage is still probably not quite right for your home jukebox. Just as an example, let’s look at the numbers for Just Married, one of the finest movies of 2003. After ripping this movie to my hard drive, I see that the four VOB files take up 3,761,000,000 bytes.

Using a calculator shows us that this 95 minute movie must have a bit rate of approximately 5.28 Mbps – probably not reasonable for an 802.11b network. Even under ideal circumstances when there is only one stream active on the network, it would be tough to keep up that kind of throughput. Put the network under only a moderate load, add in typical impairments to reception, and you’re just not going to be able to watch Ashton Kutcher and Brittany Murphy gallivant around Europe without lots of breakups and pauses. No fun.

The second problem is one of simple economy. I have perhaps 100 DVDs that I want to store on my hard drive. At a price point of roughly $1/GByte, MPEG-2 storage of my collection is probably going to set me back close to $500, and will mandate an array of big drives, complicating my server setup.

Fortunately, there is a readily available solution to this problem. The MPEG-4 video standard, ratified in 1999, provides a video codec that can compress data much more effectively than MPEG-2, albeit at some increase in the required CPU power. Fortunately, CPU power is something most of our desktops have plenty of.

Packaging MPEG-4 Streams: DivX

The most common way to store and distribute MPEG-4 video is using what is known as the DivX format. This format encapsulates an MPEG-4 video stream and an audio stream in an AVI file. AVI files are widely supported on a wide variety of platforms, and generally all you need to play DivX video is a DivX video codec and the appropriate audio codec, usually MP3 but sometimes AAC.



The DivX player

The DivX codec used to create these AVI files is built and supported by DivXNetworks, a company that grew out of the original hacks and Open Source projects that gave birth to DivX. DivXNetworks not only creates codecs and other software tools, they also have a certification program for hardware manufacturers. There is a lot of good information and support on their web site at www.divx.com.

Typical MPEG-4 streams created with DivX codecs will be only perhaps 30% of the size of the originals. This reduces network throughput down to something under 2 Mbps, which makes it much more likely that I can ship movies over my 802.11b network. It also reduces the cost of storing movies on my hard drive down closer to the $1 range, making it more palatable.

I should point out that squeezing DivX video down to radically reduced sizes is a popular activity. A common goal is to be able to store an entire movie on a single CD. In this article I’m always assuming that you want to store your DVDs at archival quality, so I won’t be trying to explore the outer reaches of size reduction. When my DivX file is squeezed down to 20-25% of the size of the original MPEG-2 video, I find the quality to be noticeably degraded.

Using Dr. DivX to Create MPEG-4 streams

Start poking around on the web for advice on how to convert MPEG-2 video to DivX format and you’ll quickly realize that everyone and his brother has a different notion of how to skin this cat. Unfortunately, when you start browsing through the tutorial and how-to guides, you’ll see that there is a fairly steep learning curve associated with most of the packages out there.

For those of you who are looking at this conversion simply as a means to an end, I will recommend the use of a tool that doesn’t have quite as many bells and whistles, but will do a great job on nearly all of your video conversions. Dr. DivX is the conversion tool sold by DivXNetworks that fills the bill quite nicely.

The Dr. DivX page on the DivX.com site has information about Dr. DivX, as well as links to download and purchase the program. Please note that you can use the program on a trial basis for 15 days to see if it meets your need. I definitely recommend the trial run before purchasing Dr. DivX.

Downloading and installing Dr. DivX is a straightforward process, and I won’t provide any additional details here. The procedure will install both the DivX codec and the app on your PC, and will optionally install a DivX player. (I don’t see any reason to install the DivX player, so I don’t recommend that option.)

Dr. DivX has one additional requirement that you might not have on your PC, which is an AC3 decoder. This software is required to decode the audio in your captured DVD VOB files. There is a free package called AC3Filter available on its SourceForge project page at ac3filter.sourceforge.net. This is an option-free install which simply makes the AAC encoded audio understandable to Dr. DivX.

With the software installed on your PC, it’s now a pretty simple set of steps to turn that ripped MPEG-2 data into a tightly packed DivX file.

Step 1: Selecting the Input

When you first start Dr. DivX, you’ll be presented with the screen shown here.



Dr. DivX opening screen

You’re going to be converting video files, so select the “Video File” button. This will present you with a standard Windows File Open dialog. You will then want to navigate to the folder where you stored the VOB files ripped from your DVD.

You should see a list of VOB files with a name in the format VTS_XX_N.VOB, where N starts at 1 and works its way up by steps of one. Simply select the first VOB file as your input. Dr. DivX will automatically pull in all the VOB files in that sequence.

Dr. DivX will then pop up a dialog that offers you the opportunity to exclude any of the VOB files from the input to this session. You should assume that all files are part of your input and pass on this option. Dr. DivX will then do a bit of processing on the input before moving on.



Dr. DivX offering you the chance to exclude files

Step 2: Selecting the Audio Track

The next screen is the audio selection dialog. Most DVDs have several audio tracks, and Dr. DivX needs to know which one you want to include in the AVI file.



Dr. DivX audio input dialog

In general the first track is the one you will be using, but it’s good to preview it here before moving on. The play button lets you hear the actual content of the audio track, and you can use the slider to find a spot in the soundtrack where there is some dialog. The most common mishap that can occur here is the inadvertent selection of the wrong language.

After you’re comfortable that you have the correct track, click the Next button and move on to the next step.

Step 3: Output Configuration

The next dialog is labeled “Choose Output”, but it’s really more of a preliminary configuration step. The first thing to observe in this dialog is that it asks you to select a certification level. This selection is designed to make sure that you create a DivX file that can be played on your output device. All of the playback scenarios discussed here will work on the Home Theater setting, so choose that.



Dr. DivX Output Configuration dialog

In the section of the dialog labeled “Encode the DivX Video to:” you have a couple of options. I recommend that you select the “Make a Quality file” drop down box and select the “High” option.

The Profile Output of the dialog shows you at this point what parameters have been chosen by default for this encoding. You will have the option to change all these in the next couple of dialogs, which you will reach by clicking the “Next” button.

Step 4: Basic Settings

You’re now on the Encode Video dialog, which implies that you are ready to go – but this is a bit misleading. You should go ahead and select your output file name at this point, but don’t click the Encode button yet! There are a couple additional screens of configuration you need to go through before completion.

At this point, instead of pressing the Encode button, click the “Modify Settings” button. This will provoke a warning from Dr. DivX, which you will have to acknowledge. It’s true that modifying things in these advanced settings can hose up the process, but you are only going to make a couple of small changes.



Dr. DivX Basic Settings dialog

Clicking the “Modify Settings” button brings up two additional windows: the Basic Settings dialog and a Preview window. The Basic Settings dialog provides an opportunity to modify the resizing and cropping recommended by Dr. DivX. In general I’ve found that you should leave these settings alone – Dr. DivX does a good job of selecting the appropriate values. (Although in a couple of instances I’ve found that the Good Doctor recommended resizing and as a result fouled up the aspect ratio.)

The Preview Window gives you an excellent opportunity to do a sanity check on your video, allowing you to see if all the recommendations are correct. Simply click on the Play button and see what plays back. You should see the video you expect, with the audio track you selected, properly synchronized and cropped.

The Basic Settings dialog also allows you to change the encoding frequency of your MP3 output. I frequently change the recommended 128 Kbps setting to 160 Kbps.



Dr. DivX Preview window

You have just one final step before the encoding starts. Click on the “Advanced Settings” button to bring up the final dialog.

Step 5: Advanced Settings

The final dialog you will see before encoding is the Advanced Settings dialog. There are a lot of options here, but I’ve found that you can ignore most of these without too much effect on the final output. I change just a couple of things here. First, the dropdown box that specifies the Variable Bitrate mode will default to 2-pass. Change this to 1-pass.

The second change is in the Bit Rate, just above the drop down box. I will typically increase the value here to be at least 30-40% greater than that recommended by Dr. DivX. For example, on a typically sized video, Dr. DivX will frequently recommend a bit rate of 1000 or 1100 Mbps. I’ll usually bump that up to 1500 Mbps.



Dr. DivX Advanced Settings dialog

These changes I’ve suggested will be anathema to many experienced video hackers, but I think the difference is one of motivation. Dr. DivX is set up to do a good job of minimizing the output file size, but I think it does so at the expense of quality. I’m not concerned about getting my DVD to fit on a single CD, all I want it is an excellent quality copy on my hard drive.

I’ve found that if I let the DivX codec do its thing in 2-pass mode, I see far too many encoding artifacts, regardless of the suggested bit rate. The single pass method may not be optimal, but it has the advantage of producing the high-quality output I want. In most cases the copy is indistinguishable from the orginal DVD.

At this point, you’re ready to set the process in motion. Press the “Encode” button, and you’ll see Dr. DivX cogitate a bit before starting the encoding process. Once it starts, you should sit back, relax, and wait.



Dr. DivX encoding

How long will you have to wait? That depends on the speed of your system. If your machine is a high-end P4 with a 2.5GHz CPU, you may well be able to encode near real time, which means you’ll have a complete AVI file in a couple of hours. A lower speed Celeron may only be able to encode 5-10 frames per second, which means you probably want to kick this process off just before you go to bed.

Eventually it will complete, and you are ready to view your encoded masterpiece. How do you do this? Read on.