Quoting Marton Balint (2024-05-18 18:11:12) > diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c > index cba63dab5f..6e23079ceb 100644 > --- a/fftools/ffmpeg_demux.c > +++ b/fftools/ffmpeg_demux.c > @@ -1524,6 +1524,33 @@ static Demuxer *demux_alloc(void) > return d; > } > > +static int set_input_ch_layout_opts(const OptionsContext *o) > +{ > + /* "ch_layout" is only a valid format option for some formats, but we set > + * it anyway, because it is also a codec option and we don't report > + * unconsumed format options if they are codec options as well. */ > + for (int i = 0; i < o->audio_channels.nb_opt; i++) { > + char val[32]; > + char *spec = o->audio_channels.opt[i].specifier; > + char *key = av_asprintf("ch_layout%s%s", spec[0] ? ":" : "", spec); > + if (!key) > + return AVERROR(ENOMEM); > + snprintf(val, sizeof(val), "%dC", o->audio_channels.opt[i].u.i); > + av_dict_set(&o->g->format_opts, key, val, 0); > + av_dict_set(&o->g->codec_opts, key, val, AV_DICT_DONT_STRDUP_KEY);
I don't like modifying OptionsContext in its consumers (it's const for a reason), and it's probably not even necessary - if the semantics of the option is "override demuxer-reported channel layout", then you can just override the demuxer-reported channel layout (similarly to how guess_input_channel_layout() does it) and it will be communicated to the decoder automagically. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".