Convert Video Files to DVDs at a Terminal in Linux

So you've got a pile of videos you've snagged from the Internet or maybe you've been making your own videos with your own camera but you want to throw them onto a DVD for viewing on your DVD player. Of course there's applications that take care of this for you - you can do this with applications that come installed by default in Macs. Windows and Linux users aren't quite so lucky. I'll show you in this post how to create a simple DVD (no menus) using a few applications you can install for free in Linux. I'm also writing this from the point of view of an Ubuntu system.

To kick this off you'll need a few applications. Install the following:

mencoder, ffmpeg, mkisofs, dvdauthor
$ sudo apt-get install mencoder ffmpeg mkisofs dvdauthor # in Ubuntu

You'll also have to make a change to the installed audio/video codecs installed by default with ffmpeg. Fire up Synaptic and search for "libavcodec" and you'll see one that's uninstalled with the word "unstripped" in its package name. You need to install that package which will remove the package it replaces. Once that's done and these other applications are installed you're ready to go.

The script I use to convert a single video to DVD-ready is:

#!/bin/bash

# two pass encoding
mencoder $1 -ovc xvid -xvidencopts pass=1 \
  -oac mp3lame -lameopts vbr=3 -o /dev/null
mencoder $1 -ovc xvid -xvidencopts pass=2:bitrate=1000 \
  -oac mp3lame -lameopts vbr=3 -o $1.mpg

# convert file to a dvd-ready mpeg
ffmpeg -i $1.mpg -target ntsc-dvd $1-final.mpg

# remove temporary files
if [ -e $1.mpg ]
then
  rm $1.mpg
fi
if [ -e divx2pass.log ]
then
  rm divx2pass.log
fi

I pass this script the name of the file I want to convert and it does the rest. You could use this script to make another one that'll scan through an entire folder to convert a bunch of files all at once instead of doing them one at a time.

Once you've got your files converted you just have to use the following commands:

$ dvdauthor -o [output folder name]/ -t video1.mpg video2.mpg ...
$ dvdauthor -o [output folder name]/ -T
$ mkisofs -dvd-video -v -o [output file name].iso [output folder name]

The first line builds a DVD file and folder structure out of the files you include in the command. You can list as many video files as you want and they'll end up as single tracks on your DVD. The second line creates the table of contents for the DVD and the third line transforms your DVD file and folder structure into a DVD iso disk image. When that's done you'll have an ISO ready to burn to a DVD and to do that you can use any burner program you wish. You don't need to do anything special other than just burn it to a DVD.

If you're feeling adventurous you can learn a lot more about how to use dvdauthor including how to create menus for your DVDs using an XML type text file. I haven't yet gotten into that yet.

That's all there is to it. It can take a while for the first script to run so make sure you're not trying to do this real quick right before you need the DVD.

Syndicate content