This is an old revision of the document!
This page tries to give hints about editing captured MPEG files. These captured MPEGs are generally from DVB S/T (in MPEG TS format) or from IVTV based cards or any other card with hardware MPEG-2 encoding (in MPEG PS format).
These captures often contain transmission errors which end up as missing or broken frames. A player (MPlayer, xine, VLC) will constantly resync the streams using the timing information embedded in the stream. Avidemux will not.
Apart from the constant shift, which is easily recoverable using the timeshift filter, it will result in a growing synchronisation issue when encoding or transcoding. Even saving without re-encoding will be async.
MythTV recordings are a prime example of this problem. If the process below is not followed the audio will be offset by approximately -330 ms at the start of the recording and the drift throughout the duration of the recording. Please note that not all MythTV recordings have this problem, just some depending on the software and hardware configuration.
The only 100% reliable way to do it is to use ProjectX (see the ProjectX tutorial). It takes a bit of time but is easily scriptable, an example script is available from here. Let's say you have a DVB file called 2537_20060819203500.mpg in MPEG TS format (DVB-T) capture.
First we will demultiplex the file into elementary streams, but synced elementary streams
That will generate one file per elementary stream with the following extensions:
Now we must recombine these streams, into PS format for example.
mplex -f 8 -o output_file.mpg 2537_20060819203500.ac3 2537_20060819203500.m2v 2537_20060819203500.mp2
The resulting file (output_file.mpg) can be edited in Avidemux (remove commercials for example) or transcoded to any formats without sync issue.
ProjectX is very reliable to resync the streams. For information, it will dupe missing audio frames or create empty video frames when they were dropped.
Up to date versions of mplex for Win32 systems are hard to find, however ImagoMPEG-Muxer is a perfect substitution.
If you encode to other format (MPEG-4,…), you will probably want to go to Preferences and select Input→Use libavcodec MPEG decoder. libavcodec contains code to try to hide decoding errors. So instead of having a green block, you will have a mostly correct but blurred block, which is much more pleasing to the eye.