Converting DivX/XviD AVI to DVD with FFMpeg
I recently bought a DVD burner, and I’ve been experimenting with the different software for video conversion, mastering, and burning in Linux.
Background
I’ve used Transcode and Ripmake in the past to do DVD-to-SVCD and AVI-to-SVCD reencodes. The problem I had with those tools is that they default to using MJPEG Toola, which I have never managed to get reasonable performance with. My 2.4ghz P4 only gets ~12fps when transcoding using tmarihis method. Recompiling with GCC 3.4 and all optimizations enabled brought me up to ~18-20fps, but this is still not acceptable.
Ripmake also seems to default to non-anamorphic DVD encodes. I don’t know if this can be changed, but it’s certainly not desirable.
Enter FFmpeg
Fortunately, I’ve had much better luck with FFmpeg’s performance. It also understands enough codecs to work directly on an AVI and spit out DVD-ready MPEG-2 video.
Software and Assumptions
I’m running Debian sarge (testing), with Christian Marillat’s excellent Debian video packages. I have the following packages installed:
- ffmpeg 2:20050304-0sarge0.0
- libxvidcore4 2:1.0.2-sarge0.0
- dvdauthor 0.6.10-4
- dvd+rw-tools 5.21.4.10.8-1
For this example, we’ll assume that you have a 1.85:1 ratio XviD AVI to convert, though it should be incredibly obvious how to convert a 1.33:1 video as well.
Reencoding
Reencoding the AVI is simple:
$ ffmpeg -i my_video.avi -target dvd -aspect 16:9 -sameq my_dvd_video.mpg
That’s all there is to it. The -target dvd option causes FFMpeg to handle all the niggly bits necessary to convert to DVD, including scaling the video frame, resampling audio, and so forth. According to the FFmpeg documentation, -sameq “uses in the encoder the same quality factor than in the decoder. It allows to be almost lossless in encoding.” Sounds good to me.
I get just over 25fps on my system using this method, with very acceptable output quality.
Mastering & Burning
Now, we have to master the DVD image. You’ll need a copy of dvdauthor for this.
Create the DVD structure:
$ mkdir DVD $ dvdauthor --title -f my_dvd_video.mpg -o DVD $ dvdauthor -T -o DVD
The DVD structure will now be in the “DVD” directory. Now we just have to burn this to our DVD. You will need to be root to do this.
# growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./DVD/*
You can change the speed argument to suit your burner and media speed. You can also drop the contents of the VIDEO_TS folder into a K3b DVD Video project, if you prefer a GUI.
And that’s it. You should be able to drop the burned disc into your DVD player and enjoy.
Edit: Fixed Christian’s address.

July 1st, 2005 at 4:28 am
Yes, but do you know (or know anyone who knows)
how to get a true 1.85 aspect ratio? I’m trying to make
one now, and don’t want to have to settle for 16:9.
Thanks.
July 19th, 2005 at 7:26 am
Try the following!
$ ffmpeg -i my_video.avi -target dvd -aspect 4:3 -sameq my_dvd_video.mpg
August 29th, 2005 at 2:49 pm
I have the same set up as above other than I am runnign Fedora Core 3. When I try to author the DVD I get the following error:
WARN: Skipping sector, waiting for first VOBU
and no vob is created.
Do you have any thoughts on this?
November 25th, 2005 at 10:38 am
is there a way to loop or combine xvid files to make a new videofile with ffmpeg ?
i want to loop clips x-times as a single smoothly playing track.
any (other) suggestions ?
thanks
November 27th, 2005 at 5:57 am
“is there a way to loop or combine xvid files to make a new videofile with ffmpeg?
i want to loop clips x-times as a single smoothly playing track.
any (other) suggestions?”
None that I’m aware of. Try using AVIDemux.
December 6th, 2005 at 8:10 am
I conver a avi to fle with ffmpeg.But audio missed.Why?
January 18th, 2006 at 1:01 am
Hi!
Just a quick question: how is the final size controlled?
What if I’d like to write 2 avis to one DVD?
What about 2 pass encoding?
thx
January 24th, 2006 at 8:07 pm
Gergely,
Final size is determined by FFmpeg. The -sameq argument tells it to try to keep the same level of quality. In my experience, the MPEG-2 files it outputs are around 1.5gb. You can therefore fit 3-4 files (~3.5 hrs) on a single DVD. Just pass the additional files to dvdauthor.
Two-pass encoding is pointless. I noticed no degradation of quality from the original AVI, so you’re just burning CPU cycles at that point.
March 12th, 2006 at 10:23 am
Thanks for nice howto :) I was using MPlayer to create an MPEG-2, but it wasn’t very good - lot of errors, horrible sound and so.
I just wanted to show you one nice option for DVDAuthor:
dvdauthor -o ./dvd -c 0,05:00,10:00,15:00,20:00,25:00 film-dvd-sub.mpg
That -c will split DVD to chapters long five minutes. Maybe you know it :)
March 12th, 2006 at 10:24 am
And one little question - will that works for some mpg > mpeg-2? Or I’ll have to do that with other options, or program?
April 17th, 2006 at 10:52 am
Hi,
First I want to thank all the people who participate for the construction of this web-site.
It is very usefull…..thank you
then I have a couple of questions:
…please keep in mind I am not an expert in this…
1) How do I know what type of aspect ratio I have in my original DivX or avi file? Knowing that what type of aspect ratio should I use during the conversion?
2) Using the command that I found in this site
I was able to convert a *.avi movie and the sound and the aspect ratio are good.
I havn’t changed any command just used the initial command I found.
But when the 2 folder VIDEO_TS and AUDIO_TS
have been generated, I realize that in the AUDIO_TS
there are no files …..but in what I get the sound i good
Why?
Than you very much for all
May 24th, 2006 at 1:46 am
Just to mention K3B now has a tool for authoring dvds. You can drop the files into the coreect directory. This would save time on dvdauthor and growisofs.
September 27th, 2006 at 6:09 pm
Thanks! I was trying to do this using mencoder and that is a vast insane wasteland of confusion compared to the ffmpeg command-line options. From what I understand they both use the same libav backend anyway. Great tutorial!
October 4th, 2006 at 9:34 am
Unfortunately that ffmpeg command generates errors with high quality video files as the files generated can have “bitrate spikes” where the bitrate goes higher than the dvd player can handle, which stops lot of DVD players from playing the DVD Disc.
Also I recommend using mencoder I’m getting 60fps encoding instead of 35fps.
he’s a batch file you can use to encode dvd compliant PAL mpeg2 files
set /p inputfile=Input File:
set outputfile=c:\outpufile.mpg
rem Change fps to 29.97 if NTSC, 25 for PAL
set fps=25
set aspect=16/9
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192:aspect=%aspect%:vqmin=2:vqmax=8 -ofps %fps% -o “%outputfile%” “%inputfile%”
October 30th, 2006 at 10:25 am
Here is a great advance tutorial for converting DVD to Xvid.
Its not for 1st timmers but for those who really want that extra quality from there video.
Here is the link this tutorial is by Sujit Mohan
http://vtalk2.com/forum/index.php?showtopic=309
November 20th, 2006 at 7:58 pm
Just been using thesse instructions and was tripped up my the wild card expantion on the ‘growisofs’.
Issuing the command in the mannor described on this page caused growisfs to complain about an invalid VIDEO_TS directory.
Therefore I had to change the commmand from:
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./DVD/*
to:
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./DVD
maybe growisofs has changed since the document was written. I am using version 7.0 (mkisofs 2.01.01a05-unofficial-iconv)
Otherwise thanks for the consise DVD authoring instructions.
February 21st, 2007 at 5:47 am
Great site!
What is the method when you wish to have 2 (different) video titles on the same dvd?
February 22nd, 2007 at 11:00 pm
Art,
Just add more “-f” options to dvdauthor, one per title on the DVD.
April 25th, 2007 at 6:51 am
[...] 1. atomizedĀ [...]
June 18th, 2007 at 3:21 am
[...] do, it does it WELL. I couldn’t begin to tell you all the ins and outs of this program…Here is a good place to start if you’re looking to make DVD complaint MPEG [...]
May 15th, 2008 at 7:12 pm
The questions about output file size and vbr are actually good ones. I have an AVI file that is over 3 hours long. If I don’t specify the output size, it comes in at 6.2G after a single pass. The quality is as good as the original, but I’d like it to fit on a single layer DVD. This implies going to vbr, which means two passes.
When I tried two passes (setting -pass 1 and -pass 2 as appropriate), it created an output MPEG each time and both were the same 6.2G. I tried limiting the file size (-fs 43000000) and it just truncated the file. There is something else required that I’m missing and the man page is not exactly a model of clarity on this issue.
Any hints would be appreciated.
May 16th, 2008 at 11:20 pm
Gary, you are looking for the -b option, which will set the video bitrate. When I used this command it defaulted to a bit rate of 6000000 b/s, whereas a bitrate as low as 3000000 b/s is acceptable for most material (especially using lower resolutions)
September 4th, 2008 at 1:51 pm
Thanks for the tutorial. I downloaded an avi movie and wanted to convert it to DVD to watch it on TV. I didn’t have a DVD burner on my Linux laptop, so tried to do it at work on a windows machine using Nero. I failed two times to burn the DVD using Nero and wasted 4 hours of my time. Then I gave a try to Mac and iDVD. It comes with beautiful themes and menus for DVD, but I found that, it doesn’t do what it is supposed to do (Converting Movies). So I decided to do it using Linux and came across your tutorial. I converted my movie in less than half an hour (In nero takes 2 hours). I made my DVD schema and then transfered the whole thing to Mac computer with DVD burner. I simply burned everything as data, and got my DVD working.
If you don’t have anything on your AUDIO_TS directory, it s fine. I’m not sure, but I think that file should contains files for special sound effects.
December 28th, 2008 at 3:13 pm
Many thanks for this quick guide. I found also that the growisofs command didn’t work for me, as cited. Instead, I found I needed to use this:
growisofs -dvd-compat -speed=4 -Z /dev/dvd -dvd-video DVD
(Note the change in order of the arguments and the DVD folder path)