mathr / blog / #

Soft Rock EP DVD HOWTO

I finally finished the DVD I've been working on, using only Free/Libre Open Source Software. Here's a quick outline of the method used to make it.

0. Menu

For maximum compatibility with DVD players, the menu background video must be a multiple of the GOP (group of pictures) size (15 frames long for PAL, and I think 18 frames for NTSC).

DVD/1_0_SoftRockEP/Makefile

all: 1_0_SoftRockEP.mpg

1_0_SoftRockEP.mpg: spumux.xml menu.mpg buttons-blue.png buttons-green.png buttons-red.png
	spumux -m dvd -s 0 -P spumux.xml <menu.mpg >1_0_SoftRockEP.mpg

menu.mpg: audio.mp2 video.m2v
	mplex -f 8 audio.mp2 video.m2v -o menu.mpg

audio.mp2:
	dd if=/dev/zero bs=4 count=86400 | toolame -b 128 -s 48 /dev/stdin audio.mp2

video.m2v:
	cd PNG &&../png_to_m2v.sh

DVD/1_0_SoftRockEP/png_to_m2v.sh

ls | xargs -n1 pngtopnm | ppmtoy4m -F 25:1 -S 420mpeg2 | mpeg2enc -f 8 -a 2 -o ../video.m2v

DVD/1_0_SoftRockEP/spumux.xml

<subpictures>
 <stream>
  <spu
   start="00:00:00.00"
   image="buttons-blue.png"
   highlight="buttons-red.png"
   select="buttons-green.png"
   force="yes"
  >
   <button name="magma"     x0="16"  y0="16"  x1="176" y1="144" up="magma"     down="playall" left="magma"     right="lavaflow"  />
   <button name="lavaflow"  x0="192" y0="16"  x1="352" y1="144" up="lavaflow"  down="playall" left="magma"     right="quicksand" />
   <button name="quicksand" x0="368" y0="16"  x1="528" y1="144" up="quicksand" down="playall" left="lavaflow"  right="nucleus"   />
   <button name="nucleus"   x0="544" y0="16"  x1="704" y1="144" up="nucleus"   down="playall" left="quicksand" right="nucleus"   />
   <button name="playall"   x0="16"  y0="432" x1="704" y1="560" up="magma"     down="playall" left="playall"   right="playall"   />
  </spu>
 </stream>
</subpictures>

1. Magma

As this was the first track I prepared for DVD, I was working directly from the command line and forgot to record the exact commands used. The steps were: generate video (in the form of multiple TGA image files) from audio using Pd+GridFlow, convert all TGA files to PNG files, encode multiple PNG files to MPEG2 video (see 0. Menu for details), encode WAV audio to MP2 audio, multiplex audio+video to DVD MPEG.

2. Lava Flow

A slightly refined version of the interactive command-line process of 1. Magma, omitting the conversion from TGA to PNG, using this little script:

DVD/1_2_LavaFlow/tgagz2pnm.sh

#!/bin/bash
gzcat $1 | tgatoppm -

3. Quicksand

Using a script to encode.

DVD/1_3_Quicksand/encode-m2v.sh

#!/bin/bash
find TGA | xargs -n1 ./tgagz2pnm.sh | ppmtoy4m -F 25:1 | mpeg2enc -f 8 -a 2 -o video.m2v

4. Nucleus

Direct MPEG generation from Pd+Gridflow using a PPM FIFO (named pipe) instead of intermediate individual image files. GridFlow writes consecutive frames to fifo.ppm, previously created with mkfifo.

DVD/1_4_Nucleus/encode.sh

#!/bin/bash
cat fifo.ppm | ppmtoy4m -F 25:1 -S 420mpeg2 | mpeg2enc -f 8 -a 2 -o ./video-nosound.m2v

DVD

The DVD/*/*.mpg files are symlinked in DVD/DVD to make things neater.

DVD/DVD/dvd.xml

<dvdauthor dest="dvd" jumppad="no">
  <vmgm />
  <titleset>
    <menus>
      <video />
      <audio />
      <pgc entry="root" pause="0">
        <vob file="1_0_SoftRockEP.mpg" pause="inf" />
        <button name="magma"    >{ jump title 1; }</button>
        <button name="lavaflow" >{ jump title 2; }</button>
        <button name="quicksand">{ jump title 3; }</button>
        <button name="nucleus"  >{ jump title 4; }</button>
        <button name="playall"  >{ jump title 5; }</button>
      </pgc>
    </menus>
    <titles>
      <pgc>
        <vob file="1_1_Magma.mpg" />
        <post>{ call menu entry root; }</post>
      </pgc>
      <pgc>
        <vob file="1_2_LavaFlow.mpg" />
        <post>{ call menu entry root; }</post>
      </pgc>
      <pgc>
        <vob file="1_3_Quicksand.mpg" />
        <post>{ call menu entry root; }</post>
      </pgc>
      <pgc>
        <vob file="1_4_Nucleus.mpg" />
        <post>{ call menu entry root; }</post>
      </pgc>
      <pgc>
        <vob file="1_1_Magma.mpg" />
        <vob file="1_2_LavaFlow.mpg" />
        <vob file="1_3_Quicksand.mpg" />
        <vob file="1_4_Nucleus.mpg" />
        <post>{ call menu entry root; }</post>
      </pgc>
    </titles>
  </titleset>
</dvdauthor>

DVD/DVD/make.sh

#!/bin/bash
rm -rf dvd dvd.iso && dvdauthor -x dvd.xml && mkisofs -dvd-video -o dvd.iso dvd

Burning

Use your favourite burning software to burn the DVD/DVD/dvd.iso image on a DVD.