问题
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.
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/8915435/can-you-find-key-frame-i-frame-in-h264-video-without-decoding-i-e-is-it-in-p