2. Required software
First let me introduce you to some tools you'll use.
- MPlayer is a multimedia player which supports a very broad
range of file formats and media codecs: MPEG1, AVIs
(including all Windows codecs, all DivX codecs), DVDs, VCDs, SVCDs
and so on. I use it for watching all kind of files.
- MEncoder is part of the MPlayer package and is used
for encoding video and sound. It is capable of transcoding DVDs.
- transcode is a set of tools that allow to transcode from
a broad list of formats to a broad list of other formats including
transcoding from DVD to AVI or (S)VCD.
- DVDs contain information about the titles / chapters / angles and
audio languages contained in the files. These information are stored
in
.IFO files. libdvdread is often used to parse
these files and extract the informations that are needed.
- lame (Lame Ain't an MP3 Encoder) encodes MP2/WAV audio
to the MP3 format.
- vobcopy can be used to copy VOBs from a DVD. Decryption
is done on the fly.
- dvd::rip is a graphical frontend for transcode.
- Vorbis is a new audio compressor which is superior to MP3 regarding
size and quality. If you want to use this instead of MP3 then you also
need the ogmtools which combine video and Vorbis audio.
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:
- Native codecs are normal Linux binaries (most often shared
objects, libCODECNAME.so). Support for them is trivial.
- Windows codecs are the original or slightly modified
Windows dynamic libraries (DLLs, AX and the likes). These codecs do
not work natively under Linux - you need a special library to use
these codecs. This library is called avifile. A couple of years
ago this was the only way to watch AVIs under Linux.
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:
- MPEG4 is an official video compression standard. There is no
codec whose name is simply MPEG4. If you talk about MPEG4 you don't
talk about a specific codec - you talk about a set of techniques to
compress videos. MPEG4 compliant means that a codec produces
files that can be played by other MPEG4 compliant codecs.
- DivX ;-) is the "original" hacked Microsoft MPEG4 codec that
started all those ripping frenzies. It does not support all MPEG4 features
like b-frames* or
global movement compensation (GMC
*). Some still use it
under Windows with the excellent tool Nandub. It is seldom used
under Linux because there are codecs that provide better quality. It comes
as a Windows dynamic library (
divx.dll and some others) and
requires avifile.
- DivX 4 and 5 are the official successors. DivX 5
replaces DivX 4. That's why you can't have both codecs installed
at the same time (well technically you can, but you shouldn't, for
obvious reasons). These are native Linux shared objects called
libdivxdecore.so and libdivxencore.so. This
codec is closed source. For Windows there are different versions available
and only the commercial version supports all encoding options like
b-frames*,
GMC*
or quarter PEL*. The
free version can still be used to view all files
created with even the commercial version. Unfortunately there's only
the free version for Linux which doesn't support all those nice options.
DivXNetworks are thinking about providing a commercial solution for
Linux as well. But don't expect that codec to be available soon.
- XviD (it's
DivX read backwards) is an Open
Source MPEG4 implementation that is really good considering compression
and picture quality. Support for advanced MPEG4 features
(b-frames*,
GMC*)
is being worked on or has already been implemented.
- libavcodec or short lavc is another Open Source MPEG4
compliant video codec which is superior in performance and quality to
DivX 5 and even to XviD. This codec starts to support
b-frames*. It is part
of the ffmpeg project.
- Of course there are the MPEG1 compliant codecs that you need for
VCDs and the MPEG2 compliant codecs for SVCDs or DVDs. At the moment
this guide aims at producing AVIs so I won't go into detail about
either one of these.
- Most other codecs are either outdated (like Intel Indeo 5) or
other cracked version of Microsoft's MPEG4 codec (like AngelPotion).
Still other codecs are under heavy development (like VP4) and do
not present a workable solution for us here.
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:
- MP3 is short for MPEG1 layer 3 and is an official
audio compression standard. If you talk about MP3 you actually
talk about a compression technique, not about a codec in particular. There
are more codecs for MP3 than I can name in a full day.
- lame is an acronym for "Lame Ain't an MP3 Encoder" (although
it is ;-)). It provides a encoder that produces high quality MP3 files.
Both transcode and MEncoder use lame for
audio compression.
- AC3 is again an official audio compression standard. Almost all
DVDs contain AC3 encoded audio. Today there are decoders for
both Windows and Linux that work with AC3 sound inside AVIs.
The advantage is that no re-compression is necessary (recompressing
always loses quality) and that multi channel sound (Dolby Surround and
the likes) will be preserved. The disadvantage is that AC3 sound
needs more space than MP3 encoded sound.
- Vorbis is a new Open Source audio compression. It is available
for both Windows and Linux. Its advantages are a better quality : size
ratio compared to MP3 and multi channel support. Unfortunately
you cannot safely include Vorbis audio into AVI files. Since June 2002
I've provided a tool that can join video and Vorbis audio in an OGG
container - the ogmtools. You can now take advantage of
Vorbis' superior quality under Linux as well.
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.
- libdvdread - Get it from the Ogle project page.
Note that Debian Woody already contains libdvdread. A simple
apt-get install libdvdread2 libdvdread2-dev should do the
trick.
- XviD codec - Needed if you want to use transcode.
Short instructions taken from the MPlayer documentation:
cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid login
When asked for a password simply hit enter.
cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid co xvidcore
cd xvidcore/build/generic
- Edit Makefile.linux to fit your needs.
make -f Makefile.linux
- Copy the
xvidcore/src/divx4.h file to
/usr/local/include/decore.h and to
/usr/local/include/encore2.h. Be sure to make a backup
of the files you will overwrite!
- Copy
libxvidcore.so and libcore.a to
/usr/local/lib/
For the compilation you might need a special version of nasm
which you can get
here.
- vobcopy - Get it from
the
homepage.
- avifile - As explained it is needed to access Windows
codecs for which there are no native Linux binaries. Head over to
the homepage.
Before you do that check again if your Linux distribution already
provides avifile (Debian Woody does). You still need the
Windows codecs from the avifile homepage or directly
from
MPlayer's homepage.
- DivX 5 - although this guide does not focus on DivX 5
you can get it from
http://www.divx.com/. If you have some time to spare than I suggest
that you make some comparisons between DivX 5 and XviD or
lavc and see for yourself that it is worse than the two latter
codecs.