This will describe how I took a MPEG-TS file containing DVB data and encoded the video and audio into WebM. Extracted and then encoded the DVB subtitles into VOBSub format and then muxed the whole lot into a Matroska container.

 Acquire a DVB recording

For this I used gnutv from the dvb-apps package.
$ gnutv -channels ~/channels.conf -out file bbc-one.ts "BBC ONE Scot"

 Demux the MPEG-TS

A lot of the work required here is to simply get at the DVB subtitles. To do this I used ProjectX.

Load up the MPEG-TS file, all the default settings should be fine. You can use the controls under the CutControl tab to trim your file down to just the bit you want. Use the navigation buttons and the top left icon in the Cut Points frame to set the cut points.

Note: Ignore the Outside Export Range that comes up in red, not sure exactly why it says that but it didn't seem to have any adverse effect.

Once done, click prepare >>. You can review the settings (they should be OK) and then click the Play/Pause button.

This will produce several files, including at least one video (.m2v), audio (.mp2) and one subtitle file (.sup) and a subtitle IFO file.

e.g I got the following

bbc-one.m2v		- MPEG sequence, v2, MP@ML interlaced Y'CbCr 4:2:0 video, CCIR/ITU PAL 625, 4:3, 25 fps
bbc-one.mp2		- MPEG ADTS, layer II, v1,  64 kbps, 48 kHz, Monaural
bbc-one-02.mp2		- MPEG ADTS, layer II, v1, 192 kbps, 48 kHz, Stereo
bbc-one.sup		- Subtitles
bbc-one.sup.IFO		- Subtitles info

 Convert the subtitles into VOBSub

Next we need to convert the subtitles into something we can put into Matroska (or at least that mkvmerge will allow).

VOBSub is what is used on DVD's and is just another mpeg file that is overlayed on top of the main video (if subtitles are enabled).

For this task I used BDSup2Sub.

The version I used (5.0.0) needed some of the above files under a slightly different name.

$ ln -s bbc-one.sup.IFO bbc-one.sup.ifo
$ ln -s bbc-one.sup bbc-one.sup.sup
sorted that out. Now run BDSup2Sub
$ java -jar BDSup2Sub.jar
Load up the IFO file (i needed to use bbc-one.sup.ifo)

I ignored the error I got and dismissed the settings pop-up window. Then I simply went to File -> Save/Export and clicked Save.

This produces another couple of files, a .idx and .sub. I got


 Create a WebM

Next I created a WebM file for the video and audio with
$ ffmpeg -i bbc-one.m2v -filter:v yadif -b:v 1200k -i bbc-one-02.mp2 -ab 112k bbc-one.webm
Note: I used the bbc-one-02.mp2 file for the audio, the other one was some visually impaired commentary track.

 Put all this into a Matroska container

Now we need to put the video/audio/subtitles into a Matroska container (WebM can only contain VP8/9 video and Vorbis audio). For this I used mkvmerge from the MKVToolNix package.
$ mkvmerge -o bbc-one.mkv bbc-one.webm bbc-one.sup_exp.idx
This will give you your end product: bbc-one.mkv
$ mkvmerge -i bbc-one.mkv 
File 'bbc-one.mkv': container: Matroska
Track ID 0: video (V_VP8)
Track ID 1: audio (A_VORBIS)
Track ID 2: subtitles (S_VOBSUB)

Andrew Clayton; Thu Dec 19, 2013