Up one level
Ripping, Encoding, and Burning CD and DVD media in Debian Linux
Spencer Stirling

Ripping CD and DVD media to ISO images
This can be done in a variety of ways. Here's how I do it. I put the disk in the drive (obviously). I wait for KDE (or GNOME) to recognize it and ask to mount it - I always cancel this operation.

The next step always seems to be necessary, but I don't know why. I PLAY the CD or DVD for a few seconds (if it is a video/audio disk). If it is a data disk then I don't bother. For example, if it is a DVD then I open up "xine" and press the DVD button and let it play for a few seconds, then I close "xine".

I then open up a command prompt and copy the DVD with this command:

dd if=/dev/dvd of=myfile.iso
Obviously you'll have to change your /dev/dvd to whatever your DVD/CD device is.

Ripping and Encoding CD media
The best software that I have found for ripping->encoding your Audio CDs into mp3 or OGG (recommended, and better) is either KAudioCreator or Grip (both easily available from the official Debian repositories). UPDATE: K3B is now my favorite program for this. There's not much to say about this EXCEPT the following: if you want to encode in Ogg/Vorbis format THEN you should install the "vorbis-tools" package by typing

apt-get install vorbis-tools

If you want to encode in MP3 then you'll have to work a BIT harder. Since the MP3 format is crawling with a stinky stew of legal morons, you'll need to download the "lame" package (which is NOT available through the official Debian repositories). Instead add the following lines to your "/etc/apt/sources.list" file:

deb http://www.debian-multimedia.org/ stable main
Then you can install lame with the commands
apt-get update
apt-get install lame

Ripping and Encoding DVD media with Dvd::rip
The following has been tested with the "lenny" distro (current as of September 2009). However note that the version of ffmpeg (3:20080706-0.3lenny1) in the unofficial repository

deb http://www.debian-multimedia.org/ lenny main
is BROKEN. Hence things must be installed in the FOLLOWING ORDER: first put the official Debian "lenny" repository in your "/etc/apt/sources.list" file WITHOUT THE debian-multimedia.org repository, i.e. include ONLY this line:
deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
Then install the relevant packages with the commands
apt-get update
apt-get install ffmpeg
apt-get install vorbis-tools
apt-get install mkvtoolnix
apt-get install mkvtoolnix-gui
apt-get install ogmtools
Second add the multimedia repository in your "/etc/apt/sources.list" file:
deb http://www.debian-multimedia.org/ lenny main
deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
Install the remaining packages with the commands
apt-get update
apt-get install dvdrip
apt-get install transcode
apt-get install lame
apt-get install rar-2.80
apt-get install subtitleripper
Let me give the relevant versions for trouble-shooting:
dvdrip		0.98.9-0.0
transcode	1.0.7-0.0
vorbis-tools	1.2.0-5
lame		3.98.2-0.4
ffmpeg		0.svn20080206-18
ogmtools	1.5-3
rar-2.80	2.80-2
subtitleripper	0.3.4-0.6
mkvtoolnix	2.0.2-1.1+b1
mkvtoolnix-gui	2.0.2-1.1+b1
You can check these versions on YOUR install using commands like
dpkg -l | grep "ffmpeg"
Now you MUST make sure that your machine can PLAY dvds correctly... see my Xine Howto for that (in particular you need the libdvdcss2 package).

Before we begin ripping and encoding, let's lay down some groundwork for what FORMATs we should use. Here I will ONLY support Open Source formats.

Container format
The "container" is not a video format, but rather a "box" in which to put a bunch of tracks. For example, the popular (but inferior, and NOT Open Source) Microsoft AVI file is a "container". Within that file sits the actual video, audio, and maybe subtitle formats. There are TWO good Open Source containers that WE SHOULD USE:

OGM (Vorbis) or MKV (Matroska) (better)

The OGM format is what the Vorbis team (of OGG audio fame) has founded as a container. This container can contain video, audio, and subtitles, although it cannot contain the "vobsub" subtitle format, which is a REAL pain - more about that later. The MKV format is the most advanced container format. The only annoying thing is that dvd::rip doesn't encode directly in MKV (I have NO idea why), so we'll have to do some postprocessing.

Video format
There are MANY video formats (called "codecs") out there. The best codecs (these days) are different attempts to implement the so-called MPEG4 standard (which is NOT a codec, but a STANDARD). The Microsoft codecs are called DIVX, although this is obviously proprietary. Again, I'm trying to avoid them, so I'll pick from one of the following OpenSource codecs: FFMPEG (better license) or XVID (which is obviously DIVX spelled backwards). Here I'll use FFMPEG.

Audio format
You already know what an mp3 is, and you probably already know what the legal issues are concerning that pile of junk. The Vorbis team has a (better, actually) standard called OGG. I'll use that here. Unfortunately (as far as I know) this will downmix your 5.1 channels (usually AC3 or DTS) into a 2-channel stereo compressed format. You can choose to just pass through the AC3 (or DTS) signal - it's bigger, but at least it lets you keep the 5.1 channel sound (I think - to be tested).

Subtitle format
There are (as far as I know) two decent formats for subtitles. The first is called the Vobsub format which pulls the subtitles from the DVD in graphical format (it is a sort-of MPEG file, actually). Usually this comes as *two* different files, one with a ".idx" extension and the other with a ".sub" extension, although oftentimes these files are zipped together into a ".rar" file (more about that later).

The other subtitle format (the Windows Subrip format) has the extension ".srt", and this is just plain text. Usually these files are generated from a Vobsub file using some kind of Optical Character Recognition (OCR), although this seems to be more of an art than a science. I will not discuss any further here how to generate ".srt" files, although the package "gocr" might be useful to you for such things.

Now Vobsub files CANNOT be put in OGM containers (however SRT files can). This usually means that if you want to distribute an OGM file then you will also have to distribute a Vobsub ".rar" file along with it. This is a pain for two reasons: two files is worse than one for distribution; only MPlayer can play the *separate* ".rar" Vobsub files (Xine pukes, maybe VLC can take it). Furthermore the ".rar" files MUST be encoded with rar 2 format (you probably have rar 3 on your distro). Hence you will have to install a separate (older) rar compression utility. Very primitive.

All files can be put into MKV containers (we're starting to see the advantage already), so this will be our goal. Unfortunately we'll have to do the original encoding into the OGM format with separate subtitle files and THEN convert into MKV format.

With "dvd::rip" it took me a lot of tries to figure out what works/what doesn't. First create the project. Make sure that the directories that you configure have PLENTY of room. For our example I'll use


In the "Storage" tab you can specify the source however you want. If the DVD is in the drive then just select it. I always manually rip my DVDs (ahead of time) into ISO images using "dd" (see the first paragraphs of this page). When I'm ready to encode I mount the ISO image file via loopback, e.g. (as root)

mount -o loop myfile.iso mymountdirectory
Then I select "mymountdirectory" in dvd::rip with the "Choose DVD Image Directory" button. IMPORTANT: you should choose the "Copy data from DVD to harddisk before encoding" option. TRUST ME... even if the data has already been ripped to an ISO image.

Rip Title
Push the "Read DVD table of contents" button. You can select multiple tracks if you want and start the rip by pushing the "Rip selected title(s)/chapter(s)" button. VERY IMPORTANT TIP: If you are ripping and encoding MULTIPLE tracks from a DVD (i.e. you have more than one track selected in the "Rip Title" tab), then when you set up "Clip and Zoom", "Subtitles", and "Transcode" (see below) you need to repeat the settings for EACH TITLE SEPARATELY. When you finally hit the transcode button it will work on all of them in sequence (all night long). If you don't configure each title separately then your settings will only apply to the first one in the list. The rest will use the defaults. I wasted a whole night of transcoding on this. AHHHHHHHHH.

VERY IMPORTANT TIP: There is a serious bug in dvd::rip (if you want any subtitle options, which I recommend). You will need to mount the original DVD (or ISO image, as done above). In the VIDEO_TS directory you will find a bunch of files named VTS*.IFO. You need to copy them into the project's tmp/ifo directory. In our example the commands are
cp mymountdirectory/VIDEO_TS/VTS*.IFO /home/jerkuser/dvdrip/stupidmovie/tmp/ifo

Clip and Zoom (Cropping and Resizing)
There are several different aspect ratios that you'll likely encounter, and some are listed as follows (width/height). I will concentrate on DVDs encoded in NTSC format. I haven't had a chance to play with PAL DVDs or Blueray (high def) yet.

4/3=1.33:1 at 720x480 (NTSC Standard Television). Note that 720/480=1.5:1, NOT 1.33:1. This is because the "pixels" in TV are not square (note: I don't think this applies to modern HD TVs anymore), but are actually slightly rectangular (about 13% taller than square). Hence a 720x480-pixel frame size gets rendered at a 4/3=1.33/1 aspect ratio on older standard TVs!

16/9=1.77:1 (Widescreen TV). This is STILL delivered at 720x480 but the image is "squeezed" in horizontally. Assuming square pixels (i.e. a computer monitor) the image must be expanded to 848x480 to get the correct 16/9 aspect ratio. The actual details of how this aspect ratio is achieved depends highly on the DVD Player/TV combo (i.e. with older televisions the DVD Player would have to compensate for the non-square pixels and the 4/3 viewing area).

1.85:1 (Academy Flat movie format - wider than widescreen)

2.35:1 (CinemaScope movie format - even WIDER still)

If you live in the US you'll receive the DVD images in NTSC 720x480 format (if you live elsewhere then you probably will get PAL format, which is a bit different but similar - I think the odd-shaped TV pixels are different for PAL, too. Google for details. What I describe here, however, is enough information for you to figure out how to crop ANY movie in ANY format). Obviously movies are filmed in (usually) 1.85:1 or 2.35:1 aspect ratio, so clearly the 720x480 DVD frame size isn't WIDE enough (or is too tall, depending upon how you look at it) to render the movie appropriately. This is handled ON THE DVD ITSELF in 1 of 3 ways (starting from the worst, getting to the best):

(1) The sides of the movie are CUT OFF - this is called Pan and Scan ("Fullscreen") and it sucks

(2) The movie is "letterboxed", meaning that big black empty areas are put on the top and the bottom and the movie is uniformly "shrunk" until it fits into 720 pixels across. For a 2.35:1 movie (taking into account the non-square pixels) the movie will be stored as a 720x270 "floating box" in the middle of the regular 720x480 frame. This is how the movie is encoded on the DVD, which is a HUGE waste of space (but better than cutting off the sides). For a 4/3 TV this is what must be done eventually anyway, so it probably doesn't matter much. For a widescreen TV, however, you will probably be forced to put the TV in a pseudo-4/3 format (puts black bars on the sides and displays the image in a 4/3 virtual box in the middle - this will make the entire movie look like a little postage stamp surrounded by black bars on ALL sides).

(3) The movie is "anamorphic", meaning that the movie is squeezed in horizontally. This is just the way that widescreen TV is encoded anyway (see above), so this works WELL. Since widescreen is 16/9 and the NTSC signal is 720x480 the image will be stretched horizontally to render the image appropriately on a widescreen TV. For older 4/3 TV the opposite is done: the DVD *player* COMPRESSES the image VERTICALLY and adds black bars on the top and bottom (otherwise everything looks too skinny). This gives pretty much the same results on a regular TV as the "letterbox" method above. (Your player must be told to deliver the signal in 4/3 "letterbox" to do this).

Anamorphic format is the best because it uses the maximum amount of DVD data space to its fullest advantage - giving you the highest amount of "information" - hence the highest fidelity image. For regular TV it probably doesn't matter much (still go with the anamorphic, though - it costs no more, and it IS the standard now), but for widescreen it IS a big deal.

It is clear that even with anamorphic "stretching" most movies will have black bars on the tops and bottoms EVEN ON THE DVD (since movies are usually wider than even the "widescreen" TVs). So it is true that SOME space is being wasted, but not nearly as much. Let's see how much. The NTSC frame on the DVD again is 720x480. This gets stretched by 33%. So (taking into account the non-square TV pixels) a 2.35:1 Cinemascope movie is encoded on the DVD as a 720x360-pixel floating image in the 720x480 frame. Clearly this is much more DATA than the 720x270 "letterboxed encoding" method.

A similar bit of logic applies to movies encoded in 1.85:1 format. The actual movie will be a 720x456-pixel floating frame in the 720x480 NTSC frame. HOWEVER this is NOT ALWAYS TRUE. It seems that some jackasses see how "close" 1.85 is to 1.77, so instead of encoding the movie at the correct 1.85:1 aspect ratio they crop a bit off the sides and make it 1.77:1 - filling the entire 720x480 pixels (but losing some data on the sides). Some losers just can't stand to have black bars (no matter how thin) on their widescreen TVs!!!

What this all means (for anamorphic formats)!
In dvd::rip first select the DVD title that you want to work on (on the top). I prefer to set the "Presets" to "No Modifications" - I like to do it myself (thank you). I first clip off the black bars on the top and bottom. Then I resize. Usually I try to keep the pixel measurements as a multiple of 8 to allow for the "fast resizing" algorithm in transcode/dvdrip:

I first crop 60 pixels off the top AND bottom to give a 720x360 picture. I like to keep the maximum number of lines (hence all the hype with 1080p), so I "zoom" the 720 up to a number which makes the ratio be 2.35:1. So I use an 848x360 frame. For lower quality I zoom down to a 720x304 frame. Notice that I didn't correct for the crazy odd-shaped TV pixel size here because now I'm sticking the movie on my computer, which has SQUARE pixels. So I guess you didn't need to know any of the above junk (although it can be confusing if you don't realize that TV pixels are non-square and you know how to do 3rd grade math)

The method is similar. If the movie is formatted at its proper 1.85:1 format then (when played through the computer this is easier to see) very skinny black bars should appear on the top and bottom. This is GOOD!!! In this case I do the following: I first crop off 12 pixels from the top AND the bottom (cut off the black bars) - reducing me to a screen that is 720x456. Then I zoom up to an 848x456 frame. For lower resolution try 720x392.

1.77:1, aka 16/9
If there are NO black bars on the top and bottom then the movie has been encoded at 1.77:1 (16/9). In this case no cropping is necessary, but I scale the 720x480 up to 848x480. For lower resolution try 720x408. Hopefully the movie was originally filmed at 1.77:1 (like HBO films), but more likely it has just been cropped. Either way there is nothing to do about it.

Finally, for a 4/3 movie I scale the 720x480 screen down to 640x480 for a 4/3 image on a screen with square pixels.

In dvd::rip first select the DVD title that you want to work on (on the top). Select the subtitle that you want to include (for multiple languages I'll let you figure it out). DO NOT render the subtitle directly on the movie... then you'll never be able to turn it off. At the bottom of the screen under the heading "Create vobsub file" select the "Create later after transcoding" checkbox. Note that you can always come back later (after transcoding) and do a "Create now" process if something goes wrong with the subtitles.

Now go into the "Transcode" tab. First, set your "Container" to OGG. I like to use the following settings (leaving everything else default)

Video options:
codec: ffmpeg  (or xvid sometimes)
2-pass encoding: YES
Deinterlace mode: Zoom to full frame (slow)
Video bitrate calculation:
By quality (BPP value): (use pulldown box) 0.25=VHS (good) quality, 0.5=DVD (better) quality
I usually use BitsPerPixel (BPP)=0.25 ...

Now for the audio: if you are not keeping the 5.1 channel AC3 or DTS then in the "Audio" box select "Vorbis". You can change your bitrate preferences: 128kbps is BARE MINIMUM, 160 is fine, 192 is better (beyond that I don't believe any human can detect the difference... still many go for 256kbps).

Audio options:
bit/samplerate: 128 kbps (min), 192 kbps (preferred)
Finally the extra options
Preview window: NO
PSU core: YES (corrects for NTSC A/V sync problems, however sometimes CAUSES these problems).

Before you click the "Transcode" button you should check the "split files on transcoding" checkmark if you set up for multiple split files. Start the transcoding and go to bed.

Converting OGM to MKV
At the end of the process, in the "avi" subdirectory of your dvdrip project you will have files with ".ogm" (and ".rar" extensions, if you used subtitles). First, you should "unrar" the rar files (this extracts them into files with ".sub" and ".idx" extensions)

unrar e stupidmovie-001.rar
Now open up the MKV converter tool
provided by the "mkvtoolnix-gui" package. In "add" you should add both the movie .ogm file and the subtitle .idx file (this will pull the .sub file automatically).

Under "Tracks" scroll down the list of files (it's a very small scroll) until you see the Vobsub file - probably the last one. Click on it (but NOT on the checkmark... make sure that it stays checked!!!). In "General track options" make sure that the "Default track flag" option is set to "NO". Otherwise the subtitles come on by default every time you start the movie.

Now start the muxing... it's very fast and produces an .mkv file in the same directory where the .ogm and .idx files are (e.g. /home/jerkuser/dvdrip/stupidmovie/avi/001/). That's IT!

Burning CD and DVD media with K3B
By far the best software for burning CDs is k3b (part of KDE). It just seems to be the most stable, most options, etc. I used to use Gnomebaker, but I often had problems with it crashing. Since I haven't had problems with k3b there isn't much to say (except: install it).

Note that K3B claims to burn DVDs with no problem, although since I haven't actually tested that yet (haven't found the need so far) I cannot comment - it probably works (although, as usual, nothing is ever as easy as it seems).

This page has been visited   times since December 04, 2005