Linux DevCenter    
 Published on Linux DevCenter (
 See this if you're having trouble printing code examples

Create Self-Booting Movie CDs

by Robert Bernier

I love my son and try to give him what he needs in life. Sometimes I even give him what he wants, too. He has a nice bike that he uses quite a lot, and he is always out and about. Of course he has his own PC, which is online 24/7 while he constantly surfs for sports car images. For some strange reason, the teachers at his primary school thinks he's some sort of genius, as he's always telling them that Windows sucks and the TCO is much less when using Linux. At times I think I let him have too much; I have let him play games on a Windows machine. Then, of course, at age 11 he broke my collarbone and all I did was lecture him on his propensity for causing "incidents."

However, sometimes I put my foot down. One example involves my DVD collection. I don't trust him with those little discs of plastic and dreams. We sometimes have debates about what he's allowed to watch, and often he wants to take my DVDs to a friend's house, which I absolutely forbid. What's a father to do?

The answer is to make a copy to watch on the PC.

Before diving into the guts of the article, please keep in mind that I'm not suggesting you do anything illegal. I shudder to think that some evil person will impoverish an unassuming multinational corporation by depriving it the opportunity to make a small profit off a piece of entertainment geared for the unwashed masses. That's why the United States has such wonderful laws protecting companies' rights. (Did I tell you that I live in Canada?) Instead, I implore you to use the following approach only for DVDs unencumbered by licensing issues.

Creating a movie involves a few software and hardware considerations:

  1. The PC that plays the movie must have a CD reader as its primary boot-up device. It should have a Pentium III or better CPU.
  2. The PC used to create the movie must have a DVD reader, a CD burner, and at least 2GB of free space.

Making these movie backup copies requires several distinct utilities, including:

It looks pretty daunting, doesn't it? Just look at all those utilities that you need to create your movie.

Actually, you can make things work with very little knowledge by using one more utility that ties all of the above together: K3b. K3b is a CD- and DVD-burning application for Linux systems optimized for KDE. It provides a comfortable user interface for performing most disc-burning tasks.

The Moviemaking Routine

Here are the steps you should follow:

  1. Read the DVD and convert it into an AVI.
  2. Break the completed AVI into files small enough to fit onto a CD.
  3. Use K3b to create a new eMoviX project/CD for each AVI volume.
  4. Burn away.

Now let's start putting the pieces together.

Ripping the DVD Using Mplayer

Of all the utilities, Mplayer is not only the most critical but also the trickiest to set up and use correctly. There are lots of good references, including the Mplayer home page and, from this site, Video Playback and Encoding with MPlayer and MEncode and DVD Playback on FreeBSD.

Note: Adding to the complication is the fact that several Linux distributions don't supply Mplayer. Those that do tend to hobble its capabilities in order to avoid running afoul of legal restrictions. The best approach is to download Mplayer directly from its web site. You'll also need to download the required codecs (a form of technology used to compress and decompress video data) too.

First, install the codecs on your machine, usually to /usr/local/lib/codecs/. Then configure and compile Mplayer.

Ironically, for all Mplayer's complication, you can create your AVI by using this one incantation from the command line:

/usr/local/bin/mencoder dvd:// -o temp.avi -ovc lavc \
	-lavcopts vcodec=mpeg4:vhq:vbitrate=1800 -oac mp3lame -lameopts \
	cbr:vol=3 -aid 128

Let's break down the above command.

It's a good idea to test the command first, since the encoding process will take several hours. The most common encoding mistake involves recording the sound improperly, and you'll hate to find out you'll have to repeat the wait. Doing a test recording is pretty simple. Add the following switches to the above command invocation:

-endpos 30 -ss 00:10:00

This will cause Mplayer to record for a period of 30 seconds at about 10 minutes into the DVD recording.

There's often more than one track on a DVD. You might want to record something other than the first track. The easiest solution is to simply play the tracks until you find the one you're interested in. For example, mplayer dvd:// plays the first track by default; mplayer dvd://1 plays the first track explicitly; and mplayer dvd://2 plays the second track explicitly.

There's more than one command incantation that will create an AVI. It's all a question of experimenting with the different video and audio codecs. For example, you can restate the command where it copies the audio stream directly into the AVI without converting it to MP3:

/usr/local/bin/mencoder dvd://1 -endpos 30 -ss \
	00:10:00 -o temp.avi -ovc lavc -lavcopts \
	vcodec=mpeg4:vhq:vbitrate=1800 -oac copy -aid 128

This incantation will normally result in a 1.4GB AVI.

Play back the ripped recording by running Mplayer:

mplayer temp.avi

Breaking Up the AVI

The transcode suite of utilities is ideal for video stream processing. That's exactly what we want to use here.

Transcode doesn't require too much in the way of existing libraries to compile; however, you should pay close attention to the summary printed at the end of the configuration to see exactly what libraries it has found and what the resulting binary can do. Refer to Table 1 for an example output. You may have to play with the configuration paths if transcode doesn't find libraries that you know exist on your system.

Summary of transcode 0.6.11 features
Static AV-frame buffering yes
Support for network (sockets) streams yes
DVD navigation support with libdvdread no
Link against local Lame library (>=3.89) | ver no | static
pvm3 support no
nasm-dependent modules (bbmpeg) yes
mjpegtools-dependent modules no
libdv-dependent modules no
Ogg support | Vorbis support | Theora support yes | yes | no
Default xvid export module xvid2
liba52 audio plugin (>=0.7.3) | default decoder no | yes
avifile API supportno
ImageMagick-dependent modules (>=5.4.3) no
libjpeg-dependent modules | mmx accel yes | no
liblzo-dependent modules no
libxml2-dependent modules no
Experimental v4l support yes
Experimental lve support no
libmpeg3-dependent modules no
libfame video encoding plugin no
QuickTime-dependent modules no
libpostproc-dependent filter plugin no
X11-dependent filter plugins yes
freetype2-dependent filter (filter_text) no
Table 1. Transcode configuration summary information

Once you've compiled and installed transcode, you can run the tcprobe utility on your newly created temp.avi:

tcprobe -i temp.avi

The following example output shows the kind of information that you should receive:

$ tcprobe -i temp.avi

[tcprobe] RIFF data, AVI video

[avilib] V: 29.970 fps, codec=DIVX, frames=135989, width=720, height=480

[avilib] A: 48000 Hz, format=0x2000, bits=16, channels=2, bitrate=448 kbps,

[avilib] 9076 chunks, 254128000 bytes, CBR

[tcprobe] summary for temp.avi, (*) = not default, 0 = not detected

import frame size: -g 720x480 [720x576] (*)

frame rate: -f 29.970 [25.000] frc=4 (*)

audio track: -a 0 [0] -e 48000,16,2 [48000,16,2] -n 0x2000 [0x2000]

bitrate=448 kbps

length: 135989 frames, frame_time=33 msec, duration=1:15:37.504

Transcode includes a utility called avisplit for splitting AVI files into chunks of a maximum size. This example command breaks temp.avi into chunks no larger than 640MB apiece:

avisplit -s 640 -i temp.avi

In this case, it creates two files, temp.avi-0000 and temp.avi-0001. Remember to check them out by playing little snippets at different points in the movie, say at the beginning and end of each file.

Creating the ISO

At this point you're now ready to create the self-booting movie ISO. It'll take several utilities to do this, but that's where K3b comes in.

The first thing to do is to ensure that K3b sees all the requisite utilities, as seen in Figure 1. Launch the program, go to the Settings menu item, and click on the Configure option. You won't need all of the utilities listed here, but you'll certainly require those listed at the beginning of this article.

the K3b configuration window
Figure 1. The K3b configuration window

Figure 2 shows a snapshot of a new eMoviX project. Choose the eMoviX project that suits the medium to which you are burning. You may have a DVD burner, but be sure to select a CD project if the recording medium is a CD-R.

creating a new eMoviX project
Figure 2. Creating a new eMoviX project

Using K3b is a fairly intuitive process. When you run the program, you'll first see three panes. The top right one shows the files, defaulting to your home directory. From this pane you can navigate to the AVI files. Now drag and drop the first ISO image into the bottom pane. You can bring up the Burn window by clicking on the Burn icon, selecting Project -> Burn from the menu, or pressing Ctrl-B to start the burn process. The Burn window, as shown in Figure 3, provides you the opportunity to fill out the information to include on your CD as well as how the movie should start and what should happen when it finishes. Take a minute to tab through all the options. It's pretty cool what eMoviX can do.

The K3b burn window
Figure 3. The K3b burn window

I don't change much of anything except for the volume description and whether I want the system to eject the CD or shut down the system after the movie ends. When you're satisfied with your options, click on the Burn button to begin the burn process.

That's it, folks! Repeat the process for the next images until you have completed burning your CD movie.

Using the CDs

Put the first CD in your disc tray and boot the machine. The CD's isolinux OS will take care of the rest. Notice that you can interrupt the boot process to the CD's BusyBox shell.


They're aren't any!

One More Trick

I like using an image from the movie as my label for the CD jewel case. I use Mplayer to screen-capture an image:

mplayer dvd:// -ss 00:10:00 -vo jpeg

This example command will begin screen-capturing several frames per second, beginning 10 minutes into the movie. You will end up with a collection of numbered JPEG images in the directory where you invoked Mplayer. Press Ctrl-C as soon as you've collected enough images to choose from.

Now load them into your favorite graphics package. I use display from the imageMagick graphics suite because I can load them all with one command:

display *.jpg

Select the one you would like to use, print it, fold the paper, and you're done.

Robert Bernier is the PostgreSQL business intelligence analyst for SRA America, a subsidiary of Software Research America (SRA).

Return to the Mac DevCenter

Copyright © 2009 O'Reilly Media, Inc.