Create a DVD from .MPG and add subtitles using Spumux in bash.

Packages needed: FFmpeg, spumux, dvdauthor. And maybe mkisofs to create a dvd iso. Or growisofs to burn directly. (If you need to identify your video, install Mplayer.

user@server:$ yum install ffmpeg spumux dvdauthor mkisofs growisofs mplayer

First we need a .mpg or .mpeg file. For example if you have an .avi file, convert this to .mpg (change pal-dvd to ntsc-dvd if needed)

user@server:$ ffmpeg -i movie.avi -target pal-dvd movie.mpg

Now we have the .mpg file we can set up the XML files with the settings for the conversion. Create spumux.xml and add the following settings into it.

<subpictures>
   <stream>
      <textsub filename="yoursubsname.srt" characterset="ISO8859-1"
        fontsize="28.0" font="arial.ttf" horizontal-alignment="left"
        vertical-alignment="bottom" left-margin="60" right-margin="60"
        top-margin="20" bottom-margin="30" subtitle-fps="25"
        movie-fps="25" movie-width="720" movie-height="576"
     />
   </stream>
</subpictures>

You have to replace the filename, movie-width and the movie-height to your video preferences. You have seen them while converting if not use this command.

user@server:$ mplayer -identify output.mpg

Now before we start processing, we need arial.ttf in our .spumux folder. If you don’t have a .spumux folder, create one;

user@server:$ mkdir ~/.spumux

OK — now we are all set, what you have to do now is use the following command.

user@server:$ spumux spumux.xml < out.mpg > output.mpg
DVDAuthor::spumux, version 0.6.11.
Build options: gnugetopt iconv freetype
Send bugs to

INFO: Locale=en_US.UTF-8
INFO: Converting filenames to UTF-8
INFO: Detected subtitle file format: subviewer
INFO: Opened iconv descriptor. *UTF-8* *ISO8859-1*
INFO: Read 1340 subtitles
INFO: Adjusted 39 subtitle(s).
INFO: Unicode font: 1418 glyphs.
INFO: Found EOF in .sub file.
WARN:  Read 0, expected 4
INFO: 1340 subtitles added, 0 subtitles skipped, stream: 32, offset: 0.50

Statistics:
- Processed 1340 subtitles.
- The longest display line had 48 characters.
- The maximum number of displayed lines was 3.
- The normal display height of the font arial.ttf was 32.
- The bottom display height of the font arial.ttf was 45.
- The biggest subtitle box had 4470 bytes.

Alright, when this is done we have to make another .xml file. Create dvd.xml and put this in there.

<dvdauthor dest="DVD">
  <vmgm />
   <titleset>
     <titles>
       <pgc>
         <vob file="output.mpg"/>
       </pgc>
     </titles>
   </titleset>
</dvdauthor>

Obviously you have to change the vob file to your output video name. When you have done that we can do the following command.

user@server:$ dvdauthor -x dvd.xml
DVDAuthor::dvdauthor, version 0.6.11.
Build options: gnugetopt iconv freetype
Send bugs to

INFO: Locale=en_US.UTF-8
INFO: Converting filenames to UTF-8
INFO: dvdauthor creating VTS
STAT: Picking VTS 01

STAT: Processing output.mpg…
STAT: VOBU 12080 at 4249MB, 1 PGCS
INFO: Video pts = 0.500 .. 5813.060
INFO: Audio[0] pts = 0.500 .. 5813.172
INFO: Audio[32] pts = 5.660 .. 5760.406
STAT: VOBU 12086 at 4250MB, 1 PGCS
INFO: Generating VTS with the following video attributes:
INFO: MPEG version: mpeg2
INFO: TV standard: pal
INFO: Aspect ratio: 4:3
INFO: Resolution: 720×576
INFO: Audio ch 0 format: ac3/6ch, 48khz drc

STAT: fixed 12086 VOBUS
INFO: dvdauthor creating table of contents
INFO: Scanning DVD/VIDEO_TS/VTS_01_0.IFO

You have just created a dvd including subtitles which you can enable or disable. What you got to do now is simply make a ISO or burn it directly to your blank dvd.

To make a ISO you can use this command:

user@server:$ mkisofs -dvd-video -o name-your-dvd.iso DVD/
97.40% done, estimate finish Fri Nov 13 08:53:17 2009
97.63% done, estimate finish Fri Nov 13 08:53:16 2009
97.86% done, estimate finish Fri Nov 13 08:53:17 2009
98.09% done, estimate finish Fri Nov 13 08:53:17 2009
98.32% done, estimate finish Fri Nov 13 08:53:16 2009
98.55% done, estimate finish Fri Nov 13 08:53:17 2009
98.78% done, estimate finish Fri Nov 13 08:53:16 2009
99.01% done, estimate finish Fri Nov 13 08:53:16 2009
99.24% done, estimate finish Fri Nov 13 08:53:16 2009
99.46% done, estimate finish Fri Nov 13 08:53:15 2009
99.69% done, estimate finish Fri Nov 13 08:53:15 2009
99.92% done, estimate finish Fri Nov 13 08:53:16 2009
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 4096
Path table size(bytes): 42
Max brk space used 15000
2176659 extents written (4251 MB)
[user@server]$

If you want to burn it directly without making a .iso then use this command; (Replace /dev/scd0 with the device path to your DVD recorder)

user@server:$ growisofs -Z /dev/scd0 -dvd-video DVD/
| More

Comments

  1. 1

    Hmm – nice! Subtitles are just great!

    BTW – New design is so nice too.


    MrcredsAlex
    Nov 18th, 2009