If two filters have incompatible sample formats, attempt inserting a
scaler (resample filter).
---
libavfilter/avfiltergraph.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 6f219a6..ff33960 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -128,15 +128,21 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
if(link && link->in_formats != link->out_formats) {
if(!avfilter_merge_formats(link->in_formats,
link->out_formats)) {
+ enum AVMediaType type = link->type;
AVFilterContext *scale;
char scale_args[256];
/* couldn't merge format lists. auto-insert scale filter */
snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d",
scaler_count++);
- scale =
- avfilter_open(avfilter_get_by_name("scale"),inst_name);
-
- snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts);
+ scale = type == AVMEDIA_TYPE_VIDEO ?
+ avfilter_open(avfilter_get_by_name("scale"),inst_name) :
+ type == AVMEDIA_TYPE_AUDIO ?
+ avfilter_open(avfilter_get_by_name("resample"),inst_name) : NULL;
+
+ if (type == AVMEDIA_TYPE_VIDEO)
+ snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts);
+ if (type == AVMEDIA_TYPE_AUDIO)
+ snprintf(scale_args, sizeof(scale_args), "%d:-1", link->out_formats->formats[0]);
if(!scale || scale->filter->init(scale, scale_args, NULL) ||
avfilter_insert_filter(link, scale, 0, 0)) {
avfilter_destroy(scale);
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc