
Now we have video clips of separate slides. The next step is to add a music backing track that plays across each clip. The DVD specification allows for the use of PCM, AC-3 or MPEG-2 audio, at various bit rates. For the photo album, I decided to use MPEG-2 audio; I decided that I didn't need the higher audio quality of AC-3 or PCM. mjpegtools includes a tool called mp2enc that encodes WAV files in MPEG-2 format. Another tool from mjpegtools, mplex, multiplexes one or more audio files into a video MPEG stream. To do multiple audio files, you need the CVS version of mjpegtools. Start by concatenating all the video files required for a particular slideshow using *cat*, as mplex seems to have problems with handling multiple input files:

cat *mpg > video.mpg

In the title5 directory (the fifth title is going to have two audio tracks), I ran mplex on this new file:

mplex -f 8 -o video%d.mpg photos/set5/video.mpg audio1.mp2 audio2.mp2
This creates a series of files called video1.mpg, video2.mpg, ..., videoN.mpg in the current directory, multiplexed with the two audio tracks, audio1.mp2 and audio2.mp2. The -f 8 argument to mplex ensures that the new MPEG files are DVD-compatible, the same as mpeg2enc.

One issue to be aware of is that mplex multiplexes the whole audio track. If the track is longer than the combined length of the video clips, then the final clip is extended to cover the rest of the audio. You may want to adjust the frame times in jpeg2enc phase or edit the audio track to prevent this from happening. 
