I just recently found a bunch of little video clips that I took with my little point and shoot Canon PowerShot camera. Most of them are really short, less than 5 minutes, and I wanted a quick and easy way to put these on DVD so I can send them to friends and family. So here it is a quick and easy way (relatively speaking) to encode movies in linux to DVD.

I’ve been working with ffmpeg to do TiVo encoding for a while and seemed like a good candidate, so I figure I would stick to what I know. One thing that I couldn’t really do with ffmpeg was combining the AVI file, this is probably because I was not using it right but I figure I stop wasting time trying to figure it out and just use mencoder to do this.

This is what I did: First combine all the files into a single AVI.

mencoder -oac copy -ovc copy clip1.avi clip2.avi clip3.avi-o clips.avi

Here -oac and -ovc is used to set the audio and video codecs. copy just means to don’t really convert into anything, just “copy”. We then list all the clips we want to combine and finally use -o clips.avi to specify the target file that will hold the merged video clips.

Next we convert the AVI to MPEG2.

ffmpeg -i clips.avi -aspect 16:9 -target ntsc-dvd  -s 720x384 -padtop 48 -padbottom 48 clips.mpg

Let me quickly explain the options: -i clips.avi is of course the input file. -aspect 16:9 is the aspect ratio of the clips. -target ntsc-dvd sets the format to NTSC, DVD. -s 720×384 this is the video size and -padtop 48 -padbottom 48 is the padding or “black bars” to add to the video in order to achieve a 720×480 resolution.

The original size of the video was 600×320 and DVD resolution (at least for NTSC) is 720×480. So in order to match the final size I scale it up by using a a simple ratio formula. ((source height * destination width) / source width) which gives me ((320 * 720) / 600) or 384. This will be my new height or 720×384, but this still doesn’t match 720×480 so we add “black bars” on top and bottom to get there. We just take the difference and divide by two so the video is centered. ((480 – 384)/2) = 96/2 = 48. This is why we add -padtop 48 and -padbottom 48.

In my case this worked out fine. There are times when the destination height will end up being bigger than 480. So here you have two options.

First option is to use -croptop and -cropbottom to remove the excess from the top and the bottom. Which will remove part of the pictures. You may or may not want this, especially if your video is mostly of closeups as you will lose quite a bit of the picture. So your second option is to add “black bars” to the left and right.

So how do we add these “black bars” to the left and right? Well instead of using the previous formula to calculate the new height, we are going to calculate the new width instead. So let say our source video was 320×240. The formula we would use would be ((Source Width * Destination Height) / Source Height) or ((320 * 480) / 240) = 640. So our new size would be 640×480. As you can see 640 is short of 720 so we do the same trick, to calculate the left and right bars. ((720 – 640)/2) = 80/2 = 40. So if our original size was 320×240 our final parameters would be -s 640×480 with -padleft 40 -padright 40. But enough of “black bars”, once we have our video it is time to build the image.

The rest is fairly easy. We use dvdauthor to create the VOB files and table of contents.

dvdauthor -o dvd/ -t clips.mpg
dvdauthor -o dvd/ -T

Then the following is optional but I’d like to do this just to make sure the permissions are correct in the final image. It basically changes the files to read only as well as the directories.

chmod 400 dvd/VIDEO_TS/*
chmod 500 dvd/*

And finally we build the ISO image we are going to burn. here we just switch over to the dvd directory we just created and run mkisofs to create the image.

cd dvd
mkisofs -dvd-video -V "Family Videos" -o ../family_videos.iso ./

Lastly we just burn the image onto a DVD. I use growisofs but there are easier ways to do this. You could use K3B, Nero or what ever else you have installed. Just make sure to burn it as a disc image and not as a data disc.

growisofs -dvd-compat -Z /dev/scd0=family_videos.iso

Well hope this helps.