Search code examples
mpeg-4

Can you find key frame (I-frame) in h264 video without decoding? i.e. is it in packet?


I need to know if I can find a I-frame without having to decode it first. I would like there to be some flag in AVPacket, but I can't see that there is one.

Thanks.


Solution

  • You can certainly find location of I frame by looking up appropriate header code. If you parse the sequence you can find it from the start code.

    The H.264 bitstream is broken into sections called NAL units. These units have the 24 bit code 0x000001 preceding them for synchronization. After this there will be a unique start code that corresponds to start of a picture, and type of picture based on which you can decide which frame is this.