ffmpeg中设置x264设置sps id,实现多个SPS/PPS

若有这种需求:期望在同一流中存在不同编码参数的h.264流。

应用场景: 视频截取,视频拼接等,可以不进行全部转码了。

 

核心参数:sps-id



经测试可以通过 x264-params或x264opts进行参数设置,不用修改ffmpeg源码了。
    av_dict_set(&video_encoder_options, "x264-params", "sps-id=6", 0);
    av_dict_set(&video_encoder_options, "x264opts", "sps-id=7", 0);



"x264-params"和x264_params因拼写问题设置不成功。。。
 
参数表中定义:
    { "x264-params",  "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
 结构体中定义:
ffmpeg中设置x264设置sps id,实现多个SPS/PPS_第1张图片
 

设置时:
ffmpeg中设置x264设置sps id,实现多个SPS/PPS_第2张图片
 

切记: 想要正常使用,需这样设置: av_dict_set(&video_encoder_options, " x264-params", "sps-id=6", 0);
不是下划线,是小横线啊。
 
经测试可以通过 x264-params或x264opts进行参数设置,不用修改ffmpeg源码了。
    av_dict_set(&video_encoder_options, "x264-params", "sps-id=6", 0);
    av_dict_set(&video_encoder_options, "x264opts", "sps-id=7", 0);
经测试,x264-params的优先级高一点。
 
 

你可能感兴趣的:(ffmpeg中设置x264设置sps id,实现多个SPS/PPS)