Copy your DVD to XviD with AC3 surround sound
This guide is no longer maintained. It is stored mainly for future historians to investigate. For more up-to-date information, please see our other guides.
Over the past year or so, we have received tons of suggestions, ideas and rants about our existing DVD to DivX guide, most of them are related to the well-known bug in DivX5, which makes DivX5 codec very hard to deal with -- it doesn't obey requested bitrate levels if the movie gets "too big". Other requests have mostly related to the audio encoding, which in previous guide is done by using MP3 audio.
Within the last year, the open source alternative to DivX, called XviD has come to a mature age and it doesn't have the bugs of DivX5. Also, most of the users have finally understood that creating a backup of the DVD movie into two CDs gives clearly better results and also allows higher quality audio to be used. Therefor we decided to make a guide that uses the original sound format found on most of the DVDs, AC3, as our audio for this guide.
Please remember that this guide applies directly only to anamorphic DVDs (also called 'enhanced widescreens', etc), for old-fashioned 4:3 DVDs, the resize and crop options are slightly different (very shortly described in the guide).
Requirements
First of all, you need to have these tools:
- XviD codec (for encoding the video)
- some sort of a DVD ripper
- DVD2AVI (frameserving from VOBs and extracting the audio)
- VFAPI Reader Codec (package includes VFAPIConvert, for frameserving from .d2v file to VirtualDub)
- VirtualDub (for encoding, etc)
- VirtualDubMod (we recommend that you d/l both VDub versions and use this one only for audio multiplexing and nothing more)
- XviD Bitrate Calculator (for bitrate calculations, obviously)
- Optionally Smart Deinterlace filter for VirtualDub, if the movie is interlaced
We recommend that you install VirtualDub and the modified version of VirtualDub, called VirtualDub AC3 to separate directories on your harddrive, so that they don't "confuse" each others. Also, install the separate filters into "original" VirtualDub's directory, leave the AC3 version to do just its job -- muxing the audio to video. In addition to this, you also need to have tons of free HDD space -- normally around 7GB -- and obviously a DVD-ROM drive :-)
What will happen during the process?
First of all, we need to have the DVD on hard disk in decrypted format. That means that the software cannot handle CSS encrypted video. These DVD files require decent amount of free HDD, normally 3 to 7 GB. Then we use DVD2AVI to extract the audio and create a frameserver .d2v file. Then, because VirtualDub doesn't support .d2v files directly, we need to convert the .d2v file into another frameserver file, what we call "pseudo-AVI" with VFAPIConvert.
After that's done, VirtualDub will have to go through various steps, including resize, crop and the actual video encoding. After that's done, we use specially-modified version of VirtualDub to multiplex AC3 audio track into newly-created XviD video. And that's it. Resulting video will be a 2CD XviD video with AC3 5.1 surround audio.
Ripping DVDs

Determining the correct audio track

So, let's open this file, normally named as vts_01_INFO.txt with text editor, such as Notepad. Once opened, scroll down to a part that says "Stream Info".

As we want to have the audio track that is in AC3 format and has 5.1 channels and is spoken in English, we look first for English tracks. Soon we notice that English tracks are Track 02 and Track 03. Both are in AC3 format, but only the first one of them has 6 channels (5.1) in it. So, the track we select, is Track 02 in this particular case. Now, try to remember this -- or if your mind is too wobbly that you can't remember one number, write it down :-)
DVD2AVI

Open DVD2AVI and from File menu, select Open. Now, locate the ripped VOB files from your harddrive and select the first one in the list and click Open. After this, DVD2AVI should pop up a new window that lists all the VOBs you ripped to this directory. Simply check that this is the case and click OK.

Look at the Statistics Window while the movie is playing and write these things down:
- Aspect Ratio: either 16:9 or 4:3 -- if this is 4:3, this guide wont work for you, since the movie is not anamorphic
- Frame Rate: either 23.97, 29.97 or 25.00
- Video Type: this is important! This can be either PAL, NTSC or FILM (FILM has usually a percentage number -- if your movie says FILM, let the movie run for at least 5 minutes and write down the percentage shown in here)
- Frame Type: Interlaced or Progressive
Decisions, decisions...
Now, if your Video Type was PAL, you don't have to think about this further, skip to the next chapter. But if you have an NTSC or FILM type, this gets tricky. This is due the fast that normally NTSC movies have been "telecined" from 24fps framerate to 29.97fps in order to make the movies compatible with American TV standard (NTSC) by artificially increasing the framerate.
So, in order to remove these useless dupe frames and to get a pure, original-form movie out of the DVD files, we need to perform a Force FILM operation within DVD2AVI or IVTC in VirtualDub. Now, we have to decide, based on these facts:
- If DVD2AVI says FILM and no percentages at all and Frame Type was Progressive, you should perform Force FILM
- If DVD2AVI says FILM and percentage is over 95%and Frame Type was Progressive, you should perform Force FILM
- If the Video Type is NTSC and Frame Type is Progressive, you should use Force FILM (this is one case that CAN cause problems, but give it a shot)
- In cases where DVD2AVI says Frame Type is Interlaced and Video Type is either NTSC or FILM (with or without percentages), things can go pear-shaped easily. Suggested thing is to use DVD2AVI's preview and scrollbar and scroll around the movie and look at frames where there is lots of contrast -- such as man in black suit and with white background -- and look at the contrast points (where the black suit changes into white background) and see if the edges are "smooth". If not, movie is most likely a really interlaced. Otherwise you should also try to use Force FILM and skip deinterlace part later on in this guide.
Force FILM (optional)

Ok, if based on the above chapter, you need to perform a Force FILM operation, then this chapter is for you. If you have PAL material or otherwise twisted NTSC source, skip this chapter.
Simply go to to the Video menu and select Forced FILM under Field Operation submenu.
Audio demux

Then, again from Audio menu, go to Output method submenu and select Demux (AC3, MPA, DTS).
Save the project
Next step is to save the project file (.d2v file) and the demuxed audio (.ac3 track) to HDD. Simply go to File menu and select Save Project. Select some short name and hit Save. Now DVD2AVI will extract the audio and write the project file. This doesn't take long -- the time depends on the length of the movie and speed of your harddrive -- normally couple of minutes.
VFAPIConvert

Start VFAPIConvert and click Add Job button. Now, file dialog opens. Simply locate the .d2v file DVD2AVI created for you and click Open. If you created the .d2v file in same directory where you also ripped the VOBs, there's a good chance that you see two .d2v files inside this directory. The other one is normally named as vts_01.d2v or similiar. Ignore this file as it is generated by SmartRipper and SmartRipper's .d2v generating doesn't work correctly. Open only the one you created with DVD2AVI.
Now VFAPIConverter should popup a small window that shows the Source(S) you selected and the suggested Output(S) filename. This should be OK by default, since this pseudo-AVI will be very small. Now check that Options are correct -- Export Video and Export Video through VFAPI Reader Codec should be both checked and the Export Audio should be dimmed. If this is correct, click OK.
Now, simply click Run and VFAPIConverter will create you a pseudo-AVI. This will take less than a minute, normally only couple of seconds.
Calculate bitrate

Now, use the Movie Length slider to adjust the length of your movie, the number you wrote down earlier, in minutes (just for those who had F in maths, 1h = 60mins, so 1:55:09 length equals to 115mins and 9secs) -- preferrably one or two minutes more than the actual length, just to be on a safe side.
Next, move the Movie Size slider to 1409 MB -- this value is exactly the amount of data you can fit on 2 80min CDs. Now, click the Using Selected file(s) button and program will open a file dialog box. Select the AC3 audio track DVD2AVI created for you and click Select.
Now you should see a value next to Video Size at the bottom of the page. Write this value down and exit the program.
VirtualDub stuff

Next, go to Audio menu and select No audio (as we're going to add the audio afterwards).
Then, go to Video menu and select Full processing mode. After you've done this, select Compression, again from the Video menu and VirtualDub will open a new window that allows you to choose your compression method for the video. Select XviD MPEG-4 Codec and click Configure.
XviD's first pass settings

Global tab

All three checkboxes (Enable lumi masking, Enable grayscale and Enable interlacing) should be unchecked.
Quantization tab
Don't touch this :-)
Two Pass tab

Alt. Curve tab
Don't touch this either ;-)
Credits tab

Debug
Just leave the Automatically detect optimizations selected. After this, you can close the window by clicking OK. Now, close the codec selection window as well, by clicking OK.
IVTC (optional)

Now, go to Video menu and select Frame Rate... Leave Source rate adjustment to No change and go to Inverse telecine (3:2 pulldown removal) and change the setting to Reconstruct from fields - adaptive. Now, close the window by clicking OK.
Deinterlace with Smart Deinterlace (optional)

We are going to use external VirtualDub filter for this process, called Smart Deinterlace, which -- as its name says -- is pretty smart :-) It performs interlacing only to those parts of the video that require it, such as fast motion scenes. Installing it only requires unzipping the package into VirtualDub's plugins directory.
Now, go to Video menu and select Filters. Next you should see VirtualDub to open a new window that lists your filters. Click Add and a new window opens. Select smart deinterlace from the list (if it doesn't appear in the list, click Load.. and find the .vfp file you extracted from the smartdeinterlace's package) and click OK.
Now, program opens up Smart Deinterlace's settings window. This is something that is slightly confusing and unfortunately there aren't really good "use this and that's it" type of instructions available for this filter's usage. But based on the experience and comments from various authors, these suggested settings here are a relatively safe bet -- but if you experience some sort of a weird movement jinxes in fast scenes, you might want to try other options.
Anyway, let's keep the Frame-only differencing selected, but take out the Compare color channels (instead of luma) checkbox (unless you're processing a cartoon, in which case this should be checked). Uncheck Show motion areas only and Blend instead of interpolate in motion areas. Check the Use cubic for interpolation -- this setting takes more time, but produces better results when encoding. Leave the default values in the numeric boxes -- 15 for Motion threshold and 100 for Scene change threshold. Finally uncheck the Motion map denoising. Leave all Advanced Processing checkboxes unchecked. If you wish to tweka around these settings, we recommend you to read the html file that comes within the Smart Deinterlace's package -- it explains the various settings in more detail.
After this is done, click OK to return back to the filter selection.
Resize
Now, let's get into resizing. Because AVI clips can't have anamorphic bit unlike DVDs, which do, we have to resize the video to be in correct aspect ratio. And as you have already understood, this guide is mostly for anamorphic DVDs. But if you insist to rip those oddball 4:3 aspect ratio movies, you can use this guide as well -- easiest way is to simply skip this part if your video is in 4:3 aspect and modify the cropping part to meet the "multiply-by-16" demans.
But to get into business, we need to get the video into correct aspect ratio. Now, we love to get the movies into 640 width, for various reasons -- it doesn't reduce the original width of 720 pixels "that much" and also is one of the "native" Windows resolutions, meaning that you can switch your PC's resolution to 640x480 and your player don't need to perform a resize-on-fly when you play the movie. So, we will use 640 pixels as a width for the video. Now, since anamorphic movies are in 16:9 resolution, we can easily calculate the height of the movie as well. Simply, let's take 640 and divide it by 16 (ok, get your calculator and check it) and we get 40. Now, since the width:height ratio is 16:9, we simply multiply the 40 with 9 and we get the height in pixels (calculators again..) -- 360. So, the resolution for us is going to be 640x360.

After you've done this, click OK to return back to the filter list.
Crop the video
Now, next step is to get rid of the black bars at the top and the bottom of the picture, if there's any -- note that even that there isn't any black lines, you still need to do this, if your resolution is now 640x360.
So, now we need to understand one important thing -- all video codecs love videos that have resolutions which are multiplies of 16. In most of the cases, they don't even start encoding your video if this is not the case. So, if we take a look at our width, it's 640. So, let's divide this by 16 and we get 40, which is integer and means that this width is in multiplies of 16.
Now, if we take a look at our height, it is now 360. Divide this by 16 and you get 22.5, which means that the height is not in multiplies of 16. Even if there isn't any black bars in the top or in the bottom of the video, you still need to get rid of at least 8 pixels to get the resolution to be in multiplies of 16 (such as 640x352).
Remember this "both, height and width, have to be in multiplies of 16" rule.

So, next thing you should do, while null transform is selected in the list, is to click Cropping... This will open a new window for you.
Now, in this window you see the preview of your movie and four little boxes called X1 offset, X2 offset, Y1 offset and Y2 offset. Now, don't touch to X settings -- we don't want to complicate things too much :-) Use the slidebar to get into a frame that has movie in it, so you can see where the black borders begin and where the movie area ends.
Use the Y1 and Y2 settings to cut the top and bottom black areas. And now, remember that your original height was 360 when we got into this part. So, adjust the Y values to get rid of the black areas get your calculator ready and reduce the value what you have in Y1 from 360 and then reduce value in Y2 from this result. Now, divide this value with 16 and if you get an integer, you're good to go. If not, increase the black borders slightly until your final value (360-Y1-Y2) is in multiplies of 16. One of the most probable results is that you will get 44 in the top and 44 in the bottom part and this will result into 272, which is really in multiplies of 16. This is not the case always, but it is the case in very many movies (with "real" aspect ratio of 2.35:1).
Once you've cut the borders and confirmed the resolution, click OK to return back to the filter list. Then you can click OK to exit the filter list as well and to return back to the main window.
Save the first pass

Change the second pass settings

Now, a new window opens. Change the Encoding Mode to 2 Pass - 2nd Pass Int (yeah, we will trust into XviD's ability to make these decisions). Then, exnter the video size you wrote down in XviD Bitrate Calculator into Desired size (Kbytes) box. Then, simply click OK as the Advanced options should have remained untouched since you saved the first pass. And then simply click OK in Compression window to return back to the main window.
Save the second pass

Start encoding

Multiplexing the AC3 with the video

First, go to File menu and select Open video file.. and find the second pass AVI you just finished and click Open.

This opens a file dialog. Use this to locate the AC3 file you created with DVD2AVI and click Open.
Interleaving settings
Now, look at the filename of your AC3 file -- it should tell you some useful information, such as the bitrate of the audio and the delay value for the audio (marked in milliseconds in the filename).
Now, go to Audio menu and select Interleaving.... This will open a new window.

For 384kbps 5.1 AC3, try to put 160 into Preload box and 160 into Interleave audio everyXXX box. Then change the selection next to the Interleave audio every XXX box to ms.
If your audio is in 448kbps 5.1 AC3 format, try 128ms values for both boxes.
Finally, enter the value you have in the AC3 filename to the Delay audio track by XXX ms box and close the dialog box by clicking OK.

After you've done this, go to File menu and select Save as AVI... Now, make sure that your destination directory has appx. 1400MB of free space and then pick a name for the file, something like 'the_movie_final_version.avi' and hit Save.

For the audio playback, you most likely need to download the audiofilters package, available from Doom9's download page.
Splitting & rest of the stuff
Now, maybe you want to save this video to CD as well? If so, you will need to split it into half. Luckily we have exactly the right guide for this process :-) Simply follow this guide to split the movie.
And if you prefer to have subtitles (dubbing is a 8th deadly sin), you might want to read through our subtitle ripping guide as well.
As usual, all questions, comments and ideas should be posted to our discussion forums.
Version history
v1.0 -- 16th Oct, 2002, First version online (dRD)
v1.1 -- 7th Nov, 2002, Updated the XviD 2-pass tab settings to manually set the 1st pass analyzing log path. Also added the audio interleaving settings. Thanks for jukkaam for the tips! (dRD)
v1.2 -- 19th Nov, 2002, Changed references to VirtualDubMPG2 to VirtualDubMod, since VirtualDubMPG2 is now being integrated to this new VDub modification project. (dRD)
Written by: Petteri Pyyny