关键帧不是关键帧? AV_PKT_FLAG_KEY不解码为AV_PICTURE_TYPE_I [英] keyframe is not a keyframe? AV_PKT_FLAG_KEY does not decode to AV_PICTURE_TYPE_I

查看:2890
本文介绍了关键帧不是关键帧? AV_PKT_FLAG_KEY不解码为AV_PICTURE_TYPE_I的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在标志中解码包含AV_PKT_FLAG_KEY的数据包之后,
我期望得到I帧,而是获得了P帧:

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:

之后调用:

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));

返回输出:

    packet flags: 1 picture type: P

当我期待: / p>

When I was expecting:

    packet flags: 1 picture type: I  

其中'1'== AV_PKT_FLAG_KEY。而我是指AV_PICTURE_TYPE_I,

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

这个行为是否正确? (我正在解码MPEG2视频)。

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

推荐答案

我收到了ffmpeg bugtracker的回复:

I got a response from the ffmpeg bugtracker:

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


我怀疑你错过了编解码器延迟。
你通常看到的视频帧不是基于你刚刚发送的数据包。这对于多线程解码尤其如此,但是即使没有一般可能的原因在于B帧的工作原理。

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.

而且,确实我打印出 - > pict_type图片类型3帧后,有一个I帧可以弹出几帧,稍后会出现3帧后的延迟。在我的情况下,我有一台四核电脑,所以也许有一个线程被分配给我的电脑上的每个核心进行编码。

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.

这篇关于关键帧不是关键帧? AV_PKT_FLAG_KEY不解码为AV_PICTURE_TYPE_I的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆