需要从关键帧开始解析。
判断关键帧方法
通过AVPacket中的标志来判断
如何判断当前AVPacket是否为关键帧呢?
答案是: 通过AVPacket中的flags来判断。
AV_PKT_FLAG values定义如下:
#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
/**
* Flag is used to discard packets which are required to maintain valid
* decoder state but are not required for output and should be dropped
* after decoding.
**/
#define AV_PKT_FLAG_DISCARD 0x0004
其中AV_PKT_FLAG_KEY用来表示是否为关键帧。
非关键帧跳过,从关键帧开始解析