Friday, July 26, 2013

Creating a DVD in Linux

There are a number of documents created that describe the inception of a DVD from DV (Digital Video) files, or even "ripping" (capturing the contents of a DVD into a movie file), but none that I saw delt with convering a captured movie from a TV tuner card into a DVD.  This document describes the basic steps performed in taking a video capture file and converting it into a DVD.

The first step is to carve the captured file into the exact pieces desired.  I performed this step using the mplayer in playing to the point where I wanted the video capture file to start, and then noting the "seconds" field.  Then, I noted where the ending point was that I needed from the video.  At that point, I ran :
    
    mencoder -ovc copy -oac copy -ss 604 -endpos 4845 -o chopped_file.mpg original-file.mpg
    
    
The above command took the file original-file.mpg and made a copy - but only copied 4845 seconds (see the -endpos 4845 parameter) starting from the 604 second mark (see the -ss 604 parameter).  The copy was named chopped_file.mpg.

At this point, it is a good time to note that the -endpos parameter is not an "end position", but a time from the -ss (or start position), so that can often be confusing.

Once I had the file I needed, I converted that to a DVD-compatible, MPeg-encoded file using the ffmpeg utility :
    
    ffmpeg -i chopped_file.mpg -target dvd -aspect 4:3 -sameq dvd-ready.mpg
    
    
The ffmpeg command executed read in the chopped_file.mpg, forced a dvd format (the -target dvd parameter) in a TV format (not wide screen - that would have used a -aspect 16:9 parameter.  The -sameq parameter just meant to preserve as much of the quality as possible.  The resulting file was dvd-ready.mpg.

It is also possible to do the previous two steps (mencoder and ffmpeg) in one fell swoop.  The following command will extract the segment of video that is needed, de-interlace it, and get it ready to be put onto a DVD image.
    
    ffmpeg -i original-file.mpg -ss 00:10:04 -t 01:20:46 -target dvd -aspect 16:9 -deinterlace -sameq dvd-ready.mpg
    
    
This is the perfect opportunity to convert that dvd-ready movie file into a DVD video image.  This is done using the wonderful tool called dvdauthor, in two stages.  The first creates a title video from the dvd-ready.mpg file we have created, and sets up some of the required pieces for a DVD video.  The second creates the table of contents and completes the structure for the subsystem :
    
    dvdauthor --title -f dvd-ready.mpg -o DVD/
    dvdauthor -T -o DVD
    
    
Note : you may want to create the DVD/ directory that the dvdauthor commands above will be placing the files into because this is not done by default.

At this point, it is time to create the ISO image.  Some experts prefer to use growisofs, but I'm just a little pickier than that - I want more control over the command.  I typically use mkisofs, but I'll shorten the command to the essential parameters :
    
    mkisofs -dvd-video -udf -o dvd.iso DVD/
    
    
The -dvd-video parameter tells mkisofs to turn on some minor DVD-compatability (setting the order of the appropriate files and padding betweem files if required).  The -udf parameter is adding UDF file system compatability (very similar to Joliet file systems on CD-Rom's).  The -o dvd.iso is telling the mkisofs to create the DVD video image as dvd.iso, and the DVD/ is where the base of the image will come from.

Once that is completed, it is possible to burn the ISO image directly to the DVD recorder using cdrecord, burncd, K3B (if you prefer GUI's), or even rebooting into windows and using Nero.  It should be a functional DVD video at that point in time.

No comments:

Post a Comment