欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > ffmpeg添加sps,pps

ffmpeg添加sps,pps

2025/5/10 0:45:52 来源:https://blog.csdn.net/cai742925624/article/details/144617888  浏览:    关键词:ffmpeg添加sps,pps

1、ffmpeg自动添加, 在avcodec_open2之前添加一行代码就行了:

codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;

2、手动添加, 在avcodec_open2之前添加如下代码, 0x00000001或者0x000001是起始码,0x67是sps的开头,0x68是pps的开头。

unsigned char sps_pps[23] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x0a, 0xf8, 0x0f, 0x00, 0x44, 0xbe, 0x8, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x38, 0x80 };
codec_ctx->extradata_size = 23;
codec_ctx->extradata = (uint8_t*)av_malloc(23 + AV_INPUT_BUFFER_PADDING_SIZE);
if (codec_ctx->extradata == NULL) {printf("could not av_malloc the video params extradata!\n");return -1;
}
memcpy(codec_ctx->extradata, sps_pps, 23);

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词