gpt4 book ai didi

c++ - ffmpeg - avcodec_receive_frame 返回-11,为什么以及如何解决它?

转载 作者:行者123 更新时间:2023-12-04 23:10:03 36 4
gpt4 key购买 nike

我正在学习在我的引擎中使用 ffmpeg,
我想解码视频流的第一帧并将其输出到图像文件。
我试过了,就是不知道为什么它返回-11。
我的代码:(最后 5 行代码中的错误,第 70-74 行)
Link to my code

最佳答案

这是您的代码(第 70 - 74 行):

res = avcodec_receive_frame(pCodecContext, pFrame);
if (res != 0)
{
return EXIT_FAILURE;
}
让我们看看,文档对相关功能( avcodec_receive_frame )有什么看法:

Returns

0: success, a frame was returned
AVERROR(EAGAIN): output is not available in this state - user must try to send new input
AVERROR(EOF): the decoder has been fully flushed, and there will be no more output frames
AVERROR(EINVAL): codec not opened, or it is an encoder >
other negative values: legitimate decoding errors


您可以执行以下操作:
switch (res) {
default: puts("unknown result"); break;
case 0: puts("success"); break;
case AVERROR(EAGAIN): puts("output is not available"); break;
//... you get the idea
}

关于c++ - ffmpeg - avcodec_receive_frame 返回-11,为什么以及如何解决它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71620158/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com