[FFmpeg-devel] [PATCH 6/6] ffmpeg_filter: use an unknown channel layout if necessary.

Nicolas George nicolas.george at normalesup.org
Wed Nov 28 16:14:21 CET 2012

For libavfilter, the channel layout is mandatory.

Could be considered to fix trac ticket #1763;
works with the sample from #1957.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
 ffmpeg_filter.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Note: I think we should also get rid of guess_input_channel_layout() in
ffmpeg, except possibly for the very obvious cases: there is really nothing
that tells us that a 4-channels file with no layout declaration is more
likely to be 4.0 than quad.

diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c
index 5e37128..e174ec5 100644
--- a/ffmpeg_filter.c
+++ b/ffmpeg_filter.c
@@ -626,13 +626,16 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
     int pad_idx = in->pad_idx;
     char args[255], name[255];
     int ret;
+    uint64_t layout = ist->st->codec->channel_layout;
+    if (!layout)
+        layout = av_channel_layout_make_unknown(ist->st->codec->channels);
     snprintf(args, sizeof(args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s"
              1, ist->st->codec->sample_rate,
-             ist->st->codec->channel_layout);
+             layout);
     snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
              ist->file_index, ist->st->index);

More information about the ffmpeg-devel mailing list