Sunday, October 11, 2009

Quick DVD authoring, with subtitles

Let's say you have a DivX movie (movie.avi) and a subtitles file (subtitles.srt) and you want to burn this into a DVD, which any player (non divx-capable) can play.

This is called DVD authoring, and there are many tools to do the job (though I have not found one that I really like, yet). For such a simple task, a few commands on the console are the simplest option.

1. Transcode move to MPEG-2

See the mencoder documentation at the end - it contains examples for other formats.
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
-vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 \
-lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 \
-o movie.mpg movie.avi


2. Render and multiplex subtitles into movie

Create a file like this one, and save it as sub.xml:
<subpictures>
<stream>
<textsub filename="subtitles.srt" characterset="ISO-8859-1"
fontsize="22.0" font="devedesans.ttf"
horizontal-alignment="center"
vertical-alignment="bottom" left-margin="60"
right-margin="60"
top-margin="20" bottom-margin="40" subtitle-fps="25"
movie-fps="25" movie-width="720" movie-height="574"/>
</stream>
</subpictures>
Run spumux to create a new mpeg file with the subtitles stream:
spumux -s0 sub.xml < movie.mpg > m_subs.mpg


3. Author the DVD


Finally, we need to tell dvdauthor how to create a dvd. Create a file dvd.xml like this one:
<dvdauthor>
<vmgm>
<titleset>
<titles>
<subpicture lang="es">
<pgc>
<vob file="m_subs.mpg">
</pgc>
</titles>
</titleset>
</dvdauthor>
And run dvdauthor:
dvdauthor -o thedvd -x dvd.xml


4. Round up


Voila! The directory thedvd will contain the DVD structure (not an ISO image). You can test the results with mplayer:
mplayer dvd:// -dvd-device thedvd

and if it looks ok, just burn it into a dvd - k3b can burn this (use new Project -> movie DVD)

At the end you can delete *.mpg files, and the thedvd directory.

References:


  • mencoder on dvd authroing: http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-vcd-dvd.html
  • spumux: http://dvdauthor.sourceforge.net/doc/spumux.html

No comments:

Post a Comment