Monday, February 9, 2009

Converting avi to DVD format

In this blogpost I would like to explain how an existing avi file (in XVID or DIVX format) can be converted to DVD format, ready to be burned to disc. This for people who still have an old DVD player which cannot read DIVX and XVID movies.

First thing to do is to convert the XVID film into a format usable for DVD playback. The DVD standard typically uses MPEG-2 for video and AAC for audio. It is possible other formats are also supported, but I stuck to these formats.

The conversion to MPEG-2 can be done with ffmpeg an open source tool that is able to convert a lot of video files. The command line is as follows:

$>ffmpeg -i film.avi -target pal-dvd film.mpg

This will convert the file film.avi into film.mpg with the standard DVD format (resolution and framerate) for PAL televisions. For NTSC (USA) it is enough to change the 'pal' part into 'ntsc'.
After the file has been converted, it can be massaged to be put on a DVD disc. For this we need to create the directory structure that consists of the directories AUDIO_TS and VIDEO_TS. The directory AUDIO_TS is typically empty on a DVD, but the VIDEO_TS directory contains the files of type VOB and IFO that contain the video and audio in chunks of 1 GB. For creating this directory layout and the correct files, dvdauthor is a good tool. Dvdauthor requires an xml file that contains a description of the structure of the dvd layout. It is very powerful and allows for a lot of customization. In this example I keep it simple with one single file that has 4 chapters:

<dvdauthor dest="DVD">
 <vmgm />
  <titleset>
   <titles>
    <pgc>
     <vob file="film.mpg" chapters="0,15:00,30:00,45:00,1:00:00"/>
   </pgc>
  </titles>
 </titleset>
</dvdauthor>

Save this file as film.xml to the same directory as where film.mpg resides. With dvdauthor now the layout will be created as follows:

$>dvdauthor -x film.xml

This command will create a directory DVD with inside the directories AUDIO_TS and VIDEO_TS. The VIDEO_TS directory will contain the VOB files that contain the video and audio. This structure can then be burned to disc using tools like K3B.

PS: both tools can be installed in Ubuntu using:
$>sudo apt-get install ffmpeg dvdauthor

PS2: There are other tools with which you can accomplish the same job: