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

7May/10Off

Burning MPEG2-TS to a DVD

For years, i have been using my dreambox to record TV shows and enjoy them when I fancy. I especially like the fact that i can skip commercials. Anyway, a while ago a good friend asked if I could make a DVD out of a documentary I had recorded on the box's HDD.

"no problem, I'll burn it rightaway", I answered ...

could I be more foolish ?

It took me more than a month to figure out what were the steps requested to achieve this. At the beginning, I was thinking that simply building a DVD structure (dvdauthor) out of the MPEG2 Transport Stream picked up from the receiver would work. After all, a DVD player can read MPEG2, and everything needed is inside the file, including the video track, the audio in 2 languages and the subtitles !

DVD players can only read MPEG2 Program Streams and what you get from a DVB tuner are Program Streams, totally different beasts !

Some background about MPEG2

The MPEG2 standard defines two kind of containers for a variety of streams that are multiplexed (or muxed) together. Transport streams (MPEG2-TS) are used by most broadcasted programs such as DVB (-S for satellite, -T for terrestial, ...) and Program Streams (MPEG2-PS) for anything that could be contained in file-based storage (with a beginning and an end). As stated in this Wikipedia article, the two formats are "different, but related", and for this reason, you can't just dump a program you've recorded on a DVD and hope that your player will be happy with it.

Additionally, TS are inherently resistant to broadcasting errors (reception problems, rain on the satellite dish, etc ...), and have support to allow players to resynchronize the video and audio tracks when it jumps. PS don't provide that, and just converting the TS to a PS would progressively make the video and audio out of sync when playing it back.

Making a proper PS for inclusion in a DVD from a TS requires a lot of steps that I'm going to describe in this article. Hold your breath :-)

My requirements for this DVD-burning project are:

  1. being able to watch movies with their original soundtrack. I just can't bear the french soundtrack they make us endure in France (and it's actually a law here. You can't broadcast movies with the original soundtrack before very late at night if you're not a premium channel)
  2. subtitles. I can enjoy most movies in english, but i like to have subtitles. Movies recorded from DVB streams in France, contain, in a very old-fashioned way, another MPEG stream, containing teletext encoded text on a special page (889 for french). Mind it, your DVD player will not be happy with those either !

I have found many user-friendly tools with nice GUI such as MPEGStreamClip for OSX, that would have allowed me to perform most of the step outlined below, but they always fall short on some of my requirements. For instance I could not make MPEGStreamClip include subtitles from the teletext stream into the file it produces. Other solution will not allow you to keep the original soundtrack. So my solution involves a lot of command-line tools and needs you to be pretty familiar with UNIX, and not afraid by a terminal window.

Something worth noting: With the recent advent of high-definition, decoders such as Free's FreeBOX-HD still produces MPEG2-TS files, but with the video track encoded using the H-264 codec. I couldn't make ProjectX cut/edit those files but it can still demux them. I've not tried that, but converting the video to MPEG-video and follow the same process should be possible. I guess you would have to re-encode them with a lower resolution, as MPEG2 in HD would use a HUGE amount of space and would certainly not fit in a 4.7GB DVD

You've been warned and can go on reading :-)

The tools we'll need

  • ProjectX: the swiss-army knife of MPEG-2. The interface is not very intuitive, but after a while, you can figure it out pretty easily and get it to do what you want. We're going to use this tool to extract the video, audio and subtitle tracks from the TS.
  • mplex: part of the mjpeg-tools, this command-line tool allows to build a DVD-compliant Program Stream using the different tracks extracted using ProjectX
  • spumux: part of the dvdauthor suite, allows you to add a dvd-compliant stream of subtitles from many different format (including subrip files !) to a MPEG2-PS
  • dvdauthor: will build the standard DVD structure (AUDIO_TS and VIDEO_TS folders) from a MPEG2-PS

Say we downloaded a file named "stream.ts" from our decoder. Our goal is to use it to produce a valid DVD structure from it. In my serie of articles, I am going to walk you through converting that TS to a valid DVD structure that you can use to burn a DVD for your hardware DVD player.

Episode 1: Edit cutpoints and de-mux with ProjectX
Episode 2: Multiplex the resulting streams into a DVD-compatible PS using mplex
Episode 3: adding the subtitles

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.