Hack70.Create a DVD

Hack 70. Create a DVD

How to create your own DVD under Linux with the tovid suite and a host of other utilities.

"Create a VCD" [Hack #69] discussed how to use the tovid suite to take a video of almost any format and convert it into a video suitable for a VCD or SVCD. You can also use this tool to create DVD-compatible video. The nice thing about this method is that you use largely the same tools for the task with a few variations when it comes to creating the final DVD file structure.

This hack assumes that you already have the tovid suite of tools installed. If you don't, follow the steps in [Hack #69] to download and install tovid. Much of the syntax to create a DVD-compatible video file is the same. First identify the aspect ratio of your video file. tovid supports full-screen (4:3), wide-screen (16:9) and theatrical wide-screen (2.35:1) aspect ratios through the -full, -wide, and -panavision options, respectively. Generally speaking, if you are creating a DVD of a home video or TV show, you probably will use -full (which is what tovid uses by default if you don't specify the option). If the video source is from a movie, you will use -wide or -panavision, depending on how wide the video is. If you are unsure, run the idvid utility that comes with the tovid suite on the video file to output the width and height of the video, then divide the width by the height:

 $ idvid  sample.avi  ----------------------------------- idvid video identification script Version 0.18b Written in 2004 by Eric Pierce http://tovid.sourceforge.net/ ---------------------------------- Gathering video information. This may take several minutes, so please be patient… ===================================================== File: sample.avi    Width: 512 pixels   Height: 384 pixels … $ 

In this example the video aspect ratio is 512/384, or 4:3.

With the aspect ratio chosen, run tovid with the -dvd option to create the new DVD-compatible MPEG2 file:

 $ tovid -dvd -ntsc -full  sample.avi output  Probing video for information. This may take several minutes… Input file is 512 x 384 at 23.976 fps. Reported running time is 1267 seconds. Source is not 29.970 fps. Adjusting to 29.970 fps. Scaling and/or padding with letterbox bars Scaling 512 x 384 directly to 720 x 480 The encoding process is estimated to require 886 MB of disk space. You currently have 21396 MB available in this directory. ========================================================= Testing mplayer stability with -vc dummy option: Test succeeded! Creating WAV of audio stream with the following command: mplayer -quiet -vo null -ao pcm "sample.avi" -vc dummy -ao pcm:file=stream. wav ========================================================= ========================================================= Encoding WAV to ac3 format with the following command: ffmpeg -i stream.wav -ab 224 -ar 48000 -ac 2 -acodec ac3 -y "output.ac3" Audio encoding finished successfully ========================================================= Creating and encoding video stream using the following commands: nice -n 0 mplayer -benchmark -nosound -noframedrop -noautosub -vo yuv4mpeg - vf-add pp=hb/vb/dr/al:f -vf-add hqdn3d -vf-add scale=720:480 "sample.avi" cat stream.yuv | yuvfps -r 30000:1001 -n -v 0 | nice -n 0 mpeg2enc -M 2 -a 2 -f 8 -b 8000 -g 4 -G 11 -D 10 -F 4 -v 0 -n n -4 2 -2 1 -q 5 --keep-hf -o "output.m2v" 

If you have more than one video you would like to convert, you can use the tovid-batch command instead. tovid-batch takes the same arguments as tovid, except that you don't specify an output filenametovid-batch will determine the output filename based on the input filename. So if you had a directory of full-screen .avi files you wanted to convert to DVD, run this:

 $ tovid-batch -dvd -full -ntsc  *.avi  

Unlike with VCDs, K3b doesn't yet support creating Video DVDs directly from the MPEG filesit expects a complete VOB file structure. This means you need to create a proper .xml file to describe the DVD structure. Like with VCDs you can use the makexml tool to create an XML file that is compatible with the dvdauthor tool. makexml supports more options when used for DVDs.

Table 3-5 lists the DVD-specific options.

Table 3-5. makexml DVD options



-group -endgroup

List of video files to include as one single title. This is useful if you have split a movie into several video files.


Forces the creation of a separate titleset per title. This is useful if the titles of a DVD have different video formatse.g., PAL + NTSC or 4:3 + 16:9. If used with menus, there must be a -topmenu option that specifies a menu file with an entry for each of the titlesets.

-chapters n

Creates a chapter every n minutes within the video. This option can be put at any position in a file list and is valid for all subsequent titles until a new -chapters option is encountered. Using this option may take some time, since the duration of the video is calculated.

These options are generally for special cases apart from the last option. By default makexml won't define chapters in your DVD, which means you won't be able to easily skip through. To add chapters, use the -chapters option and specify an interval such as five or ten minutes. That way you can more quickly skip through the DVD. To create an XML file for the example with a chapter every five minutes type:

 $ makexml -dvd -chapters 5  output.mpg output  --------------------------------------------- makexml A script to generate XML for authoring a VCD, SVCD, or DVD. Part of the tovid suite, version 0.18b Written in 2004 by Eric Pierce http://tovid.sourceforge.net/ -------------------------------------------- Adding title: output.mpg as title number 1 of titleset 1 Calculating the duration of the video using the following command: idvid -terse "output.mpg" This may take a few minutes, so please be patient… The duration of the video is 00:21:07 Closing titleset 1 with 1 title(s). ========================================== Done. The resulting XML was written to output.xml. You can create the DVD filesystem by running the command: dvdauthor -x output.xml Thanks for using makexml! 

With the XML file created, the next step is use dvdauthor to create the DVD filesystem. dvdauthor has a number of options you can use to create special DVD filesystems, but since makexml has already done the work for us, you can just pass it to dvdauthor as an argument. makexml also listed the appropriate command to use in its output, so to create a DVD filesystem for our example, type:

 $ dvdauthor -x  output.xml  DVDAuthor::dvdauthor, version 0.6.11. Build options: gnugetopt magick iconv freetype fribidi Send bugs to INFO: Locale=en_US INFO: Converting filenames to ISO-8859-1 INFO: dvdauthor creating VTS STAT: Picking VTS 01 STAT: Processing output.mpg… STAT: VOBU 3184 at 529MB, 1 PGCS INFO: Video pts = 0.178 .. 1268.077 INFO: Audio[0] pts = 0.178 .. 1267.506 STAT: VOBU 3194 at 530MB, 1 PGCS INFO: Generating VTS with the following video attributes: INFO: MPEG version: mpeg2 INFO: TV standard: ntsc INFO: Aspect ratio: 4:3 INFO: Resolution: 720x480 INFO: Audio ch 0 format: ac3/2ch, 48khz drc STAT: fixed 3194 VOBUS INFO: dvdauthor creating table of contents INFO: Scanning output/VIDEO_TS/VTS_01_0.IFO 

dvdauthor will create a directory named output and store the AUDIO_TS and VIDEO_TS DVD filesystem there. If you want to test the DVD before you burn it, you can use mplayer to play from the filesystem on the disk with the -dvd-device option:

 $ mplayer dvd://1 -dvd-device output/ 

This command plays the first title from the DVD filesystem under the output directory. If you want to play a different title specify it on the command line.

Now it's time to burn the file structure to DVD. If you use K3b just open it, click File New Project New Video DVD Project. Find your DVD filesystem in the top pane and then drag and drop the files inside the VIDEO_TS directories into their respective directories on the bottom pane. Then click the Burn button to set the DVD-burning options and, finally, to burn the filesystem to DVD.

If you want to burn the DVD from the command line, you need to install dvdrtools, which is a fork of the cdrecord utility that is designed to support recordable DVD drives. dvdrtools is prepackaged in many newer distributions or, alternatively, you can download the source and build it yourself from the official site at http://www.nongnu.org/dvdrtools.

Once dvdrtools is installed, the first step is to use the included mkisofs utility to create a DVD image out of your file structure:

 $ mkisofs -dvd-video -udf -o  dvd.iso output/  

With the dvd.iso file created, the last step is to use dvdrecord to record the .iso file to disk. Most of the dvdrecord options will mirror the options you would use with cdrecord, so reference [Hack #39] for more on cdrecord configuration. For my system, I would type:

 $ dvdrecord -dao speed=2 dev= ATA:1,0,0 dvd.iso  

With the DVD created, pop it in your DVD player and test your results.

Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net