Skip to content

Instantly share code, notes, and snippets.

@mikitsu
Last active May 29, 2024 23:22
Show Gist options
  • Save mikitsu/4bdc4cc956bed5931130a1a648b9e89e to your computer and use it in GitHub Desktop.
Save mikitsu/4bdc4cc956bed5931130a1a648b9e89e to your computer and use it in GitHub Desktop.
How to create a Video DVD with menus using dvdauthor and ffmpeg

Make DVD Videos with dvdauthor and FFmpeg

Preparation

Prepare the videos by converting them with ffmpeg

ffmpeg -i 'some input file.mp4' -target [pal-dvd or ntsc-dvd] output.mpg

Prepare a menu video any way you want (have one, cut out some sequences, ...) and also convert it. Prepare the menu images (e.g. with GIMP). You need two or three images with the size of your (converted) videos, probably 720x480 or 720x576:

  1. The normal menu view
  2. The highlight view, when hovering (you could reuse the normal view, but that may be confusing). Note you have one image with all highlights.
  3. The select view, after clicking (optional, you can reuse the highlight view)

Make sure that:

  1. the text is readable on the menu videos background
  2. the menu images have a transparent background
  3. (important!) the menu images have exactly the same pixels. This is best achieved by only having one image and changing the colors.

Once you have menu video and menu images, merge the normal menu image into the menu video (inserting your length in seconds)

ffmpeg -i background.mpg -i Menu.png -filter_complex "[0:v][1:v] overlay=0:0:enable='between(t,0,LENGTH OF MENU MOVIE)'" -pix_fmt yuv420p -target pal-dvd -f dvd merge1.mpg 

adapted from video stackexchange

While you could delete the original menu video after that, it's best to keep hold of it in case you decide to change your menu.

Config files

You will need two config files: one for dvdauthor and one for spumux (included in dvdauthor). Both are XML files.

The dvdauthor file contains:

<dvdauthor>
    <vmgm />
    <titleset>
        <menus>
            <pgc>
                <button name="b1"> jump title 1; </button>
                <button name="b2"> jump title 2; </button>
                <button name="b3"> jump title 3; </button>
                [...]
                <button name="bN"> jump title N; </button>
                <vob file="finished-menu-video.mpg" />
            </pgc>
        </menus>
        <titles>
            <pgc>
                <vob file="first-video.mpg" />
            </pgc>
            <pgc>
                <vob file="second-video.mpg" />
            </pgc>
            <pgc>
                <vob file="third-video.mpg" />
            </pgc>
            [...]
            <pgc>
                <vob file="Nth-video.mpg" />
            </pgc>
        </titles>
    </titleset>
</dvdauthor>

You can add different commands and the like, see dvdauthor(1). This config file will make a click on a menu item jump directly to the video.

The buttons are specified in the config file for spumux. It looks as follows:

<subpictures>
 <stream>
  <spu start="00:00:00.0" image="menu-image.png" highlight="menu-image-highlight.png" select="menu-image-select.png" force="yes">
   <button name="b1" x0="0" y0="NNN" x1="720" y1="NNN" up="bN" down="b2" />
   <button name="b2" x0="0" y0="NNN" x1="720" y1="NNN" up="b1" down="b3" />
   [...]
   <button name="bN" x0="0" y0="NNN" x1="720" y1="NNN" up="b5" down="b1" />
  </spu>
 </stream>
</subpictures>

Notes:

  • If you don't have a separate select image, just reuse the highlight image.
  • You can tell spumux to auto-detect buttons with autooutline="infer", autoorder="rows OR columns" and possibly outlinewidth="SOME GUESSED NUMBER" in the spu tag (see spumux(1) for details), but that might not always work
  • This config has a single full-width column of buttons (note the x0="0" and x1="720"). You can of course specify only the button area or arrange your buttons in a circle or in some other way.

Build the DVD

First, add the buttons to the menu video with spumux:

spumux -m dvd subtitles.xml <menu-video-merged-with-normal-menu-image.mpg >finished-menu-video.mpg

Output to the file name you entered in the dvdauthor config file.

Now, create the DVD file system in a new directory:

dvdauthor -o /path/to/target/dir -x your-dvdauthor-config-file.xml

If you have large videos (look at the converted size) and/or a slow disk (if you try this on a tmpfs, first calculate whether you have enough RAM), you will have to wait a while.

When the command has finished, you can burn the image to the DVD with mkisofs:

mkisofs -dvd-video -o /path/to/dvd/device /path/to/dvdauthor/output

You may want to write to an ISO file (on an existing filesystem) first to check if everything works before burning to a DVD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment