Video Codec startcodes


Does anybody know (or know of a resource that contains) a list of frame start codes for common video formats (MPEG-1/2/4, .wmv, .mov etc.).

For example, an MPEG-1 video frame will (I think) always start with "00 00 01 00".

In essence I'd like to know these so that I could write a program that can automatically find the start of frames throughout a video for a number of different video formats.

Best Solution

What do you want to achieve?

Is this a question how video container types are structured?

See for example :

That is a description how avi files are structured. Google may help you in finding other container file formats.

When you record a video, it is normally composed of individual frames, think of individual bitmap files in a directory.

To only have 1 file of a video, this stream of frames is put in a container, which has a header describing the contents and a certain layout in which the frames are stored sequentially in the file.

Simple example for my own container :

   struct header
      unsigned int frametype;
      unsigned int framesize;

   byte*  readFrame( header* pHdr, int frameNum )
       byte* pFirstFrame = ((byte*) pHdr) + sizeof( header );
       return pFristFrame + frameNum * pHdr->framesize;

There are several other container types. AVI is only one of these container types. To get to the individual frames you must interpret the header in the file and then based on that information calculate the position of the frame you want to parse.

I posted you a link to the definition of the avi file format. There are other places where you can get information on the mpeg/mkv/ogm file formats.

You need this information to get your program to work.

On a side note, compressed formats do not safe all individual frames independently. They safe an individual frame and then several intermediate frames, which only contain the information on how the current frame differs from the last complete frame. So you cannot extract complete frames at every frame number.