Create a Video DVD






Create a Video DVD

Use the tovid scripts to automate the conversion of many video formats to DVD.

Before DVD burners and media were relatively inexpensive, creating your own video DVDs was a daunting prospect. Even today, depending on which tools you use, it can still be a daunting prospect under Linux. However, with the tovid set of scripts (http://tovid.org), you can easily convert just about any video into a DVD-compatible format.

So you have a video (or a number of videos) that you want to convert into a DVD. The first step is to convert that video into a format compatible with the DVD standard. Although you could use mencoder or transcode directly to perform this conversion, the number of options involved can quickly get complicated and confusing. Luckily, a great tool, tovid, has been created to solve this problem. The tovid suite is a series of scripts that automate the process of converting a video into a VCD. The scripts involved have basic, easy-to-understand arguments and, because the output shows you the commands that are being executed, you can also use them to learn more about the underlying process.

Install tovid

To install tovid, download the latest release from the official project page at http://tovid.org. The main tool in the suite is also called tovid and uses the mplayer, mjpegtools, ffmpeg, mkisofs, dvdauthor, transcode, vcdimager, and normalize-audio packages to perform the video conversion, so you will need to have these packages installed beforehand (you'll need the universe and multiverse repositories enabled [Hack #60]). For example:

$ sudo apt-get install mplayer mjpegtools ffmpeg mkisofs \\
                 dvdauthor normalize-audio transcode vcdimager
            

Once these requirements are met, download the latest release and untar it:

$ tar -xzvf tovid-0.25.tar.gz
            

Now enter the tovid source directory that tar created and then run the configure script inside. This script automates the process of installing tovid on your system, and once it completes, you are ready to start:

[email protected]:~$ cd tovid-0.25 
[email protected]:~tovid-0.25$ ./configure
            

The configure script will confirm that you have all the required dependencies installed. If you are missing a dependency, check out "Search for Packages from the Command Line" [Hack #58] for information on how to track down the exact package name you need. Once configure has detected all the dependencies it needs, run the setup.sh script:

[email protected]:~tovid-0.25$ sudo ./setup.sh
            

Convert the Video

With tovid installed, now it's time to convert the video. The tovid arguments are pretty basic. The only wrinkle is that you need to decide whether to use NTSC or PAL formats and which aspect ratio to use for the video so tovid knows how to properly resize the video. Whether to use NTSC or PAL formats depends on where you live (or, more specifically, what your TV uses). If you live in the United States, use NTSC. If you live in Europe or Japan, use PAL.

tovid supports full-screen (4:3), wide-screen (16:9), and theatrical widescreen (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 will probably 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, and then divide the width by the height:

$ idvid  sample.avi 
-----------------------------------
idvid video identification script
Version 0.25
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 also takes as arguments -in followed by the input file, and -out followed by the name to give the output file (without any file extensions):

$ tovid -dvd -ntsc -full -in sample.avi -out 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 use -infiles instead of -in and you don't specify an output filename; tovid-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 -infiles *.avi
                  
               
            

Create the XML File

The next step is to create a proper .xml file to describe the DVD structure. You can use the makexml tool that is included with tovid to create an XML file that is compatible with the dvdauthor tool. makexml supports more options when used for DVDs.

Section 28 Figure lists the DVD-specific options.

Table makexml arguments
ArgumentFunction
-group videofile1 videofile2 ... -endgroup List of video files to include as one single title. This is useful if you have split a movie into several video files.
-titlesets 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 increase burn 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 it. To add chapters, use the -chapters option and specify an interval, such as 5 or 10 minutes. That way, you can more quickly skip through the DVD. To create an XML file for the sample video 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!

where output.mpg is the name of the movie to work on and output is the name of the XML file to create (the .xml is appended automatically).

Create the DVD Filesystem Structure

With the XML file created, the next step is to 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 you, you can just pass your XML file to dvdauthor as an argument. makexml also listed the appropriate command to use near the end of its output, so to create a DVD filesystem for this 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 this filesystem 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.

Burn the DVD

Now it's time to burn the file structure to DVD. With K3b [Hack #34], click FileNew Video DVD Project. Find your DVD filesystem in the top pane and then drag and drop the files inside the AUDIO_TS (if any) and VIDEO_TS directories into their respective directories in 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 already packaged for Ubuntu, so install it with your preferred package manager.

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, you can locate the dvd.iso file in your file browser, right-click it, and select "Burn to DVD." Otherwise, if you prefer the command line, use the dvdrecord utility to burn it:

$ dvdrecord -dao speed=2 
               
                  dev=/dev/dvdrw
               
                dvd.iso
            

Replace the dev=/dev/dvdrw option with the correct values for your DVD burner.

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



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows