当我尝试解码数据包(使用此函数 avcodec_decode_video2)时,有时会损坏(灰色)帧。由于丢失帧而获得此错误。ffmpeg 将以下错误写入日志:
[hevc @ 000000000379b680] 找不到具有 POC 43 的参考 [hevc @ 000000000379b1c0] 序列中的重复 POC:17. [hevc @ 000000000379b1c0] 解析 NAL 单元时出错#0
我想通过使用以下标志严格调整解码器的上下文来解决这个问题:AV_EF_EXPLODE 和 AV_EF_AGGRESSIVE。不幸的是它没有帮助,错误继续出现在日志中,但 avcodec_decode_video2 泄露了损坏的帧。
AVCodecContext* context = avcodec_alloc_context3(codecId);
avctx->flags2 |= AV_CODEC_FLAG2_FAST;
// Known encoder's bugs handling.
avctx->workaround_bugs = AV_EF_EXPLODE | AV_EF_AGGRESSIVE;
avctx->err_recognition = 0;
avctx->error_concealment = 0;
// Threads.
avctx->thread_count = 4;
avctx->thread_type = FF_THREAD_FRAME;
.....
avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt);
....
Run Code Online (Sandbox Code Playgroud)
我需要做什么来确保损坏的帧不会重复?也许我需要稍微不同地配置上下文?
PS你可以在附件中看到ffmpeg版本