This document provides the steps necessary to make a DVD which will play in a stand alone DVD player, using Linux and a DVD+RW or DVD-RW drive.

Table of Contents

1. Introduction

2. Hardware Required

3. Software Required

4. Recording, encoding and burning the video

5. Fixing audio sync problems

6. Final Note

Introduction

I am constantly amazed at how easy it is to accomplish things in Linux once someone works out the process. DVD Authoring is a good example of this, all the parts are in place, all the information is available and it is a relatively easy thing to do, but no where is there a single document showing how to accomplish it. Authoring DVD under Linux is still in its infancy, there are no tools for menus or any advanced features, for now all we can do is single straight DVD stream, which is enough for home videos and saving TV shows. I will not be discussing video editing here, I assume you will either be recording from TV or have a video tape you wish to transfer to a DVD.

Hardware Required:

I'm not going into much detail about installing the hardware, if you don't know how to install your hardware, I have provided links to articles for help.

Video Capture device: I am using a Hauppauge WinTV PCI card, TV tuner cards are cheap and easy to come by, and are well supported by Linux. There are more expensive solutions which will get you better video quality, but support under Linux varies widely. Video Applications on Your Linux Box

DVD+RW or DVD-RW drive: I am using an old Ricoh MP5120A DVD+RW drive I purchased refurbished for $150. Luckily these drives install exactly the same way as a standard CDRW drive. You also need to be able to play DVD's on you system. Please be sure your stand alone DVD player supports the format of your burner. Playing DVDs on Linux and CD-Writing with an ATAPI CDR Mini-HOWTO

Fast CPU and a huge hard drive: I am personally using an Athlon 1600XP, 384 MB of RAM and a 40 GB hard Drive. I probably wouldn't even attempt this with less than 1 Ghz CPU and 20 GB of free hard drive space.

Software Required:

Each of these packages has their own install process, please follow the instructions for each individual package.

xawtv comes with streamer, which we will use for recording the video: xawtv

mjpeg-tools is used for encoding the recorded video into a DVD compatible format: mjpeg-tools

dvdauthor is the key piece of software, without it, we would not be able to do this. This package generates the IFO files required by DVD player. There is no automatic install for this program, simply run make, then copy the binaries to /usr/local/bin: dvdauthor

dvdrtools is a fork of cdrtools which we will use to build the iso and write to newer DVD-RW drives: dvdrtools

dvd+rw tools is used to burn to older DVD+RW format, this is only necessary if you have a first generation DVD+RW drive. If you have a newer DVD-RW drive this package is not needed: dvd+rw tools

The -n switch is for format, if you use PAL, change ntsc to pal. The -t switch is record time in minutes. -s is the size of the video, in the USA, we use NTSC which requires the video to be 720x480 if you use PAL, change this to 720x576. -r is the frame rate, for NTSC use 30, for PAL use 24, -c is the video device, change it if need be. The rest of the switches should remain unchanged.

The next thing to do is to properly encode the audio and video into something a DVD player can read. The tools we need for this are from mjpeg-tools. This command line strips the audio out of our avi file and encodes it to mp2 audio. The -V switch actually is for VCD compatibility, but works for us here:

lav2wav +p stream.avi | mp2enc -V -o audio.mp2

Next we strip out the video and encode it to mpeg video. This part is what takes the longest, the faster your system is the better. The important switches here are -f 8, which ensures the video will be DVD compatible and -n n, which is for NTSC, if you are using PAL change it to -n p:

lav2yuv +p stream.avi | mpeg2enc -n n -f 8 -s -r 16 -o video.m1v

Now we need to join the two encoded files. Be sure to use the -f 8 switch for DVD compatible video:

mplex -f 8 audio.mp2 video.m1v -o complete.mpg

In order for our disc to be played in a stand alone DVD player, the directory structure HAS to be perfect, so please make sure you type the next several commands exactly as shown, in the order shown:

mkdir dvd
mkdir dvd/VIDEO_TS

Next we need an Table of Content IFO file, type:

tocgen > dvd/VIDEO_TS/VIDEO_TS.IFO

Now we want to copy our encoded video file into the structure and give it the correct permissions, type:

IFO and BUP files provide DVD players with information specific to the video file it is trying to play, ifogen looks at the video and extracts the information needed. To generate the needed files use this command line:

Now we need to generate an iso image which can be burned to a DVD disc. Be sure you are using mkisofs version from dvdrtools, which supports the DVD files system:

mkisofs -dvd-video -udf -o dvd.iso dvd/

And, finally, we can burn our disc. If you are using an older first generation DVD+RW drive, the disc will need to be formated before the image can be burned, use the following commands, replacing srcd0 with the device name of your drive:

dvd+rw-format -f /dev/srcd0
growisofs -Z /dev/srcd0=dvd.iso

If you are using a newer DVD-RW, no formating is necessary, dvdrecord will do the job:

dvdrecord -dao speed=2 dev=0,0,0 dvd.iso

Fixing audio sync problems

The most common problem with this process is audio sync. The first thing you should try is optimizing your hard drive with hdparm, turn on 32 bit I/O and DMA, it looks something like this:

hdparm -c 1 -d 1 /dev/hda

Next, load the bttv driver with the gbuffers=10 option:

modprobe bttv gbuffers=10

This should fix any audio sync problems, if it does not, you may need to use the -O n option when running mplex. This delays the video by n mSeconds. The problem with this is it is a trial and error process and often leaves the joined video file in a state that causes ifogen to segfault. It may also be possible to record the video at a lower size, say 352x240, then use yuvscaler from the mpjeg-tools to resize it to 720x480, but I have not tried this.

Final Notes:

This process will not give you "Buy in the Store" DVD quality video, the quality will depend largely on the quality of your capture source, so you should use the best quality settings you can when recording anything on video tape you intend to burn to DVD. This process takes several hours, I use the shell script below to do the work for me, while I am at work or in bed sleeping. 100 minutes of video will require about 11 GB to record, 2 GB to encode and 1 GB for the iso image. Your mileage will vary.