Fixing Broken MPEG-2 and MPEG Transport Stream (MPEG-TS) and Converting DVR-MS Files

Standard-definition (SD) and high-definition (HD) video data, packed as MPEG-2 and MPEG-2 TS or just TS in short, are transmitted digitally according to DVB-S and DVB-S2 specifications. Once received, the data is decoded to the moving picture frames displayed on the screen of the SDTV or HDTV.

The digital data packed in MPEG-2 or TS format can easily become broken during transmission and/or storing processes. A broken MPEG-2 or TS file could become quite disturbing when it’s being played or converted. Media players crash, pause, or get out of synchrony, and media converters refuse to open, partially convert, or get out of sync when dealing with such files.

Broken MPEG-2 or MPEG Transport Stream (MPEG-TS) video files are not necessarily transmitted or stored erroneously, since I’ve come across many MPEG2/TS files which are OK by the needs of say Media Player Classic – Home Cinema (MPC-HC), but have stuttering async frames when analyzed seriously.

To fix broken MPEG-2 or MPEG Transport Stream files, follow the instructions for the tools described below:

MPEG2Repair

MPEG2Repair is the lightest and fastest solution around.

Browse for the broken file, hit Find PID's, select an output file, and hit Start.

There are rare cases where its Find PID's button complains about the file being seriously broken, damaged, or incomplete: “Failed to find video PID. Try different program number or video track.” This is when you need to take either of DGIndex or Project-X steps.

VideoReDo Plus / VideoReDo TVSuite

VideoReDo Plus is proprietary software not specifically targeted to repair TS or MPEG-2 streams; a DVD authoring and editing tool, but able to do the repair as well. VideoRedo can be run in two editing modes—Cut Mode and Scene Mode.

In Cut Mode, open the broken file and from File menu, hit Save Video As..., then answer Yes to the dialog asking “There are no cuts defined. Do you wish re-mux the entire input file?” Now select your demanding output type from MPEG Program Stream (*.mpg), Elementary Streams (*.mpv), or Transport Stream (*.ts), and hit Save.

In Scene Mode however, click the Add Selection button to prepare to output the whole selection, then click FileSave Video As..., or alternatively click the Save As... button.

There are rare cases where VideoReDo Plus and VideoReDo TVSuite export only a portion of the stream, or misplace portions of the stream along the generated file, this is also desperately in need of DGIndex or Project-X to get fixed.

Aptly named VideoReDo TVSuite H.264, the new top of the line AVC-capable edition of VideoReDo supports MPEG-2 better than before. Frankly, since 2012, the entire VideoReDo product range have become more stable and don’t crop and leave the rest of problematic DVR-MS and MPEG-2 files unsaved like they frequently did back in 2010, eliminating common incomplete outputs. Looks like the message’s been heard: “professionals do not tolerate irritating shortcomings for long, they disloyally switch!”

There’s an anomaly however, that makes VideoReDo a pro’s choice instead of housewives’: VideoReDo-output files are VirtualDub-friendly rather than player-friendly. The MPG file created by VideoReDo may sound out of sync when played in Media Player Classic Home Cinema, VLC media player, etc., but you’d be amazed by how accurately lip-synched the results of its conversion via VirtualDub are.

Then as virtually troublesome as Microsoft made manipulating and even playing Windows Media Center DVR-MS files in environments other than of their own, VideoReDo TVSuite can be used as a DVR-MS to MPEG2 converter, well, transmuxer to be exact. Transmuxing is the process of changing the container format of an audio-video file while preserving the streams from the original file. Also known as container conversion, transmuxing doesn’t change the overall size of the multimedia file that much either, simply because the streams in transmuxed files are not being re-encoded.

DGIndex

DGIndex, part of DGMPGDec package, is a powerful yet easy-to-use tool primarily designed to index MPEG video streams. DGIndex is able to decode and index most MPEG1/2 streams including elementary streams, program streams, VOBs, VCDs, SVCDs, PVA files, and transport streams. More importantly—at least to us—it supports video demuxing (m1v/m2v) and audio demuxing (ac3, dts, aac, mpa, and lpcm) as well as optimized iDCTs, luminance filtering, cropping, and more.

Open the broken file, and from File menu, hit Save Project and Demux Video. For a given MPEG2-TS containing MPEG-2 video and MPEG-1 Audio Layer II, DGIndex will generate an M2V video file, plus an MP2 audio file, also kindly providing you with the audio/video delay in milliseconds as a portion of the audio file name!

The only downside to DGIndex for the rookies is DGMPGDec DGIndex demuxes container’s video and audio apart, which is actually appropriate if you’re going to open it in VirtualDub. The M1V/M2V file feeds the VirtualDub’s Open video file... and the audio file—after it’s been converted to a VirtualDub-friendly format—feeds VirtualDub’s Audio from other file....

To convert the MP2 file into a VirtualDub-friendly WAV file, use FFmpeg as follows:

ffmpeg.exe -i "input.mp2" -f wav -acodec pcm_s16le -y "output.wav"

The name of the audio file generated by DGIndex contains the audio PID, format, channel count, sample rate, bit rate, and generally ends to DELAY -{delay in milliseconds}ms (e.g., Cascada – Dangerous PID 060 L2 2ch 48 256 DELAY -362ms.mp2)

You need to put the delay preserving its sign inside VirtualDub’s audio option here: AudioInterleaving...Delay audio track by

Project-X

Project-X, a free DVB demux tool written entirely in Java, tries its best to handle and repair many stream types. Many users are looking for a Windows application, and ignore it just because it’s a Java executable (JAR), but believe me, it’s the most powerful MPEG/TS repair tool around supporting the vastest stream types.

If you’re looking for a Windows portable edition of ProjectX, just because you’re not willing to install Java Development Kit (JDK) or Java Runtime Environment (JRE), ProjectX 0.90.4.00.b32 Portable created by Dirk Paehl is downloadable here.

Please note under Aero-enabled Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2, the JRE behind Project X disables Windows Aero temporarily while it’s running, imposing Windows to show “The color scheme has been changed to Windows 7 Basic.” The reason is behind JRE’s incompatibility with Windows Aero’s composition.

Open the broken file, and on the upper-left corner of the GUI, hit QuickStart. This will demux the DVB file to a video (e.g., M2V) and an audio (e.g., MP2) file. An advantage of ProjectX over DGIndex is that the demuxed audio file using ProjectX is artificially synchronized against the demuxed video stream, so there’s no need to specify a delay value when remuxing audio/video streams together.

5 thoughts on “Fixing Broken MPEG-2 and MPEG Transport Stream (MPEG-TS) and Converting DVR-MS Files

  1. Thank you for your post. Very interesting.

    Anyway, I’m still waiting for something to fix TS’s captured from digital terrestrial TV in my country, which are not DVB.

    Here in Argentina, we use ISDB-T. The video in the TS is h264.

    Regards.

  2. If I have an audio only TS and Video only TS, what precautions should i take before muxing/combining these two split TS into one TS which has both Video and Audio packets.

Leave a Reply

Your email address will not be published. Required fields are marked *

*