This article covers MPEG-1 and MPEG-2 video formats. For MPEG4, see dedicated article.
MPEG can be confusing as it refers to a standard, a container format, and also to several video and audio codecs.
In this article, we will talk about MPEG media, video and audio.
MPEG is usually stored inside the .mpg container format. QuickTime .mov files can also contain MPEG media.
In DVD Video disks, the MPEG movie is inside a .VOB container.
MPEG-1 and MPEG-2 are two video formats that were defined and standardized in the early 90's.
- Used in VideoCD, DVD, digital TV and Internet for distribution of contents.
- Used in some digital cameras and video cameras for capture. Not suited for edition.
- Used in some set-top box to record analog TV signal in your computer.
MPEG files can be Program Stream or Transport Stream.
How to repair a damaged MPEG file?
MPEG files are relatively easy to repair, because they were designed for robustness. One of the requisites was that a MPEG signal can be broadcasted (satellite, TV, internet) and decoded despite errors, interferences, small connection loss, ...Example:
MPEG-1 file, 640x480, that was recovered by a data recovery software. It doesn't open.In MPEG files, the data blocks start with 00 00 01 xx where xx indicates which kind of block it is.
The MPEG files shall start with a certain header, that gives information about what video and audio streams it contains.
00 00 01 BA ... is usually the first block (called Pack Header)
00 00 01 BB is a System Header, and should be found nearby. It describes the audio and video streams of the file.
00 00 01 C0 is an audio block
00 00 01 E0 is a video block header.
00 00 01 00 to 00 00 01 AF are consecutive video data blocks that form a frame.
The first video block header should be followed by those two blocks:
00 00 01 B3 is a Sequence Header. Mandatory before first frame
00 00 01 B8 indicates a Group of Pictures.
Therefore, a common method to repair an MPEG file, is to rebuild the System Header and Sequence Headers that are missing:
- Find a Pack Header (search for 00 00 01 BA) followed by a Group of Pictures (00 00 01 B8). Followed means that no other 00 00 01 E0 or 00 00 01 BA structure is found in between.
- Delete all the data from beginning of file until 00 00 01 BA, keeping 00 00 01 BA as first bytes of the file.
- Insert a valid System Header just after the Pack Header, i.e. just before the next 00 00 01. This system header is usually around 20 bytes in length, and starts with 00 00 01 BB. If you cannot find it in the damaged file, take it from a good file recorded with the same settings (format, pixel size, ...)
- Just before the first Group of Pictures (00 00 01 B8), insert a valid Sequence Header. This system header is usually around 100 bytes in length, and starts with 00 00 01 B3. If you cannot find it in the damaged file, take it from a good file recorded with the same settings (format, pixel size, ...)
- Save the file and give it a name with suffix .mpg
This procedure works in most cases.