Brain Dump

A place to store my random thoughts and anything else I might find useful.

Creating a playable DVD from multiple video files

Posted by mzanfardino on September 19, 2008

Like many folks, I have from time to time wanted to burn a DVD of some video files so that I can watch them on my TV. This seems like a no-brainer, but as with so many no-brainers it does take a little bit of work. I will first summarize the tasks at hand, then work though a step-by-step example. Please note, this worked for me but is no guarantee that it will work for you (your mileage may vary).

In general, a DVD is made up of a number of files located in two directories: VIDEO_TS and AUDIO_TS. By and large it’s the VIDEO_TS directory that will hold all the necessary files. Specifically there are three types of files found: *.BUP, *.IFO and *.VOB. So, the ultimate goal will to create these files and directories from the source video in order to burn a DVD that can be played in a stand alone player.

The process starts with a video file. If it’s not already an .AVI or .MPG file it should be converted to .AVI. This can be done using mencoder (instructions to follow). Once you have an AVI file, use ffmpeg to convert it to an .MPG file (again, instructions to follow). The next step is to create the DVD file structure. This can be done with dvdauthor. However in order to add multiple videos and create separation it will be necessary to first create an .XML file (structure to follow) that will be used by dvdauthor when creating the DVD file structure. Once the file structure is in place the dvd can be burned either directly or after converting it to an .ISO file. I will discuss the merits of both at the end.

The applications required to perform this little bit of video transcoding magic are:

  1. mencoder
  2. ffmpeg
  3. dvdauthor
  4. mkisofs
  5. growisofs

For the first step (converting a video file to .AVI) it will be necessary to use mencoder. The following command will generate a log file which will be used by the next command to convert the file to an .AVI

mencoder <inputfile> -ovc xvid -xvidencopts pass=1 -oac mp3lame -lameopts vbr=3 -o /dev/null

Now use mencoder to create the .AVI:

mencoder <inputfile> -ovc xvid -xvidencopts pass=2:bitrate=1000 -oac mp3lame -lameopts vbr=3 -o <avifile>

Now the newly create .AVI file needs to be converted to an .MPG file. This is done with ffmpeg. This is also the time to add parameters that will convert to specific formats (NTSC or PAL) and aspect ratio (4:3 or 16:9). Since I’m in the US I will be formatting to NTSC and since I plan to watch this on my SD TV I will use 4:3 aspect ratio in this example.

ffmpeg -i <avifile> -target ntsc-dvd -aspect 4:3 <mpgfile>

NOTE: If the ffmpeg reports an error with the ntsc-dvd parameter, install transcode.

Before moving to the next step repeat the preceding steps for each of the video files that will be burned to the DVD. Once all the files have been converted to .MPG an XML file will be required n order to append multiple files to a single DVD. NOTE: this will not create a menu, but it will permit the use of next and back with the stand alone DVD player to select between videos. I will write up more about creating menus in a separate blog (once I figure it out!).

The XML file will looks something like this:

<dvdauthor>
<vmgm>
<menus>
<video/>
<audio/>
</menus>
</vmgm>
<titleset>
<titles>
<pgc pause=”4″>
<vob file=”video-1.mpg” chapters=”0″/>
<vob file=”video-2.mpg” chapters=”0″/>
</pgc>
</titles>
</titleset>
</dvdauthor>

I will not go into detail here about what the various xml fields manage save to say that pgc pause controls the delay between videos and that each video should be defined with the <vob file/> tag. More information can be found at http://dvdauthor.sourceforge.net/

Once the XML file has been created the DVD file structure can be created using dvdauthor as follows:

dvdauthor -o <dvd directory> -x <dvdauthor config xml>

At this point there should be a new directory (as defined by <dvd directory>) containing AUDIO_TS and VIDEO_TS directories. This new directory is the source for the DVD. At this point there are two ways to create the DVD. One is to create an .ISO file first. I can’t swear that this is strictly necessary, but I have found it to be useful for testing by mounting as an ISO9660 and then loading it as though it where the CD. To create the ISO file use mkisofs as follows:

mkisofs -dvd-video -v -o <isofile> <dvd directory>

The resulting ISO can be mounted using:

mount -o loop -t iso9660 <isofile> <mount point>

Using VLC (or any other video player) watch the results from the mount point. NOTE: this DVD should permit skipping from one chapter to the next and back. There will be no proper menu. This will be addressed in a later blog.

The last step is to burn the DVD. If you have created an ISO this can be accomplished with:

growisofs -dvd-compat -Z /dev/dvd=<isofile>

If instead you wish to burn directly from the source directory, this can be done with the following:

growisofs -Z /dev/dvd -dvd-compat <dvd directory>

There are additional options that can be used to add a title, etc. Check man growisofs for details.

That’s it! This is by no means a comprehensive process and is only meant as a jumping off point. The bulk of this information comes from http://ubuntuforums.org/showthread.php?t=320389 (my thanks to netyire for the source post!) and a lot of trial and error. There is a lot of really good information out there about transcoding videos and different methods of burning DVD’s. I highly recommend checking out http://dvdauthor.sourceforge.net/ for more information.

Mark Zanfardino

Advertisements

2 Responses to “Creating a playable DVD from multiple video files”

  1. mzanfardino said

    Point of interest: If you have a need to burn an ISO to a CD (as opposed to DVD) from the command line, simply use wodim:

    # wodim $isofile

  2. mzanfardino said

    Tip #2: User tcprobe -i $mediafile to discover information about the source file.
    Tip #3: To convert from ASF to MPEG2 (for later burning to DVD) use mencoder as follows:

    mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:480,harddup \
    -srate 48000 -af lavcresample=48000 \
    -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=18:aspect=4/3:\
    acodec=ac3:abitrate=192 -ofps 30000/1001 -o $destination_video_file.mpg $source_video_file.asf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: