keyframe is not a keyframe? AV_PKT_FLAG_KEY does not decode to AV_PICTURE_TYPE_I

谁都会走 提交于 2019-12-04 14:14:23

问题


After decoding a packet containing AV_PKT_FLAG_KEY in the flags, I was expecting to get I-frames, but instead I got P-frames:

After a call to:

avcodec_decode_video2(codecCtx, frame, &frameFinished, &packet); // mpeg2 video

I print out the following as a sanity check:

    printf("packet flags: %d picture type: %c\n", packet.flags,
            av_get_picture_type_char(frame->pict_type));

Returns the output:

    packet flags: 1 picture type: P

When I was expecting:

    packet flags: 1 picture type: I  

Where '1' == AV_PKT_FLAG_KEY. and 'I' refers to AV_PICTURE_TYPE_I,

Is this behavior correct? (I'm decoding MPEG2 video).


回答1:


I got a response from the ffmpeg bugtracker:

https://ffmpeg.org/trac/ffmpeg/ticket/2074

I suspect your are missing the codec delay. The video frame you get out usually isn't based on the packet you just sent in at all. This is especially true with multithreaded decoding, but even without it's not generally possible due to how B-frames work.

And, indeed I print out the ->pict_type "picture type" 3 frames later, there is an I-frame that pops up a few frames later with a "delay" of sorts exactly a 3 frames later. In my case, I have a quad-core computer, so perhaps there's a thread being allocated for each core on my computer to do the encoding.



来源:https://stackoverflow.com/questions/14044335/keyframe-is-not-a-keyframe-av-pkt-flag-key-does-not-decode-to-av-picture-type-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!