ffmpeg添加sps,pps

[复制链接]
发表于 2025-11-22 15:30:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
1、ffmpeg自动添加, 在avcodec_open2之前添加一行代码就行了:
  1. codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
复制代码
2、手动添加, 在avcodec_open2之前添加如下代码, 0x00000001大概0x000001是起始码,0x67是sps的开头,0x68是pps的开头。
  1. unsigned char sps_pps[23] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x0a, 0xf8, 0x0f, 0x00, 0x44, 0xbe, 0x8, 
  2.                               0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x38, 0x80 };
  3. codec_ctx->extradata_size = 23;
  4. codec_ctx->extradata = (uint8_t*)av_malloc(23 + AV_INPUT_BUFFER_PADDING_SIZE);
  5. if (codec_ctx->extradata == NULL) {
  6.     printf("could not av_malloc the video params extradata!\n");
  7.     return -1;
  8. }
  9. memcpy(codec_ctx->extradata, sps_pps, 23);
复制代码
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表