Zuzur's corner technology, the web, programming and a bit of this and that …

16May/10Off

Burning MPEG2-TS to DVD – E03 – adding the subtitles

DVD subtitles aren't text, hardware players don't support rendering text into fonts, so you have to insert images that will be displayed by the player at the right time.

When demuxing our TS in the first article, we have extracted the subtitles in subrip format. We now need a tool that will create another MPEG2 track that contains images of the subtitles, rendered with the right font.

spumux, part of the dvdauthor suite does this job fairly well. Again, use your package manager to install dvdauthor and you should be able to use it.

XML subtitles descriptor

spumux uses an XML descriptor file that helps it render the subtitles. You specify the location of the subrip file, its charset, the font that will be used for rendering the text, and various other parameters for the location of the subtitles.

Here is the content of the file named stream-subs.xml we are going to use for this project.

       <subpictures>
          <stream>
             <textsub filename="stream[889].srt" characterset="ISO8859-1"
                fontsize="28.0" font="arial.ttf" horizontal-alignment="center"
                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="574"
                force="yes"
             />
          </stream>
       </subpictures>
$  spumux -P stream-subs.xml < stream.ps > stream-with-subs.ps
DVDAuthor::spumux, version 0.6.14.
Build options: gnugetopt magick iconv freetype
Send bugs to 
 
INFO: Locale=fr_FR.UTF-8
INFO: Converting filenames to UTF-8
INFO: Detected subtitle file format: subviewer
INFO: Opened iconv descriptor. *UTF-8* *ISO8859-1*
INFO: Read 1267 subtitles
INFO: Unicode font: 242 glyphs.
INFO: Found EOF in .sub file.a written
INFO: 1267 subtitles added, 0 subtitles skipped, stream: 32, offset: 0.12
 
Statistics:
- Processed 1267 subtitles.
- The longest display line had 37 characters.
- The maximum number of displayed lines was 2.
- The normal display height of the font arial.ttf was 32.
- The bottom display height of the font arial.ttf was 38.
- The biggest subtitle box had 3118 bytes.

When spumux finishes processing, you should have a stream-with-subs.ps file in your current working directory, and you should be able to test that it displays properly using VLC or your media player (VLC won't recognize the subtitles stream in the resulting PS, but don't worry, spumux has inserted it properly.

Fonts

Not liking Arial too much, I am still looking for the best font for the job, spumux comes with a set of fonts coming from the mplayer project, if you want to try out other fonts, they just have to be in ~/.spumux just copy/link the .ttf files there.

Timing issues

Sometimes the subtitles are offset a bit and do not display at the right time. I have found a very handy tool named Sears that will allow you to edit the subtitles, change the text or timing, and more importantly offset the whole batch by one or 2 seconds if necessary.

Now it's time to move on the final step of our DVD authoring. Creating the DVD structure from the resulting MPEG2-PS.

Back to the summary article
Episode 1: Edit cutpoints and de-mux with ProjectX
Episode 2: Multiplex the resulting streams into a DVD-compatible PS using mplex
Episode 4: authoring the DVD

Tagged as: , , Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.