In order to make the slideshows, we need to transform the pictures into video clips. The mjpegtools suite includes a utility called jpeg2yuv that transforms a JPEG file into YUV (a color model used for video pictures) format, which then can be piped into mpeg2enc to generate an MPEG-2 video file. Before this transformation happens, though, we need to make sure the picture files are formatted correctly for DVD. It is advisable to alter your pictures manually to fit the PAL or NTSC resolution constraints (720×576 and 720×480, respectively) before feeding them into jpeg2yuv. mjpegtools includes a utility called yuvscaler that automatically resizes incoming YUV data into the correct resolution, but this can alter the aspect ratio of your pictures and cause distortion.
A sample command line to generate a slide looks like this:
jpeg2yuv -n 125 -I p -f 25 -j picture1.jpg | \ mpeg2enc -f 8 -o slide.mpg
The -n option tells jpeg2yuv how many frames it should generate, in this case 125 (5 seconds at 25fps); you should use 29.97 for NTSC. The -I option tells it to use progressive interlace (rather than throwing parts of the image away), and -f sets the required frame rate. The -f option to mpeg2enc tells it to create a DVD MPEG-2 video stream. This process needs to be repeated for all the photos to be included on the DVD, so you might want to write a quick Perl or shell script to automate this process.
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.
The process for creating DVD menus is similar to generating the slides. Using The GIMP, make a new image of size 720×576 (for PAL), with a resolution of 75dpi in the x-axis and 80 in the y-axis (NTSC values are 81 and 72). Add an alpha channel, then create the menu picture you desire (see Figure 1 for the base image of the main menu). Once this is finished, add another layer and mark out the location of the buttons that can be highlighted, as seen in Figure 2. A maximum of four colors can be used for this mask; I used red to mark the button areas, and white to make sure that the text still was visible when a button was selected. When you're satisfied with the menu, export the background layer as a JPEG file and the mask as an indexed PNG. Make sure you've set the number of colors to four, three if you're saving the transparent background as a color. This process is repeated for all menus required in the DVD (see Figures 3 and 4 for a further example).
As before, use jpeg2yuv and mpeg2enc to create an MPEG file, and mplex to multiplex it with an audio file. For some reason, menus need an audio file to work, so if you want silent menus, you have to use a short burst of silence. Buttons in DVD are implemented as part of the subtitle stream, so we use dvdauthor's submux tool to define a menu's buttons. The program reads in subtitle information from a text file and multiplexes it into the video stream. The format of the submux files looks like this:
<file_name> <start_time> <end_time> <x_offset> \ <y_offset> <4 8-bit numbers>
There can be multiple entries in a .sub file, but only one line is required for the menus:
mainmask.png 00:00:00.00 00:00:00.00 0 0 0 1 0 1
Defining the start and end times as zero instructs the DVD player to keep the subtitle on screen continuously. The 0 1 0 1 sequence turns the selected button red when using the default palette file supplied with dvdauthor. The four different numbers (from 0–255) control the transparency values of the colors in the indexed PNG. You might want to experiment with these values to see what effects you can create, but the sequence above seems to produce reasonable results. Having made a subtitle file, we then run submux to add the subtitles to the video stream:
submux menu.sub < video.mpg > menu.mpg
Win an iPhone 6
Enter to Win
|Take Control of Your PC with UEFI Secure Boot||Nov 30, 2015|
|Geek Hide-away in Guatemala - Stay for Free!||Nov 26, 2015|
|Microsoft and Linux: True Romance or Toxic Love?||Nov 25, 2015|
|Non-Linux FOSS: Install Windows? Yeah, Open Source Can Do That.||Nov 24, 2015|
|Cipher Security: How to harden TLS and SSH||Nov 23, 2015|
|Web Stores Held Hostage||Nov 19, 2015|
- Take Control of Your PC with UEFI Secure Boot
- Cipher Security: How to harden TLS and SSH
- Microsoft and Linux: True Romance or Toxic Love?
- Non-Linux FOSS: Install Windows? Yeah, Open Source Can Do That.
- Web Stores Held Hostage
- Firefox's New Feature for Tighter Security
- Geek Hide-away in Guatemala - Stay for Free!
- PuppetLabs Introduces Application Orchestration
- diff -u: What's New in Kernel Development
- IBM LinuxONE Provides New Options for Linux Deployment