DVB TS stream to MKV with MP3/H.264 encoding
This quick How-To solves the problem how to convert a DVB stream present as a transport stream file (.ts) into a low-size but still high-quality format using linux operating systems for the purpose of playback on a PC or similar hardware.
Software requirements
Install as recommended on your linux dirstribution (emerge, aptitude, etc.) or by simply downloading the source code (and if necessary compile/install in the usual manner).
- avidemux
- Lame
- ProjectX
- MPlayer and Menconder
- x264 library
- mkvmerge (part of mkvtoolnix)
Cutting
I personaly like the avidemux tool for cutting to get rid of advertisement and the other stuff at the beginning and ending of the stream.
Demuxing
java -jar ProjectX.jar -demux MyTVDub.ts
Encoding
Sound
lame MyTVDub.mp2
will create a MyTVDub.mp2.mp3 with 48kHz sampling rate with 128kbit/s bitrate audio file with about 50% decrease of size. If you have recorded multiple audio streams repeat with the other mp2 files. f you have AC3 multichannel sound files simply add them when you are muxing the matroska file (see below).
Video
mplayer -vf cropdetect MyTVDub.m2v
Copy what looks like "720:560:0:10" and replace it in the current line
mencoder MyTVDub.m2v -o MyTVDub.H264.m2v -oac copy -vf crop=720:560:0:10 -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:crf=22.0
This will now encode the TS video stream into a high quality H.264 encoded video file. Note that its hard work for the CPU, depending on the number of cores and frequency they can operate this may take some hours.
Muxing
mkvmerge --title "My DVB rec" --default-language ger -o MyTVDub.mkv --language 0:ger MyTVDub.H264.m2v --language 0:ger MyTVDub.mp2.mp3
If you have multiple audio streams simply append another
--language 0:en MyTVDub[0].mp2.mp3
or
--language 0:ger MyTVDub[1].ac3
in order to mux them into the matroska container.

Zurück: Deutscher Klaus mag gerne Bier
