DVD ripping and transcoding with Linux

This guide was updated on August 23, 2002.

  1. Introduction
  2. Required software
    1. A word on codecs
    2. Common libraries / codecs
    3. MPlayer
    4. transcode
    5. getting RPMs
  3. Ripping the VOBs
    1. Interlaced video
    2. ...using the command line interface
    3. ...using dvd::rip
  4. Transcoding the DVD to an AVI
    1. Aspect ratios
    2. Using dvd::rip
      1. Clipping and zooming
      2. Choosing encoding parameters
      3. Generating a quick preview
      4. Preventing audio/video desynchronization
      5. Doing the whole thing
      6. For advanced users: transcode command line arguments
    3. Using MEncoder
      1. Encoding the audio
      2. Generating a preview (first pass)
      3. Generating a preview (second pass)
      4. Generating the final AVI (both passes)
  5. Subtitles
    1. Converting subtitles to text format
      1. Compiling the tools
      2. Extracting the subtitle stream
      3. Converting the raw stream
  6. Additional tricks
    1. Fixing desynched audio
    2. Splitting AVIs
    3. Extracting audio from VOBs/MPEGs/AVIs
    4. Using separate audio files
    5. A visual AVI editor: avidemux
  7. Links
    1. Libraries, codecs
    2. Media players
    3. Media encoders
    4. Other documentation
    5. Mailing lists
  8. Glossary
    1. CBR, VBR and ABR
    2. Global Motion Compensation (GMC)
    3. Letterboxing
    4. P/I/B-Frames, GOPs
    5. Quarter Pixel (QP)
  9. Changelog
  10. About

1. Introduction

So you've bought a shiny new DVD. You think it ultimately rocks and want to be sure that no matter what happens you still have a copy of this movie. But how the heck do you get it from that big DVD onto such a small CD? And in good quality, mind you? Just read on.

WARNING! This guide is not for the faint hearted. It involves a lot of compiling code, installing software, doing things on the command line. If you don't know how to do configure; make; make install then read some other docs and learn about it. If you don't want to then please install Windows and use all those formidable DVD ripping utilities available for it. I won't start a flame war about "Linux vs Windows". It's simply a fact that the process is rather difficult under Linux.

You're still with me? Great! You're about to embark on a journey to a beautiful land...

Back to the table of contents


2. Required software

First let me introduce you to some tools you'll use.
I'll present you two methods for DVD transcoding - using MEncoder and transcode. Nevertheless you need some files for both method.

2.1. A word on codecs

In an ideal world there would be only one codec - the best one. But this world is far from ideal. The result is that there is a wide range of video and audio codecs to chose from. First I'll explain the different types of codecs: Today most codecs come with a native version for Linux (like XviD, DivX 4/5 and others).

Here's a list of supported video codecs:

This guide tries to focus on two codecs: XviD and lavc. Reasons are that both provide excellent quality, both are fast and you only need a MPEG4 compliant decoder (like DivX 5, XviD or ffdshow) on a Windows system for playback. Playback under Linux is no problem at all - MPlayer or Xine do happily play DivX 4/5, XviD and lavc encoded movies.

Again a list, this time for audio codecs:

I hope this clears things up a bit.

2.2. Common libraries / codecs

I won't go into too much detail in this chapter. There is more documentation on how to install included with each package. Refer to that if you have problems. Also note that MPlayer has rather strong requirements regarding versions of gcc, binutils and other central system components. Refer to
the MPlayer installation documentation.

Note: Before downloading software check if your distribution already contains that software. I use Debian Woody (testing) and have found that a lot of software is already available prepackaged.

2.3. MPlayer

You need MPlayer. It doesn't matter if you'll use MEncoder or transcode later on - you still need this. So get MPlayer from
http://www.mplayerhq.hu/. I prefer the CVS version as it often has features that the official releases lack! Just do the same - be brave and get the CVS version.

If you want to encode using MEncoder I suggest you also get a version of libavcodec for encoding. You only need to download it if you are using a CVS version of MPlayer. Releases come pre-packaged with libavcodec. These instructions are taken from the MPlayer documentation:

2.4. transcode

Get transcode from the homepage. Make sure that it compiles with XviD support as well as with support for MPlayer's post processing functions. Again I advice you to chose the CVS version.

Additionally you really want to download dvd::rip, an excellent Gtk+ based frontend for transcode. Get it from here. Installation instructions are included.

2.5. getting RPMs

I know of at least two places where you can find some RPMs for the software mentioned above:

Back to the table of contents


3. Ripping the VOBs

This part is rather easy. All you need is some free space (a lot of free space actually). Depending on what you want to transcode you should have 10G of free space available. If you don't spend some bucks on a new drive, they are really cheap at the moment (like 100€ for a 80G drive).

Before you do anything else think about the region code. All drives shipped today have RPC mode 2 protection - that means that you can only switch your region code five times before it is locked. You can get information about how to remove the region code from your drive over at Digital Digest. So why am I mentioning this? The ripping methods mentioned below rely on the drive to have the correct region code (read: the same as the DVD that's inserted) or no region code at all. All error messages are kind of cryptic and it's often not very clear that you have a region code related problem when ripping fails. So keep that in mind.

First test the DVD. Fire up MPlayer and watch the first title: mplayer -dvd 1. Do you like it? Cool. Make sure you remember whether the video is interlaced or not (see below). Close MPlayer.

3.1. Interlaced video

What you see on television are not 25 frames per second. In fact you see 50 half-frames per second (I'm talking about PAL here - NTSC has 29,97 fps or nearly 60 half-frames per second). One frame contains the odd rows, one frame contains the even rows. That way you'll get 25 fps. The problem is that those half frames are taken from different times. If you have fast horizontal movement you will then see that an object (or person) is at one position for the odd rows and at another for the even rows. These are artifacts you don't want to have in your final video. Now take a look at this interlaced picture taken from my Ally McBeal DVD. With the appropriate filters you can eliminate the effect of interlacing (called de-interlacing... what a surprise ;)). Here's the same picture with de-interlacing enabled.

Now that you have an idea what interlacing looks like you should be able to decide for yourself whether your DVD contains interlaced material or not.

For the rest of this guide I'm assuming the following:

Please substitute these paths with paths that apply to your system.

There are a lot of ways to rip the VOBs. I'll present two: using a command line tool (vobcopy) and using the transcode GUI dvd::rip. You don't have to do both :-)

3.2. ...using the command line interface

Now run vobcopy. It will automagically copy all VOBs that belong to the title with the most chapters onto your hard disk. This will copy the VOBs from the DVD and write them to the current directory (which you can alter with e.g. -o /space). They will be named after the DVD's title (e.g. I have ALLY_MCBEAL_DISC21-1.vob, ALLY_MCBEAL_DISC21-2.vob etc.). The -m switch causes vobcopy to actually mirror the DVD's contents including the .IFO files - useful because you can then use the local copy with MPlayer/MEncoder or transcode just like it was a real DVD. It will take some time. Just be patient.

Note from the author (Robos): vobcopy has some problems following angles. You might get duplicate scenes with e.g. "The Matrix". I'm working on it.

Another note from Robos: There's another new utility called dvdbackup that can also copy DVDs.

3.3. ...using dvd::rip

dvd::rip can do the same job for you.
Fire up dvd::rip by typing dvdrip. You'll see the main window. Chose Edit / Preferences and dvd::rip will come up with the
preferences dialog. Here you'll have to enter your paths. The first is the path to the DVD device and not the mount point. Often it is /dev/dvd which is a symlink to the real device, e.g. /dev/hdc.

Close that dialog. Now start a new project (File / New Project). It will start with the storage tab. Again enter the correct paths. Note how the other name fields change when you change the project title.

Change over to the Rip Title tab and press the Read DVD Table of Contents button. After a second or two the list below will be populated with the titles that are stored on the DVD. Just select the title you want to rip (you can select multiple titles by holding CTRL and clicking on them). Chose the language and the angle. Leave Specify Chapter Mode on No. Last step: press Rip selected Title(s)/Chapter(s). Again be patient. Drink some milk. Have a nice chat with your girlfriend.

The rest of dvd::rip will be covered later in chapter 4.

Back to the table of contents


4. Transcoding the DVD to an AVI

Here you really have two choices - it's either transcode or MEncoder. Both have pros and cons. Here's a very short list that is true at least for the CVS versions from April 28, 2002:

4.1. Aspect ratios

Before we start let me introduce you to the most common aspect ratios you might encounter. I'm talking about PAL here. Unfortunately I don't have that much knowledge about NTSC, so keep that in mind. DVDs are always encoded at 720x576 (5:4) although the picture will be scaled at playback. Common video formats are 4:3 = 1.33 for TV, 16:9 = 1.78 for normal cinema movies and 2.35:1 for Cinemascope.

Here is a list of common scenarios:

Don't worry if you don't understand all that at once. Take a look at dvd::rip's clipping and scaling options for a more intuitive overview.

If you want to understand what is really happening then you just have to do some math. Let's assume that the DVD is encoded with 720x576 which is 5:4, and its flags indicate that it should be played back at 16:9. This means that the player has to change the picture's aspect ratio from 5:4 to 16:9 by either scaling to 1024x576 or to 720x405. How to I calculate these values? Well I simply multiply the width with (display AR / encoded AR) which is (16:9 / 5:4) = 1.78 / 1.25 = 1.42. It's similar for the latter case. But this includes the black bars that may be present! So if your DVD cover says that the movie has an aspect ratio of 2.35 then you still see black bars on this scaled picture.

4.2. Using dvd::rip

Using dvd::rip is by far the best and easiest method to get your AVI. As stated earlier it relies heavily on transcode to do its job.

After starting dvd::rip you rip the titles you wish to transcode to your hard disk. Refer to chapter 3 for a detailed description.

4.2.1. Clipping and zooming

Now head over to the Clip & Zoom tab. Here's where you set all parameters regarding picture size and cropping (called "clipping" here). First get yourself a picture to work with: simply enter a frame number (like 200) into the Grab Preview Frame input line and press Grab Frame from ripped VOB. After a few seconds the three views below show the frame you requested.

transcode uses three steps to bring the picture to its final size: first it clips the unscaled image, then it does resizing and last it clips again. Each of this steps can be left out by selecting 0 for clipping and the original width and height for resizing. Each window shows the result of those three steps. If you want to see how big the pictures really are then just click onto any of them and a pop-up window will be opened containing the result.

You may have noticed the drop-down listbox below the three preview windows. dvd::rip offers a wide rage of presets for you to work with. Simply select one of those gives you a place to start. You can still change the values manually after selecting such a preset. All presets that are named "autoadjust..." try to guess the correct clipping regions. After selecting a preset hit the Apply Preset Values button. Now adjust the values you got until you're happy.

The big frame, medium frame and small frame parts refer to the final image size that is to be achieved. big keeps almost full DVD resolution, medium is somewhere between 500 to 600 for the width and small is somewhere around 350.

One note about resizing: Use fast resizing has a big impact upon image processing but requires that the target width and height are divisible by 32. Don't worry, dvd::rip will tell you if you can't use fast resizing. Note also that while it is possible to actually enlarge the picture I strongly advise against it. There are several drawbacks: the encoder needs a lot more bits to achieve the same quality you'd get when encoding a smaller picture and then scaling it up while playing it back, and you might even get distorted pictures (Peter Schuller reported such a case to me). Always scale down.

4.2.2. Choosing encoding parameters

We're done with this tab. Open the
Transcode tab. First decide about the video codec you want to use. If you've installed DivX5 for Linux then you can use that, but I would recommend using XviD. If you've downloaded XviD from CVS then the option to chose is xvidcvs (obviously). If transcode later aborts with some obscure error then you can try xvid.

Do you remember that I asked you to check if the video was interlaced? Now we need it. If your video is not interlaced then simply leave deinterlacing to and antialias off. Otherwise select 3 - Zoom To Full Frame. This is the slowest but best looking deinterlacer. Again here's the interlaced sample from Ally McBeal. You can see the result from 3 - Zoom To Full Frame in the first deinterlaced picture.

Another filter for deinterlacing is provided by an external plugin (don't worry you've already installed it with transcode itself). Have a look at the lower right. There's a input box labeled transcode options. All options entered here are simply passed along to transcode. We can use this for deinterlacing. Here's the same picture as above deinterlaced with other deinterlacer. This deinterlacer is faster than the 3 - Zoom To Full Frame option. If you want to use this deinterlacer then set deinterlace to off and enter -J dilyuvmmx in the input line.

dvd::rip tries to autodetect your framerate. If it failed you can correct it here. Use YUV internal should always be yes unless the output codec does not support YUV modes. XviD does. Leaving it on gives a huge speed boost. DivX multipass should be yes as well unless you only want to do a preview. For final results always chose two pass encoding. Although this is labeled DivX multipass it works nicely with XviD as well.

The audio options should be self explanatory. You chose either to reencode the audio to MP3 using the specified bitrate or to use the original AC3 sound without reencoding. AC3 audio provides surround sound and all those advantages but is bigger than MP3 sound. It's really your choice. If you use MP3 then make sure that the MP3 Quality setting is at 2. According to lame's documentation (lame is used for MP3 compression) higher quality settings like 1 or 0 - best but slower are at lot slower but do not produce significantly higher quality. The volume rescale allows normalization the audio which does not require a separate (external) program. dvd::rip automagically scans the sound and provides a rescale value.

In the upper right is the bitrate option. You can easily chose the rip size by selecting the count and size of CDs you want to use. Manipulating the Target Size or the Video Bitrate works as well. dvd::rip automatically updates the calculated values below so finding the optimal bitrate is rather easy.

4.2.3. Generating a quick preview

Most of the times you should let dvd::rip generate a small preview. You do that by providing a Frame Range. I usually take a 30 second sample which would be 750 frames at 25fps (<number of seconds> * <fps> = <number of frames to encode>) and start sometime into the movie (like 200, 300 frames). Good values might be 200 - 950. You should also give transcode a high nice level (which results in a low process priority) so it will only use spare time. If you really want your preview right here right now you can also temporarily disable DivX Multipass. Just remember to turn it back on later!

When you're done click Transcode. After a couple of minutes at most your AVI/MPEG will be ready. Now have a look at it (like mplayer my-new-file.avi). This is a good moment to see if deinterlacing works as expected and to check if audio and video perfectly synchronized. If they are, you're set. If they aren't, then read on:

4.2.4. Preventing audio/video desynchronization

If your audio and video are not synchronized in the preview (or when you play back the DVD itself) then you can give transcode a frame offset for the a/v synchronization. You do that by providing the parameter -D nr in the transcode options input line on the Transcodetab. The nr is the number of frames the audio is delayed. This number can be negative. A frame is 40msecs long at 25fps. In general the frame length is (1000 / fps)msecs long. For my Ally McBeal DVD I need a correction of -2 which amounts to -80msecs: -D -2. Now regenerate your preview video (the other parameters should still be the same) and check the audio again. If needed redo this step until you're satisfied.

4.2.5. Doing the whole thing

When the preview is fine you can start your transcode. Make sure that DivX Multipass is turned on again if you disabled it for the preview. Either click on Transcode or on Transcode + Split if you want your files to be split automatically according to the settings under Video Bitrate Calculation.

Now is really a fine time for some socialising :-)

4.2.6. For advanced users: transcode command line arguments

This chapter explains the transcode command line options used by dvd::rip. It is not crucial to the transcoding process so you may as well skip it. I provide it for those who wish to have some deeper insight into what dvd::rip and transcode do.

In dvd::rip press CTRL-t to see what the commands dvd::rip executes look like. For now let's concentrate on the last set of commands, Transcode command. Here's an example for my Star Trek: The Next Generation DVD without all those mkdir and cd commands:

  1. transcode -i /space/tng-biggoodbye/vob/004 -w 4357,250,100 -a 1 -b 128,0,0 -s 3.311 -V -f 25 -B 12,10,8 -R 1 -x vob,null -o /dev/null -y xvidcvs,null
  2. transcode -i /space/tng-biggoodbye/vob/004 -w 4357,250,100 -a 1 -b 128,0,0 -s 3.311 -V -f 25 -B 12,10,8 -R 2 -x vob -o /space/tng-biggoodbye/avi/004/tng-biggoodbye-004.avi -y xvidcvs
Let's take a look at the first command and its parameters: The second command line is not that different. It just skips all options that would discard output (like -o real-file-name and -y xvidcvs). For a more complete reference have a look at transcode's and lame's man pages.

As a last note you will find that transcode as of version 0.6.0pre6-20020529 contains support for libavcodec via a still experimental export module written by me. You can activate it by using -y ffmpeg4 (remember: libavcodec is part of ffmpeg) instead of your previous codec. dvd::rip does not support it at the moment (read: it is not in the list of selectable codecs).

4.3. Using MEncoder

As mentioned earlier there is no GUI for MEncoder at the moment. Therefore I won't provide screenshots and you have to do everything by hand. This is a process called "three pass encoding".

4.3.1. Encoding the audio

The first step is to encode only the audio. Make sure you know what audio language you want to use - you need either the audio id (which is 128 for the first stream, 129 for the second etc.) or the two-letter country code (like en for English or de for German). You can find out about these codes by running MPlayer in verbose mode: mplayer -dvd 1 -v. It should print a lot of lines. Search these for lines similar to:
[open] audio stream: 0 audio format: ac3 language: en aid: 128
[open] audio stream: 1 audio format: ac3 language: de aid: 129
[open] audio stream: 2 audio format: ac3 language: es aid: 130

Here I have three audio streams: English, German, Spanish and their IDs.

Now call MEncoder to encode the audio for you:
nice -+19 cat /space/*vob | nice-+19 mencoder -ovc frameno -o frameno.avi -oac mp3lame -lameopts abr:br=128 -alang de -
Here's an explanation for the command line arguments used:

Wait some time and you'll have your audio. MEncoder even prints some suggestions for the video bitrate:
Recommended video bitrate for 650MB CD: 1845
Recommended video bitrate for 700MB CD: 1992
Recommended video bitrate for 800MB CD: 2287

As you can see these values are rather high - but that's because an Ally McBeal episode is only 41minutes long. So I'd go for two episodes per CD and give the video a bitrate of about 1000.

4.3.2. Generating a preview (first pass)

Now's the time to decide about the video codec you're going to use. I'm assuming that AVI is the desired result with one of the different DivX encoders. MEncoder has support for DivX 4 or DivX 5 (same under Windows actually, you have either v4 or v5 running) as well as for XviD or lavc. Although most of you won't have heard of libavcodec or the ffmpeg-project before you should be advised that lavc is far superior to DivX 4 or 5 and at least as good as XviD. So I will only provide examples for lavc as you don't even need special codecs for playback: MPlayer plays them just fine (naturally), and for Windows you simply need DivX 5 (free edition is absolutely sufficient). So here we go.

Let's assemble the command line options one by one:

Put together the complete command line looks like this:
nice -+19 mencoder -oac copy -o /dev/null -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1 -vop scale=640:480 -npp lb -ss 0:20 -endpos 0:30 /space/first.vob

4.3.3. Generating a preview (second pass)

For this step we can keep most of our previous command line. Of course we change the vpass=1 to vpass=2 to tell the encoder that it's the second pass this time. Of course we should save the final output and replace -o /dev/null with something useful, e.g. -o ally-preview.avi.

Here's the command line:
nice -+19 mencoder -oac copy -o ally-preview.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2 -vop scale=640:480 -npp lb -ss 0:20 -endpos 0:30 /space/first.vob
After MEncoder finishes take a look at your preview. Adjust parameters if needed. Redo the preview until you're happy with it.

4.3.4. Generating the final AVI (both passes)

The calls for the final options simply leave out -ss and -endpos. Unfortunately MEncoder can't handle multiple input files on the command line. That's what the cat is for. Just enter:
cat /space/*vob | nice -+19 mencoder -oac copy -o /dev/null -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 -vop scale=640:480 -npp lb -
cat /space/*vob | nice -+19 mencoder -oac copy -o ally.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 -vop scale=640:480 -npp lb -

Note that -ss does not seem to work with the cat *vob | mencoder... variant. So for the preview just specify the first vob as the last argument on the command line (just look up).

Now go get a beer and a nice book.

Back to the table of contents


5. Subtitles

On a DVD subtitles are stored as pictures that are shown on top of the movie by your movie player. That way the authors have a wide choice of how their subtitles look like (and it makes subtitles in Asian languages much easier to implement). For us this may or may not be a problem - depending on whether we want to include subtitles directly into the picture of have them as a separate file/stream.

5.1. Converting subtitles to text format

Very often you don't want to be forced to see the subtitles. This is not possible if you include the subtitles in the picture during encoding. You have to extract the subtitles from the DVD into an external file/stream that the user can activate (or not). I will describe the process of converting the DVD subtitles into a text format that is widely used. Text subtitles can be easily scaled by the player (by selecting an appropriate font) and they are really small (most often below 100KB).

For this process you must have transcode and its sources. You need tccat and tcextract from transcode itself and the files in transcode/contrib/subrip from the transcode sources.

5.1.1. Compiling the tools

Unfortunately no binary package (RPM, deb) that I know of includes subrip so we have to compile and install it ourselves. But this is rather easy.

  1. Make sure you have gocr and ispell installed on your system. They come with most modern distributions. But if yours does not contain gocr then head over to its website.
  2. Change into subrip's source directory (cd transcode/contrib/subrip) and invoke make.
  3. Copy the three programs srttool, subtitle2pgm and pgm2txt to a directory in your PATH.
  4. You may have to change the script pgm2txt if your gocr does not support the -p option: at the end there are two lines containing -p ${DBPATH}. Simply remove it (after consultin gocr's manpage).

5.1.2. Extracting the subtitle stream

Here I assume that you've copied your DVD with vobcopy -m meaning that it has been completely mirrored including the .IFO files. If not then you'll have to adjust the sources.

First let's see which subtitles are available. We can use mplayer for this task:
mplayer -dvd-device /space/st-tng/disc1/ -dvd 1 -vo null -ao null -frames 0 -v 2>&1 | grep sid
This causes mplayer to just print a lot of information about the source and not to play anything at all. It should give you a list of subtitles:
[open] subtitle ( sid ): 0 language: da
[open] subtitle ( sid ): 1 language: de
[open] subtitle ( sid ): 2 language: en
[open] subtitle ( sid ): 3 language: es
[open] subtitle ( sid ): 4 language: fr
[open] subtitle ( sid ): 5 language: it
[open] subtitle ( sid ): 6 language: nl
[open] subtitle ( sid ): 7 language: no
[open] subtitle ( sid ): 8 language: sv
[open] subtitle ( sid ): 9 language: en

Now that we have the sid (subtitle ID) for the language that we want we can fire up the transcode tools and let them extract the raw subtitle stream:
tccat -i /space/st-tng/dic1/ -T 1 -L | tcextract -x ps1 -t vob -a 0x22 > subs-en
The -a 0x21 is the subtitle stream's hexadecimal number: 0x20 + sid. Here I use the English subtitles.

5.1.3. Converting the raw stream

Ok, we have a raw subtitle stream - but what can we do with it? First we have to convert each subtitle entry into a picture. This can be easily done with
subtitle2pgm -o english -c 255,255,0,255 < subs-en
Here's a catch however. With -c you can specify the grey levels used in the conversion. The idea is to make the job for gocr as easy as possible. Therefore you might have to experiment with the parameters - but this is easy, too. I've taken the following samples from my Star Trek - The Next Generation DVD:
As you can see you need a picture that does not contain outlined characters.

subtitle2pgm creates a lot of images - one for each subtitle - and a control file, called english.srtx in my case, that contains the duration for each subtitle. The next step is to let gocr recognize the text:
pgm2txt english
Be warned - gocr will ask you often about charcters that it can't recognize. This is normal. Once you're done you should run ispell over all the newly created text files:
ispell -d american english*txt
Adjust the languange to your needs, of course.

The last step is to let srttool include the actual text into the .srtx file:
srttool -s -w < english.srtx > english.srt

Voila, you have a working subtitle file. You can watch them with e.g.
mplayer -sub english.srt mymovie.avi

Back to the table of contents


6. Additional tricks

There are some more topics involved in video production.

6.1. Fixing desynched audio

This does not work with AVIs that use VBR/ABR MP3s. This step uses avisync which is part of the transcode package.

avisync is easy to use: just provide an input file (-i name.avi), an output file (-o newname.avi) and the synchronization offset in frames (-n count). From avisync's help: count>0: audio starts with frame 'count'. count>0: prepend 'count' padding audio frames. An example:
avisync -i ally-not-synched.avi -o ally-synched.avi -n -2

6.2. Splitting AVIs

This does not work with AVIs that use VBR/ABR MP3s. This step uses avisplit which is part of the transcode package. Use it only with AVIs generated by transcode.

avisplit is easy to use: just provide an input file (-i name.avi) and when it should split. You can split after a fixed size (-s size_in_megs), after a number of frames (-f f1-f2) or after a number of seconds (-t s1-s2). An example:
avisplit -i ally-big-file.avi -o ally -s 700
This will produce files named ally-0000.avi, ally-0001.avi etc. that are each 100megs big at most.

6.3. Extracting audio from VOBs/MPEGs/AVIs

MPlayer can be used easily to extract sound. The -vo null options tells MPlayer not to show the video. I'm not listing all possible options. Generally use -dumpaudio -dumpfile newaudio.extension if you want to extract the audio without processing and -ao pcm -aofile newaudio.wav if you want the WAV itself.

6.4. Using separate audio files

Sometimes you want to play another audio file along with your video. MPlayer makes this rather easy: mplayer -audiofile anotherlang.mp3 myvideo.avi plays video from myvideo.avi and audio from anotherlang.mp3. A lot of Windows media players support external audio files, too. This way you can provide several language versions as separate audio files. A combination often used is to have the AVI include the English audio track and to provide additional audio tracks in separate files.

6.5. A visual AVI editor: avidemux

If you've done video editing with Windows before you probably know the excellent OpenSource editor
VirtualDub. An OpenSource utility for Linux that aims at providing the user with a similar set of features is avidemux. You can use it in order to easily cut specific parts from a movie, to apply filters, to reencode movies and to do a lot more. I suggest you take a look at it even if using the command line is as natural to you as it is for me.

Back to the table of contents


7 Links

7.1. Libraries, codecs

7.2. Media players

7.3. Media encoders

7.4. Other documentation

Both MPlayer and transcode come with standard Unix man pages: man mplayer, man mencoder and man transcode show these pages. Additionally providing -h or --help as the only parameter to one of these programs will give you a listing of command line options (which might not be complete).

7.5. Mailing lists

I strongly suggest that you search/browse the mailing lists for information and subscribe yourself. A lot of information is available there that has not made it into the main documentation or the command line reference.

Back to the table of contents


8. Glossary

8.1. CBR, VBR and ABR

These three acronyms stand for Constant Bit Rate, Variable Bit Rate and Average Bit Rate.

With CBR the encoder spends the same amount of bits on each frame, regardless of how much it would really need. This has the disadvantage that for example complete black pictures or complete silence in an audio frame would waste a lot of bits while pictures or audio frames with a lot of elements would benefit from these bits.

VBR now takes as much bits as it needs. So black pictures get very few bits and complex pictures get as much as they need. While this provides the best quality the final size can't be predicted at all.

This is were ABR kicks in. You specify an average bit rate you want to achieve and the encoder distributes the bits it has available. Those bits it saves on black pictures it spends on complex pictures. It is a compromise between quality and size predictability.

8.2. Global Motion Compensation (GMC)

Global motion compensation (GMC) helps in zooming (bringing the camera closer) and panning (swiveling the camera), if the objects remain static in type and only change in size and position within an image. Activation of GMC is advisable if nature films or landscape documentation are to be compressed.

8.3. Letterboxing

Perhaps you've noticed that video is sometimes surrounded by black bars prior to encoding. This process is called letterboxing. It can help to maintain the correct aspect ratios for some players. Others use the black bars for displaying subtitles. The disadvantage is that these bars enlarge the picture and therefore require more bandwidth to encode although completely black parts shouldn't need much space - but the transition between the picture and the black bars does need a lot of bits that could be used elsewhere.

8.4. P/I/B-Frames, GOPs

This was taken from
doom9's Forum:

This is a quick explanation of an MPEG "GOP", or, "Group Of Pictures".

GOP:

I frame: P frame: B frame: For every macroblock in a P frame the encoder decides whether it already knows this block from the preceding frame or whether it's completely new. In the former case it only encodes the differences (INTER mode). In the latter case it encodes the whole macroblock (INTRA mode).

The situation for B frames is like this: "I don't know that block" (INTRA mode), "I know that block from the preceding I or P frame (backward mode)", "this block looks like the block in the following frame (forward mode)" or "this block looks like a mixture of the blocks from the preceding and the following frames (bidirectional mode)".

MPEG1 GOPs are always "IBBPBBPBBPBB" (this is the order in which the frames are displayed, not necessarily the order in which they were encoded/saved). MPEG2 GOPs look like that as well. They may as well contain three B frames. The DivX5 MPEG4 codec only uses "IBPBPBPBPB" because it's easier to implement and because B frame support for MPEG4 codecs is rather new. You may expect to see more B frames in the future.

8.5. Quarter Pixel (QP)

Quarter pel or quarter pixel affects the precision in filtering of macro blocks. DivX 4 works with half pel (1.5, 1.5); 1.25, 1.75, etc. are possible starting with DivX 5. Conventional division of an image into macro blocks is refined on the basis of integers - 16x16 or 8x8 - using the supplementary information from what are known as virtual blocks. This allows the motions of objects in images to be reproduced more realistically.

Back to the table of contents


9. Changelog

TODO list:
August 23, 2002:
June 3, 2002:

June 3, 2002:
May 5, 2002:
May 3, 2002:
May 2, 2002:
May 1, 2002:
April 30, 2002:

Back to the table of contents


10 About

This guide was written by Moritz Bunkus. I'm a 24 year old student of computer science at the Technical University Braunschweig, Germany. Obviously I have too much spare time to waste :-)

This is the first release of this guide. Please provide feedback - what did you like? What did you dislike? Where should I provide more information? Please also correct mistakes that I have made. And please tell me about programs / tools / scripts / documentation that I've missed. I can be reached via email: moritz@bunkus.org

Copyright (c) 2002 Moritz Bunkus.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.

Back to the table of contents