diff mbox series

[FFmpeg-devel,7/7] ffmpeg: make the ac option set the demuxer's ch_layout AVOption

Message ID 20220320201523.51516-1-jamrial@gmail.com
State New
Headers show
Series None | expand

Commit Message

James Almer March 20, 2022, 8:15 p.m. UTC
channels is deprecated on all supported raw demuxers.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/ffmpeg_opt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andreas Rheinhardt March 21, 2022, 9:12 p.m. UTC | #1
James Almer:
> channels is deprecated on all supported raw demuxers.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  fftools/ffmpeg_opt.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 720a3cc46a..213a34eadc 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -1122,7 +1122,9 @@ static int open_input_file(OptionsContext *o, const char *filename)
>          if (file_iformat && (priv_class = file_iformat->priv_class) &&
>              av_opt_find(&priv_class, "channels", 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] = "";
> +            av_strlcatf(buf, sizeof(buf), "%dC", o->audio_channels[o->nb_audio_channels - 1].u.i);

snprintf; it also avoids the initialization.

> +            av_dict_set(&o->g->format_opts, "ch_layout", buf, 0);
>          }
>      }
>      if (o->nb_audio_ch_layouts) {
James Almer March 21, 2022, 9:27 p.m. UTC | #2
On 3/21/2022 6:12 PM, Andreas Rheinhardt wrote:
> James Almer:
>> channels is deprecated on all supported raw demuxers.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   fftools/ffmpeg_opt.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
>> index 720a3cc46a..213a34eadc 100644
>> --- a/fftools/ffmpeg_opt.c
>> +++ b/fftools/ffmpeg_opt.c
>> @@ -1122,7 +1122,9 @@ static int open_input_file(OptionsContext *o, const char *filename)
>>           if (file_iformat && (priv_class = file_iformat->priv_class) &&
>>               av_opt_find(&priv_class, "channels", 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] = "";
>> +            av_strlcatf(buf, sizeof(buf), "%dC", o->audio_channels[o->nb_audio_channels - 1].u.i);
> 
> snprintf; it also avoids the initialization.

Changed locally.

> 
>> +            av_dict_set(&o->g->format_opts, "ch_layout", buf, 0);
>>           }
>>       }
>>       if (o->nb_audio_ch_layouts) {
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 720a3cc46a..213a34eadc 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1122,7 +1122,9 @@  static int open_input_file(OptionsContext *o, const char *filename)
         if (file_iformat && (priv_class = file_iformat->priv_class) &&
             av_opt_find(&priv_class, "channels", 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] = "";
+            av_strlcatf(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) {