tags:

views:

189

answers:

2

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.

+1  A: 

What do you want to achieve?

Is this a question how video container types are structured?

See for example : http://www.daubnet.com/formats/AVI.html

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.

Christopher
A: 

@Christopher What I’d like to do is write a program to
1. read in a video stream
2. check its extension and
3. based on its format be able to jump to the start of frame X by jumping to the Xth instance of the frame startcode for that particular video type (all compressed video will have a startcode at the start of each frame).

I don’t want to have to rely on a decoder (using DirectShow or something) to do this – i.e. should be a straightforward search through a file for the startcode for each frame.

Lehane