Making DVD/SVCD/VCD's under Linux
From CLUG Wiki
This is a new page, and might contain technically incorrect information. Please use at your own risk. If you are able to correct any errors or expand this document, please do so.
Warning: This is a Debian-centric page
This page is written by a Debian user with Debian in mind. Thus, he liberally uses apt-get, and assumes that
everything will work exactly the same for you.
If you don't run Debian (or something based on it like Ubuntu), it won't, so please find the differences and add them to this page.
Contents |
Intro
Documenting my travels into the realm of multimedia. This is my approach (for now at least) to making DVDs, VCDs and SVCDs under a Linux environment. Instructions are for Debian(ish) systems, but it shouldn't be to hard to get it working under any GNU/Linux OS.
Get the Necessary Tools
For encoding to MPEG2 I'll be using MPlayer+MEncoder
I compiled MPlayer from source, so just get the tarball from the above mentioned site, extract, run configure and install everything that it asks for.
For Debian you can simply do:
# apt-get install mplayer-586 mencoder-586
You can substitute "586" for your system architecture. Simply do:
$ apt-cache search '(mplayer|mencoder)'
to find the right packages.
Apt will also install all the necessary libraries for encoding/decoding AVI/MPEG streams and all the other nonsense.
Next we need to get DVDAuthor to create the DVD structures for you:
# apt-get install dvdauthor
You also need dvd+rw-tools
# apt-get install dvd+rw-tools
OK, so you can (probably) apt-get all this done by doing :
# apt-get install mplayer-586 mencoder-586 dvdauthor dvd+rw-tools
Converting Movies to MPEG2
Before you can use DVDauthor (or k3b or whatever to burn (S)VCDs for you), you first need to convert whatever format you got the relevant MPEG2 format.
Also, we use PAL over here, so these commands are centered around that.
A basic MEncoder command-line to encode a file to MPEG2 for DVD will look something like this
$ mencoder -oac <audio-codec> -ovc lavc -of mpeg -mpegopts format=dvd \ -vf scale=<X>:<Y>,harddup \ -lavcopts vcodec=mpeg2video:vrc_buf_size=<buffer>:vrc_maxrate=9800:\ vbitrate=5000:keyint=15:aspect=<aspect> \ -ofps 25 -o outfile.mpg infile.avi
First, lets get some info about the file we'll be converting:
$ mplayer -vo dummy -identify yourmovie.avi 2> /dev/null
This should give you some information on the file. Here's one for an AVI I got:
AVI file format detected. ID_VIDEO_ID=0 ID_AUDIO_ID=1 VIDEO: [DIV3] 352x288 24bpp 29.970 fps 428.7 kbps (52.3 kbyte/s) ========================================================================== Opening audio decoder: [mp3lib] MPEG layer-2, layer-3 AUDIO: 48000 Hz, 2 ch, 16 bit (0x10), ratio: 12000->192000 (96.0 kbit) Selected audio codec: [mp3] afm:mp3lib (mp3lib MPEG layer-2, layer-3) ========================================================================== ID_FILENAME=mymovie.avi ID_VIDEO_FORMAT=DIV3 ID_VIDEO_BITRATE=428720 ID_VIDEO_WIDTH=352 ID_VIDEO_HEIGHT=288 ID_VIDEO_FPS=29.970 ID_VIDEO_ASPECT=0.0000 ID_AUDIO_CODEC=mp3 ID_AUDIO_FORMAT=85 ID_AUDIO_BITRATE=96000 ID_AUDIO_RATE=48000 ID_AUDIO_NCH=2 ID_LENGTH=1478
Now, the above gives us some interesting information regarding the the file we want to encode
My file above has got a MP3 soundtrack, but we want it in AC3, so, to make a DVD compatible MPEG2 output for it, I shall do the following
$ 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=16/9 \ -ofps 25 -o outfile.mpg mymovie.avi
this will give me outfile.mpg
to see how it looks now try:
$ mplayer -vo x11 outfile.mpg
MPEG2 DVD From AVI with Existing AC3 Soundtrack
If MPlayer reports that your AVI file already has AC3 encoded surround sound, you can do the following to preserve it (and avoid re-encoding it):
$ mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd \ -vf scale=720:576,harddup \ -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:\ vbitrate=5000:keyint=15:aspect=16/9 \ -ofps 25 -o outfile.mpg mymovie.avi
MPEG2 DVD from AVI
$ 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=16/9 \ -ofps 25 -o outfile.mpg mymovie.avi
MPEG2 VCD from AVI
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd \ -vf scale=352:288,harddup -srate 44100 -af lavcresample=44100 \ -lavcopts vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:\ vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 \ -ofps 25 -o outfile.mpg mymovie.avi
Mpeg2 SVCD from AVI
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd \ -vf scale=480:576,harddup -srate 44100 -af lavcresample=44100 \ -lavcopts vcodec=mpeg2video:mbd=2:keyint=15:vrc_buf_size=917: \ vrc_minrate=600:vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 \ -ofps 25 -o outfile.mpg mymovie.avi
Getting the Stuff on the Disk
DVDs
To get your shiny new MPEG2s on your DVD+/-R disc we'll first need to create the DVD structures and then use growisofs to burn them to your disc.
Using DVDAuthor to create DVD structures
dvdauthor takes two arguments that you have to worry about for now:
- -o
- output directory
- -x
- input xml file
Here is a basic xml file (that does work):
<dvdauthor>
<vmgm>
<menus>
<video format="pal" aspect="16:9" resolution="720x576" widescreen="nopanscan" />
<audio />
<pgc entry="title" pause="inf">
<button name="1">jump title 1;</button>
</pgc>
</menus>
</vmgm>
<titleset>
<titles>
<pgc>
<vob file="mymovie.mpg" chapters="0,1:01,5:01,10:01,15:01,20:01,25:01" />
<post>call vmgm menu 1;</post>
</pgc>
</titles>
</titleset>
</dvdauthor>
Basically, you specify your menus and stuff, along with video and audio options. If you don't specify video and audio options, DVDAuthor will try and grab it from the file that you supply.
For more info on this, check out the xml file format:
$ man dvdauthor
Now you need to create a working directory for DVDAuthor:
$ mkdir -p dvd
Once you have created your XML file and working directory, all you need to do is:
$ dvdauthor -o dvd/ -x myxmlfile.xml
and watch the magic!
After it finishes it you should be left with something like this:
$ ls -lr dvd/* dvd/VIDEO_TS: total 523544 -rw-r--r-- 1 foo bar 535496704 2006-02-07 20:57 VTS_01_1.VOB -rw-r--r-- 1 foo bar 28672 2006-02-07 20:57 VTS_01_0.IFO -rw-r--r-- 1 foo bar 28672 2006-02-07 20:57 VTS_01_0.BUP -rw-r--r-- 1 foo bar 12288 2006-02-07 20:57 VIDEO_TS.IFO -rw-r--r-- 1 foo bar 12288 2006-02-07 20:57 VIDEO_TS.BUP dvd/AUDIO_TS: total 0
You can verify if everything works before burning the disk, using xine. Xine allows to play a dvd content from the local filesystem instead of the disk:
$ xine dvd://`pwd`/dvd
You can now use Growisofs to burn it to disc:
$ growisofs -Z /dev/dvd -dvd-video dvd/
Executing 'mkisofs -dvd-video dvd/ | builtin_dd of=/dev/dvd obs=32k seek=0'
INFO: UTF-8 character encoding detected by locale settings.
Assuming UTF-8 encoded filenames on source filesystem,
use -input-charset to override.
/dev/dvd: "Current Write Speed" is 4.1x1385KBps.
Viola! Freshly Roasted DVDs.
SVCDs and VCDs
- TODO
- add cmdline way to do this
Notes
If you have trouble with the aspect ratio being out of bounds, try
setting the aspect="" attribute in the DVDAuthor xml file to "4:3"
Links
- MPlayer and MEncoder
- Home Page
- English Docs (far better info) (see also the
mplayer-docpackage)
