[FFmpeg-cvslog] doc/examples/decode_filter_audio: switch to new buffersink options

Anton Khirnov git at videolan.org
Mon Sep 30 10:15:58 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Sep 25 17:59:03 2024 +0200| [0dbd59242a1c29c72fd9ac2a2bf3048c41d1843e] | committer: Anton Khirnov

doc/examples/decode_filter_audio: switch to new buffersink options

Use a mix of av_opt_set() and av_opt_set_array() to demonstrate
different ways the options can be set.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0dbd59242a1c29c72fd9ac2a2bf3048c41d1843e
---

 doc/examples/decode_filter_audio.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/doc/examples/decode_filter_audio.c b/doc/examples/decode_filter_audio.c
index 6d148f7ab4..03e13ef66f 100644
--- a/doc/examples/decode_filter_audio.c
+++ b/doc/examples/decode_filter_audio.c
@@ -96,8 +96,7 @@ static int init_filters(const char *filters_descr)
     const AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
     AVFilterInOut *outputs = avfilter_inout_alloc();
     AVFilterInOut *inputs  = avfilter_inout_alloc();
-    static const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
-    static const int out_sample_rates[] = { 8000, -1 };
+    static const int out_sample_rate = 8000;
     const AVFilterLink *outlink;
     AVRational time_base = fmt_ctx->streams[audio_stream_index]->time_base;
 
@@ -130,22 +129,22 @@ static int init_filters(const char *filters_descr)
         goto end;
     }
 
-    ret = av_opt_set_int_list(buffersink_ctx, "sample_fmts", out_sample_fmts, -1,
-                              AV_OPT_SEARCH_CHILDREN);
+    ret = av_opt_set(buffersink_ctx, "sample_formats", "s16",
+                     AV_OPT_SEARCH_CHILDREN);
     if (ret < 0) {
         av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n");
         goto end;
     }
 
-    ret = av_opt_set(buffersink_ctx, "ch_layouts", "mono",
-                              AV_OPT_SEARCH_CHILDREN);
+    ret = av_opt_set(buffersink_ctx, "channel_layouts", "mono",
+                     AV_OPT_SEARCH_CHILDREN);
     if (ret < 0) {
         av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
         goto end;
     }
 
-    ret = av_opt_set_int_list(buffersink_ctx, "sample_rates", out_sample_rates, -1,
-                              AV_OPT_SEARCH_CHILDREN);
+    ret = av_opt_set_array(buffersink_ctx, "samplerates", AV_OPT_SEARCH_CHILDREN,
+                           0, 1, AV_OPT_TYPE_INT, &out_sample_rate);
     if (ret < 0) {
         av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
         goto end;



More information about the ffmpeg-cvslog mailing list