How can I convert and repair MPEG-TS (DVB-S captures) for better playback?

I have a lot of MPEG-TS video files (H.264 video with AC3 or MP3 in a .TS container) captured from a DVB-S capture card.

When I play these videos it's much slower to seek in the video (ie. skip 30 seconds, etc) than with other files.

I'm not sure if the problem is the H.264 encoding (reference frame count?) or the MPEG-TS container, or if the MPEG-TS file contains sync errors, etc.

Does anybody have a good workflow for converting and repairing these files?


Solution 1:

The seek intervals depend on how often the Transport Stream sends synchronization information. This really depends on how it was created – the MPEG TS allows to individually set this interval and in your case, it's probably just missing. I'm not sure if it's easy enough to fix an existing TS file, so I'd rather convert the Transport Stream to a more user-oriented container like:

  • MKV
  • MP4
  • MOV

Note that AVI is not an option since its support for h.264 is … well, not good.


Your first option is to try and copy the raw audio and video bitstreams. With FFmpeg, this is as simple as:

ffmpeg -i input.ts -c:v copy -c:a libfaac out.mp4

You can install FFmpeg on Windows by downloading a build, in OS X through Homebrew with brew install ffmpeg, and on Linux by compiling from source.

If you want to reduce the size of the video, you can try to set a Constant Rate Factor (something like "constant quality") and re-encode it using x264, the most popular h.264 encoder:

ffmpeg -i input.ts -c:v libx264 -crf 24 -c:a libfaac out.mp4

Set CRF to anything between 19 and 25, or even more. The more, the worse the quality, but the smaller the file size.