FFmpeg extradata问题描述

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FFmpeg extradata问题描述相关的知识,希望对你有一定的参考价值。

场景描述

            手动添加SPS/PPS信息到AVFormatContext

unsigned char sps_pps[] = { 0x00 ,0x00 ,0x01,0x67,0x42,0x00 ,0x2a ,0x96 ,0x35 ,0x40 ,0xf0 ,0x04 ,0x4f ,0xcb ,0x37 ,0x01 ,0x01 ,0x01 ,0x40 ,0x00 ,0x01 ,0xc2 ,0x00 ,0x00 ,0x57 ,0xe4 ,0x01 ,0x00 ,0x00 ,0x00 ,0x01 ,0x68 ,0xce ,0x3c ,0x80, 0x00};
pFormatContext->streams[0]->codecpar->extradata_size = sizeof(sps_pps);
pFormatContext->streams[0]->codecpar->extradata = (uint8_t*)av_mallocz(pFormatContext->streams[0]->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
memcpy(pFormatContext->streams[0]->codecpar->extradata, sps_pps, sizeof(sps_pps));


通过avcodec_parameters_to_context将信息从pFormatContext->streams[0]->codecpar拷贝到m_pAVCodecContext

av_read_frame(pVideo->m_pAVFormatContext)分帧

avcodec_send_packet(m_pAVCodecContext)解码


出错异常如下

I:2018-01-06 14:26:03 ms:366:deprecated pixel format used, make sure you did set range correctly
I:2018-01-06 14:26:03 ms:387:unknown SEI type 229
I:2018-01-06 14:26:03 ms:387:unknown SEI type 128
I:2018-01-06 14:26:03 ms:390:nal_unit_type: 7, nal_ref_idc: 3
I:2018-01-06 14:26:03 ms:391:nal_unit_type: 8, nal_ref_idc: 3
I:2018-01-06 14:26:03 ms:392:nal_unit_type: 6, nal_ref_idc: 0
I:2018-01-06 14:26:03 ms:393:nal_unit_type: 5, nal_ref_idc: 3
I:2018-01-06 14:26:03 ms:393:unknown SEI type 229
I:2018-01-06 14:26:03 ms:393:Reinit context to 1920x1088, pix_fmt: yuvj420p

以上是关于FFmpeg extradata问题描述的主要内容,如果未能解决你的问题,请参考以下文章

ffmpeg 添加 sps pps

FFmpeg解封装h264 ---- 提取SPS PPS

extraData 钩子不适用于 2 个 flatLists 之一

Web3.py错误 - The field extraData is 97 bytes, but should be 32

Python json.loads 显示 ValueError: Extra data

Python/FFMPEG 命令行问题