Page head image

Vacation video (pt 2)


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.
— Chris Stoddard, Linux Gazette #83

I beg to differ. But once you understand how it works, it is not hard to automate most of the annoying time consuming steps.

So I have this DVD Video compliant MPEG stream, but I'd like to have some menu. First of all, forget all the graphical frontends to dvdauthor. "Q" DVD Author sure looks nice and you can easily create rather complex menu structures, but it crashes often and there is no manual (just a bunch of more or less helpful tutorials.) It didn't fit my requirements, at least I wasn't able to define different pictures for highlighted and selected menu entries. You can define differently coloured borders or semi-transparent masks to overlay a picture, but I wanted to have a white icon turning yellow on highlight and grey on select.

I've also tried kdvdauth, gdvdauthor, and several more that were not able to properly design a menu the way I wanted it to behave. Okay, let's dig up one of the numerous tutorials from the lazyweb and do it manually.

Unfortunately, most of the tutorials don't explain why something is done a certain way. The first thing you need to know is that DVD menus are just regular MPEG audio/video tracks with subtitles, glued together with a rather simple scripting engine during authoring. That means that you just need to convert your background image to a video, encode audio, create two subtitle tracks containing the button overlays (one for highlighted buttons, one for selected, or clicked, buttons), and multiplex everything. Very simple, but with some limitations: the video has to be shorter than 30 seconds, it must have an audio substream (can be silence, though) and the button layer graphics can only have four colours at a time, including the background colour, as they are implemented as subtitle graphics.

Did I mention that it is crucial to understand that highlighting/selectable elements, also called buttons, are in fact subtitles? Okay, so here's the config file for spumux, a subtitle generator and mulitplexer:

<spu force="yes"

Our mask layer images are mask-selected.png and mask-highlighted.png. These contain all the buttons, spumux will automatically try to detect their position and geometry and enumerate them. You tell dvdauthor what these do later.

Now comes the part that needs more thought. I have a video with 34 chapters and up to six chapters per menu. This results in 6 chapter menus, not counting the main menu. The chapter menus look like this:

It's a major PITA to align all the icons for each slide just by calculating their position, thus I did it with The Gimp and multiple layers:


The additional Deselected layer makes it easy to just replace the background image by keeping the graphical elements intact.

However, exporting single layers and converting them to two bit colour depth is more work than anticipated: every other layer except the one to be exported needs to be removed, otherwise The Gimp creates a palette from the colour information of all the layers... Uargh. And besides, what for do I have a computer? But as I already have layers, and the menu generator of Premiere Elements does something quite cool with Photoshop layers, why not re-implement that?

I was too lazy to read into The Gimp's scripting engine, and ImageMagick currently recognizes only two layers of an XCF file, so I downloaded and compiled XCFTools (thank you Wikipedia for the link!) which unfortunately isn't available from the openSUSE build service (yet). The tools do not require The Gimp's libraries and can convert from xcf to png or pnm.

With that in mind, I wrote the following script to convert an XCF file to DVD menu:


# Extract background and normal overlay
xcf2png -o "$menu/background.png" "graphics/$menu.xcf" Background Deselected

# Extract and convert highlight overlay
xcf2pnm -a /dev/null "graphics/$menu.xcf" Highlighted | \
convert pnm:- -fuzz 10% -transparent black -colors 2 "$menu/mask-highlighted.png"

# Exctract and convert select overlay
xcf2pnm -a /dev/null "graphics/$menu.xcf" Selected | \
convert pnm:- -fuzz 10% -transparent black -colors 2 "$menu/mask-selected.png"

# Convert the background to an MPEG2 video
png2yuv -n 25 -I p -f 25 -j "$menu/background.png" | \
mpeg2enc -F 3 -n n -f 8 -a 2 -o "$menu.m2v"

# Adjust config file for subtitle / button layer
sed "s:mask:$menu/mask:g" spumux.xml >"$menu/spumux.xml"

# multiplex everything to a DVD stream
mplex -f 8 -o /dev/stdout "$menu.m2v" silence.mp2 | \
spumux -v 2 "$menu/spumux.xml" > "$menu/menu.mpg"

# remove temporary video (you may want to remove the PNGs as well)
rm "$menu.m2v"

The file silence.mp2 is an MPEG1 L2 audio stream with... silence, of course. Replace with something else if you want audio for your menu, it just has to be MP2 or AC3 encoded. For spumux.xml, see above. The script takes one argument, the name of the menu. If you run it as "./ myMenu", it expects the gimp file at graphics/myMenu.xcf and will write the stream to myMenu/menu.mpg.

With The Gimp and a few lines of bash script it really becomes easy to design and author menus for video DVDs. But don't ask how long it took to actually research everything.

Finally, create a configuration file for dvdauthor (see one of those other tutorials for how to do it) and author the DVD.

Comments 15 years ago

That's the reason why I just bought a Windows Software and did all the editing and authoring stuff on my girlfriend's windows laptop.
- start software
- select videos
- cut
- select menu template
- burn

Before that, I tried with DVDStyler - not as comfortable as the windows software, but works nice in general... BUT - the DVD was not playable on neither of the two DVD Players we have.
One didn't play audio, the other just stopped playing after the menu.
As DVD Players don't have a debug console I just gave up and bought that software for 20 euros... sad but true: DVD authoring sucks using Linux (and open source in general)

Link | Reply 15 years ago

You got anything out of DVDStyler at all? I didn't get that far, it just locked up when trying to author the DVD. Furthermore, the GUI is terribly unintuitive and I haven't found out how to create my own buttons. And the available documentation is sparse, as usual.

I likely would have bought another Windows tool if I had had the time. Looking back, I probably should have done so.

Link | Reply 15 years ago

You're a true masochist. Here, have this piece of glowing iron. Try poking it in your eye. Achieves the same amount of pain with less effort :)

Authoring special features such as menus, branches, multiple angles or interactive features by hand is nothing short of suicidal.

Link | Reply 15 years ago

I don't dare to even think about branches or multi-angle videos... That would require an encoder that can start GOPs at fixed frames numbers and allows much finer bit rate control than any tool available to us mortals does.

What really did hurt were my experiments with the various graphical programs to create menus. Not one of them can actually emulate the behaviour of the menu for testing, they crash a lot or create complete garbage. If they create anything at all. I lost almost
a complete day due to this pile of shitnot yet functional stuff.

In comparison, creating the small script was indeed quite easy and fast. I wouldn't want to create really complex menu structures that way, though.

Link | Reply 15 years ago

...and by pure chance I discovered that the encoder mpeg2enc of mjpegtools actually has an option to start GOPs at arbitrary frames (with --chapters) and can also create streams suitable for multi-angle multiplexes (--closed-GOPs.) I'm still not going to re-author the disc, though.

Link | Reply

New Comment


required (not published)