From e78173557da898f18a78241cc3525b76694164b5 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sun, 20 Mar 2022 17:14:13 -0300 Subject: [PATCH] ffmpeg: make the ac option set the demuxer's ch_layout AVOption channels is deprecated on all supported raw demuxers. Signed-off-by: James Almer --- fftools/ffmpeg_opt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 28f5a027d5..5598f0e53d 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1116,13 +1116,12 @@ static int open_input_file(OptionsContext *o, const char *filename) } if (o->nb_audio_channels) { const AVClass *priv_class; - /* because we set audio_channels based on both the "ac" and - * "channel_layout" options, we need to check that the specified - * demuxer actually has the "channels" option before setting it */ if (file_iformat && (priv_class = file_iformat->priv_class) && - av_opt_find(&priv_class, "channels", NULL, 0, + av_opt_find(&priv_class, "ch_layout", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { - av_dict_set_int(&o->g->format_opts, "channels", o->audio_channels[o->nb_audio_channels - 1].u.i, 0); + char buf[32]; + snprintf(buf, sizeof(buf), "%dC", o->audio_channels[o->nb_audio_channels - 1].u.i); + av_dict_set(&o->g->format_opts, "ch_layout", buf, 0); } } if (o->nb_audio_ch_layouts) {