I have a bunch of MPEG-TS files, originally created by a hardware TV-recorder.
ffprobe lists their content like so:
Input #0, mpegts, from 'recording.ts': Duration: 02:14:57.67, start: 87544.254878, bitrate: 4386 kb/s Program 12003 [...] Program 12060 Stream #0:0[0xa7]: Video: mpeg2video (Main) ( / 0x0002), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x88](ger): Audio: mp2 ( / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s (clean effects) Stream #0:2[0x48]: Unknown: none ( / 0x0005) Stream #0:3[0x47](ger): Subtitle: dvb_teletext ( / 0x0006) Stream #0:4[0x4a](deu): Subtitle: dvb_subtitle ( / 0x0006) Stream #0:5[0xfb]: Unknown: none ( / 0x000B) Stream #0:6[0xfc]: Unknown: none ( / 0x000C) Program 12061 [...] Program 12095 Unsupported codec with id 0 for input stream 2 Unsupported codec with id 94215 for input stream 3 Unsupported codec with id 0 for input stream 5 Unsupported codec with id 0 for input stream 6
I want to re-encode these files for archiving, at the same time
trimming unnecessary runtime before movie start and after end:
-tcut out segments, the
concatprotocol merges them together seamlessly without re-encoding.
cutting out advertisement blocks: The
trimfilter cuts with frame-precision.
cropping away letterboxes: The
cropfilter eliminates black bars.
The resulting command line looks somewhat complex. It cuts out audio and video of two segments, resets PTS for continuity, concatenates and crops them. All of this is then encoded and merged into an MKV container.
ffmpeg -i in.ts -filter_complex ' [0:0]split[v1][v2]; [0:1]asplit[a1][a2]; [v1]trim=288.520:4957.640,setpts=PTS-STARTPTS[vo1]; [a1]atrim=288.520:4957.640,asetpts=PTS-STARTPTS[ao1]; [v2]trim=5155.360:6948.440,setpts=PTS-STARTPTS[vo2]; [a2]atrim=5155.360:6948.440,asetpts=PTS-STARTPTS[ao2]; [vo1][vo2]concat,crop=720:432:0:72[v]; [ao1][ao2]concat=v=0:a=1[a]; ' -map '[v]' -map '[a]' -c:v libx264 -c:a libvorbis out.mkv
All of this works so far. But, as seen above, the original file also contained subtitles, on stream 4, encoded as
dvb_subtitles. I now want to incorporate these into the filtergraph.
I already tried to add
concat steps for the stream and a corresponding
-map. This works fine, but encodes the subtitles with x264 resulting in additional video stream. So I added
-codec:2 dvbsub and get
Invalid encoder type 'dvbsub', despite
ffmpeg -coded lists
dvbsub as both an encoder and decoder.
How can I keep the subtitles throughout this process? A pure
ffmpeg solution would be perfect, but perhaps another tool is able to handle the subtitles better.