Home » linux » Convert avi/mkv/mp4 to dvd in OSX or Someother *nix derivative

I often need to convert avi, mkv, mp4 or some other video format to generic DVD.  Using a Mac, I’ve found that this processes is a pain in the ass.  It surprises me that there are very few tools for pulling this together.  I spent a few days searching and see that there was a few tools, but they were either dead projects, or not stable.  Don’t get me wrong, FFMpegX is pretty good at converting video formats, but trying to use it to actually make a dvd with subtitles just doesn’t work for me.  I did notice that it was based of the opensource ffmpeg, dvdauthor and cdrtools projects, so I decided to use my Darwin Ports system to install the packages (With all prerequisites)  and use the command line tools to do all the conversion.

sudo port install ffmpeg

sudo port install dvdauthor

sudo port install cdrtools

I had no clue how easy the command line tools would be to use and decided to document for my own use later.  Most of my info came from http://atomized.org/2005/03/converting-divxxvid-avi-to-dvd-with-ffmpeg/

Step 1)  Convert Source file to DVD video format

The first thing you need to do is convert the video file to a mpeg2 file with the proper video dimensions 720×480.  Luckily the FFMpeg package has a predefined template for it ‘-target ntsc-dvd, or -target pal-dvd for europe’.  Since I have a widescreen plasma screen, I use the 16:9 aspect ratio, if you have a more square tv, or if you just want your file more square use the ‘-aspect 4:3’  The ffmpeg faq has some great info on additional options like converting videos to play on game consoles or smart phones or even to just a different format.  FFMPEG can be downloaded from http://www.ffmpeg.org for non-osx systems

ffmpeg -i MyMovie.avi -target ntsc-dvd -aspect 16:9 -sameq MyMovie.mpg

Step 2) Add Subtitles (If Needed)

The easiest way to add subtitles to your newly created mpeg2 file is with DVDAuthor’s spumux tool.  This tool is a bit confusing to use, so I’ll try to make this as simple as possible.  First you need to make a xml config file for each subtitle you want to add.  Here is the one I make, and tend to use over and over by copying the file and changing the subfile name inside. Get the DVDauthor tools here http://dvdauthor.sourceforge.net

<textsub filename=”ongbak.3.english.srt” characterset=”ISO8859-1″
fontsize=”28.0″ font=”Geneva.ttf”
vertical-alignment=”bottom” left-margin=”40″
top-margin=”20″ bottom-margin=”30″
movie-fps=”25″ movie-width=”720″ movie-height=”480″

Here is a simple breakdown of what is going on in this config. Better definition found here http://dvdauthor.sourceforge.net/doc/spumux.html

  • filename – This is the subtitle file you will be attaching.
  • characterset – This is the characterset for your subtitle text to use in the film.  For english you can use ISO8859-1, for other languages reference http://en.wikipedia.org/wiki/Character_encoding
  • fontsize – This is the size of the font to display in the movie
  • font – Which font to show as.  The fonts used by spumux are locate in ~/.spumux/
  • horizontal-alignment – Where to place the subtitles in the film, {left, right, center}
  • vertical-alignment – Where to place the subtitles on the film {top, center, bottom}
  • right-margin – Don’t really understand these
  • left-margin – Don’t really understand these
  • top-margin – Don’t really understand these
  • bottom-margin – Don’t really understand these
  • subtitle-fps – Just set this to 25, for DVD
  • movie-fps – Just set this to 25, for DVD
  • movie-width – for DVD set to 720 for wide or 640 4:3
  • movie-height – for dvd set to 480
  • force – turns the subtitle without being selected

spumux -s 0 -P MyMovie.xml < MyMovie.mpg > MyMovie.sub.eng.mpg

Step 3) Convert mpg to Video_TS format, this is called DVD authoring

Now that we have our file encoded to the mpeg2 (AKA DVD) format and perhaps even the subtitles, it’s time to get the mpeg file turned into the more recognizable video_ts structure.   You can get the full lowdown on all the dvdauthor arguments from http://dvdauthor.sourceforge.net/doc/r1741.html

dvdauthor –title -f MyMovie.sub.eng.mpg -o MyMovie

the -o MyMovie means create a output directory with the VIDEO_TS subdirectory & files inside

Step 4) Create the DVD menu system

Now that the mpeg file is in the video_ts directory structure (and is broken into vob files). You need to make the dvd menu.  Personally I don’t care for advanced menus.  I just want my movies to start, so I use the following command to just make an empty menu that just auto starts the movie.

dvdauthor -T -o MyMovie

Step 5) Create ISO image from finished VIDEO_TS directory

Now that we have our functioning dvd video, lets convert it to an ISO that we can burn.  I do this with the mkisofs command from the cdrtools package.  It’s pretty simple, just use the following.  You can get cdrtools from  http://cdrecord.berlios.de/

mkisofs -dvd-video -o MyMovie.iso MyMovie/

One thought on “Convert avi/mkv/mp4 to dvd in OSX or Someother *nix derivative

  1. [New Post] Convert avi/mkv/mp4 to dvd in OSX or Someother *nix derivative – via #twitoaster http://www.analogrithems.com/rant/2011/0

Leave a Reply

Your email address will not be published. Required fields are marked *