DVD Editing/Authoring/Burning with Linux

I tried to make a fancy video for my parents-in-law's twentyfifth anniversary, so here's a short summary of my experience. Many information is already available on the internet, but for other information I sometimes found nothing. Hence, I figured, put it on the web, and hopefully some people will benefit. Besides, it helps me remember most of the steps, as I easily forget what I did. I will not summarize the requirements, as they may vary. Also, I don't know what kind of machine you have, expect some heavy delays in the process because generation of mpeg streams is quite cpu-hungry, and mpeg-streams can get quite big. For the 30 min. video I made, I used roughly 60GB (yes, 60.000.000.000 bytes), including the source-footage.

Eventually, I found some sources on the dvdauthor-user mailinglist (e.g. available at gmane.org), so I'll provide some links here: dvd-slideshow to generate a slideshow from images (can do much more), dvdwizard. Haven't tested it, yet, but looks extremely good.

Video

First of all, you need some video. I took it off my mini-dv-cam, which was easy, using kino, a great non-linear video-editor. Helping you with certain effects and such is kinoplus, an effect-plugin for kino. Although, the latest releases, beware, these are alpha, work in progress etc., are to be found here.

Once you're fine with your video, you need to convert the dv-video you edited using kino (or whatever) to mpeg, which is used on DVDs. Again, kino has some great export capabilities to the mpeg2enc, mp2enc, mplex and such. You need to set format to "8 - DVD", also, it is required to set "-r 48000" in the audio - this is really required as DVDs have a different audio sampling-rate as CDs do! Additionally, because I had no constraints on space, I put some options in mpeg2enc which are said to improve quality - "-4 2 -2 1 -c --keep-hf". I don't know if it's true, because I didn't compare the results. Furthermore, the parameter -M 2 tells mpeg2enc to use two cpus, as in smp-machines. You can see the screenshot here:

kino-screenshot

At first, I did this with scene-split on, but I found on some DVD-Players that there were short distortions when the chapter changed. So I decided to use one big mpg for the movie and do the chapters with dvdauthor (see below).

Photos

Now, I wanted to add all the digital pictures to that DVD, as there was plenty of space on the disc. But it also needs additional steps to convert the images to a DVD-compatible format, which, you're right, is mpeg.

To change the images to the correct aspect-ration for tv (pal, in my case), I did

montage -geometry 720x576 -background black -quality 100 inputimage.jpg convertedimage.jpg

If there are borders to cover, e.g. for a portrait image, these will be black (-background parameter). If you want to do this for a whole batch of images, try a little more complex shell command

for i in *.JPG; do montage -geometry 720x576 -background black -quality 100 $i conv-$i; done

This will get every *.JPG file in the current directory (think of case matters!), convert it and write the newly generated image to the file conv-(original-image-name). Hence you keep the original, but also have the target.

Now we need to convert the jpeg to a proper mpeg-stream. This is done with the command

jpeg2yuv -n 25 -I p -f 25 -j conv-image.jpg |mpeg2enc -f 8 -o image.m2v; mplex -f 8 -o image.mpg image.m2v silence.mp2

This makes a 1 second yuv-stream (25 frames/second [-f 25], 25 [-n 25] frames total) of the image using progressive interleave (-I p). The second part encodes this yuv-stream to an mpeg stream, using the DVD-format [-f 8], putting the results in the file image.m2v (as this is video only, so far). Finally, we add some audio (silence.mp2) to the stream, again, using the DVD-format [-f 8]. As you would have guessed, silence.mp2 is a mp2 with silence. You can generate one yourself like this

arecord -f dat -twav -d 1 silence.wav
mp2enc -r 48000 -o silence.mp2 < silence.wav

I had some trouble piping the m2v directly into mplex, so I did the step with the intermediary m2v as a file. Use the same logic with the for-loop above for generating some more files in one step.

Photos in a slideshow

After I had all this done with all photos, I had to realize, that there is a maximum of 512 chapters/titles in dvdauthor. Hence, I had to find another solution for the 800+ Photos.

I used the dvd-slideshow mentioned above. It works like a charm. Except a few things: I do not have toolame on my box, but mplex. The dvd-slideshow (shell script) had to be changed for the test. In the appropriate if-clause it should read -n instead of -z, you'll figure it out. I mentioned this to Scott. Furthermore, only cat'ing the mpeg-files created by the script together gave me problems on one of the hardware-players I tested the resulting dvd on. I'm currently trying to get it to work with mpgtx to join all single photo-mpeg-files, but get dozens of mplex errors, like this:

++ WARN: [mplex] Video e0: buf= 237568 frame=008870 sector=00024245
++ WARN: [mplex] Audio c0: buf=   4096 frame=014783 sector=00004918
++ WARN: [mplex] Stream e0: data will arrive too late sent(SCR)=32384000 required(DTS)=31945019

This results eventually in mplex failing with

**ERROR: [mplex] Too many frame drops -exiting

but the result compiles with dvdauthor and plays fine with mplayer (I'll post the result with the hardware-players later).

Because dvd-slideshow creates a chapter-entry for each photo, I had to adjust the xml-output, as I would have ran against the same 512-chapter-limit again. I just deleted every second chapter definition in the chapter list. This just means, that the user can't go to each single photo, but only to every second. I feel this is appropriate to get everything on one dvd and just a minor issue.

Generating Menus

This was the most tricky part for me. You need an mpeg stream and you need subtitles. Documentation for making subtitles with spumux, part of the dvdauthor tools, is not very well documented in terms of examples. First, here's my sample menu.xml for spumux. As you will see, you need two images for the navigation. One for the background and one for the subtitles, which will basically show the user how to navigate (I only use highlighting). I used The Gimp to generate the images. I made it all in one xcf-file with different layers. The background is pretty easy. Just use whatever you like, put it all on one layer and save it in a jpg-file. The navigation has to be an indexed png file, max. 4 colors, if I recall correctly. These colors can be adjusted in the menu.xml, but I just used the colors I had. Don't forget to index it, otherwise spumux will spit at it. For the navigation.png define boxes aroung the text you want to higlight and e.g. fill these boxes, except the text, with some color. spumux is able to autodetect these boxes and generate everything. It is hard to describe what I exactly did to get the navigation I wanted, but I guess a little try-and-error is still needed on your side.

With these two images, we call them background.jpg and navigation.png, we need to generate the mpeg-stream in certain steps. If you change something, only the relevant steps are required to be repeated. First, we need to create a yuv-stream of the background.jpg, piping it into mpeg2enc to generate a video-only-mpeg:

jpeg2yuv -n 25 -I p -f 25 -j background.jpg | mpeg2enc -n p -f 8 -o background.m2v

Then we add the silence from above, as above:

mplex -f 8 -o /dev/stdout background.m2v silence.mp2 > nav.mpg

This is a ready mpeg-stream, and we now add the navigation as subtitle to it, using spumux:

spumux menu.xml < nav.mpg > menu.mpg

This one feeds the mpeg-stream into spumux, using the menu.xml for definitions on that to do and the output is found in nav.mpg. This can then be included for the final DVD.

Author DVD

Now that we have what we wanted, it is time to put a DVD together. We need dvdauthor for this. I found some (few!) explanations on how to use dvdauthor's commandline interface. As the recent release has support for xml-files for "scripting", I prefer this. It is easier to change some xml-file than to change some cryptic command-line. Well, for some at least. I found no xml-example on the net, so, here's my example xml.

Some of it is pretty well explained in the dvdauthor manpage, some took me a little longer to understand. I'll explain some features of this particular setup. Remember, there are many other ways to obtain the same result. the first set, the vmgm, is the top-level menu, shown when you press top-menu, or title, on you DVD player's remote. It shows the menu I called main.mpg. See above for generating menus. The buttons are defined starting with 1 and are associated with the proper entry in the menu. After I tried a lot, I found that the command "jump title 1;" works just fine to get to the appropriate title. The entry-definition to to title makes this the top-menu, pause is set to inf for infinitive. You could also do some fancy jumping, video/photo-animation.

Then there is one titleset with one title-definition. I used one source file for the video, defining the chapters right here in the xml, to avoid some distortion shown by one DVD-player I tested the DVD on. The chapters are defined starting with 0, as this is the first entry in the file and it is required. The post-command defines what to do when the movie's over. In my case, the main-menu shall be shown, hence the call to vmgm menu 1. I tried several other way's, but they didn't work well, hence I did it this way. Maybe that there are some problems arising out of this, I don't know, though (as there is a resume, and recalling some programming, call would be ended by resume, and jump would just go there).

The second pgc-definition is basically title 2 in the titleset. Different titles are defined within one title-definition using different pgc-groups. This second title uses the pause command. The pause-definition in the pgc-definition makes the player stop for 4 seconds after the last vob was played, while the pause- definition at the vob-level makes it pause after that particular file played. This pgc-group ends with the same call to the main menu as above.

Putting DVD-filesystem together

Now that we have proper definitions for making the DVD-filesystem layout, we'll just call dvdauthor to setup the DVD on our harddisk.

rm -rf dvd && dvdauthor -o dvd -x example.xml

This puts all necessary files for the dvd in the directory dvd, which is definitely emptied beforehand. Be aware of this rm -rf!

With all these files, we can generate an iso-image to burn to the DVD. But beforehand, we would like to test the files we put together, e.g. using xine (my mplayer can't do this, ogle always kept crashing here). You can try the navigation, the movie, the images, everything. And make sure all functionallity works as expected, as DVD-discs are quite expensive.

When we're happy with our layout and everything, we generate an iso-image (although some say this step is obsolete, I was always happy doing it this way). The command

mkisofs -dvd-video -o dvd.iso dvd

will generate the iso-image. Using

growisofs -Z /dev/scsi/host0/bus0/target0/lun0/cd=dvd.iso

burns it to my dvd-burner (a LG GSA-4040B, using the scsi-layer). There a other tools to burn it, I tried dvdrecord, which failed, cdrecord-plusdvd is said to have some restrictions on usage (don't know much about it).

If everything works out, you ought to be able to watch the newly made DVD-V (for DVD-Video) on your DVD-player or using your computer.

If you're interested in some more detailed information, please visit my link page.

Caveats:
I found a lot of problems while processing my first DVD, which I won't list here. And the result may look different on different hardware DVD-players. Some players use PC-style drives, while others use proprietary ones. Software within the hardware-players is different. But I'll hope that this little guide will help you creating a unique, personal DVD for your family and friends.

I would like to state that this page is intended for self-made videos only. I used a part of the tools provided on the links for debugging purpose of the resulting, self-created dvd, as it is illegal in Germany to copy anything that has some kind of protection and this protection requires some kind of "work-around-the-protection" (that's my understanding from what I've read so far in the great c't magazin).

My opinion of this law is pretty straightforward: bullshit! I'm not even allowed to make a backup copy of a cd/dvd for use in my car, to avoid ruining my cd in the car on a hot summers day, if the cd is protected by some copy-protection-scheme (even being against the cd-standard!). This is clearly a wrong-guided law, as there is a scheme in Germany to get the money to the artists/producers (don't know exactly how). Here, a part of the money you spent on empty audio-tapes (e.g.) goes to a special organization to redistribute this money to the artists. Hence, I feel I paid my dues, but now, although I pay extra-dues to the artist, I'm not allowed to make a copy anymore. Sounds crazy? It is... Well, I won't go deeper into politics (the purpose of this side is to make a dvd of your own source-footage!).

Final word: obey the law! As strange as it is, it is the law. Please let me know if there is any link which would be able to cause trouble, I will immediately remove such link (as I do no support law-breaking of any kind!).


Jens Gecius
Last modified: Mon Feb 9 18:54:54 CET 2004 Valid HTML 4.0!