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

StackOverflow https://stackoverflow.com/questions/8961982

  •  18-04-2021
  •  | 
  •  

Question

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.

Was it helpful?

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.

OTHER TIPS

Yes you can get key frame from AVPacket, there is a member in the this structure 'flags'. you can get the value by pkt.flags, for Key-frame the value will be 1, 0 otherwise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top