FFMpeg : 调用了avfilter_graph_config 就不用调用avfilter_link() 了吗?

55 阅读1分钟

函数原型

/**
 * Check validity and configure all the links and formats in the graph.
 *
 * @param graphctx the filter graph
 * @param log_ctx context used for logging
 * @return >= 0 in case of success, a negative AVERROR code otherwise
 */
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);

调用了avfilter_graph_config函数后,不需要再显式调用avfilter_link函数来连接过滤器。avfilter_graph_config函数内部会自动处理过滤器之间的连接关系。

在调用avfilter_graph_parse_ptr函数时,已经将过滤器按照描述字符串连接起来了。然后,avfilter_graph_config函数会根据这些连接关系进行配置,包括设置输入和输出的参数,并初始化过滤器链。

因此,一般情况下,在调用avfilter_graph_parse_ptr后,接下来直接调用avfilter_graph_config即可完成过滤器链的连接和配置。

需要注意的是,avfilter_graph_config函数返回的错误码可以用于检查配置过程中是否出现了错误。如果返回值非零,意味着配置过程中发生了错误,您可以根据返回值进行错误处理和日志记录。