马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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);
复制代码 |