当使用avfilter_graph_parse_ptr接口,传入filters的参数为fps=fps=15;scale=w=960:h=540
ffmpeg就会输出错误:Invalid filterchain containing an unlabelled output pad: "fps=fps=15;scale=w=960:h=540"
说明多filter不能成功连接。
需要对各个filter的输入和输出指定.
因为默认buffersrc为in, buffersink为out
将传入参数修正为:[in]fps=fps=15[framerate];[framerate]scale=w=960:h=540[out]
就能达到将帧率调整为15,分辨率调整为960x540
关联相关代码,如下:
AVFilterInOut *outputs = avfilter_inout_alloc();
outputs->name = av_strdup("in");
outputs->filter_ctx = buffersrc_ctx;
outputs->pad_idx = 0;
outputs->next = NULL;
AVFilterInOut *inputs = avfilter_inout_alloc();
inputs->name = av_strdup("out");
inputs->filter_ctx = buffersink_ctx;
inputs->pad_idx = 0;
inputs->next = NULL;
char filter_spec[128] = { 0 };
snprintf(filter_spec, sizeof(filter_spec), "[in]%s[framerate];[framerate]%s[out]", "fps=fps=15", "scale=w=960:h=540");
avfilter_graph_parse_ptr(filter_graph, filter_spec,
&inputs, &outputs, NULL);
avfilter_graph_config(filter_graph, NULL);