diff options
author | Pavel Koshevoy <pkoshevoy@gmail.com> | 2013-04-17 10:46:49 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-17 13:11:57 +0400 |
commit | e5644313c581a4e936d600a0f18b55988f6c9a57 (patch) | |
tree | 19474e59ee7ab75d3004dd1d14539b9bfb0f539a /doc | |
parent | f2619cbd61482dc09b75a4e0d01f8957a9460654 (diff) |
examples/filtering_audio: get rid of AVABufferSinkParams
AVABufferSinkParams are ignored by avfilter_graph_create_filter,
therefore the example is misleading. Use av_opt_set_int_list to
configure abuffersink directly.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/filtering_audio.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c index d629d79e75..f674052e33 100644 --- a/doc/examples/filtering_audio.c +++ b/doc/examples/filtering_audio.c @@ -36,6 +36,7 @@ #include <libavfilter/avcodec.h> #include <libavfilter/buffersink.h> #include <libavfilter/buffersrc.h> +#include <libavutil/opt.h> const char *filter_descr = "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono"; const char *player = "ffplay -f s16le -ar 8000 -ac 1 -"; @@ -89,8 +90,9 @@ static int init_filters(const char *filters_descr) AVFilter *abuffersink = avfilter_get_by_name("abuffersink"); AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); - const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; - AVABufferSinkParams *abuffersink_params; + const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; + const int64_t out_channel_layouts[] = { AV_CH_LAYOUT_MONO, -1 }; + const int out_sample_rates[] = { 8000, -1 }; const AVFilterLink *outlink; AVRational time_base = fmt_ctx->streams[audio_stream_index]->time_base; @@ -111,16 +113,34 @@ static int init_filters(const char *filters_descr) } /* buffer audio sink: to terminate the filter chain. */ - abuffersink_params = av_abuffersink_params_alloc(); - abuffersink_params->sample_fmts = sample_fmts; ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out", - NULL, abuffersink_params, filter_graph); - av_free(abuffersink_params); + NULL, NULL, filter_graph); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n"); return ret; } + ret = av_opt_set_int_list(buffersink_ctx, "sample_fmts", out_sample_fmts, -1, + AV_OPT_SEARCH_CHILDREN); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n"); + return ret; + } + + ret = av_opt_set_int_list(buffersink_ctx, "channel_layouts", out_channel_layouts, -1, + AV_OPT_SEARCH_CHILDREN); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n"); + return ret; + } + + ret = av_opt_set_int_list(buffersink_ctx, "sample_rates", out_sample_rates, -1, + AV_OPT_SEARCH_CHILDREN); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n"); + return ret; + } + /* Endpoints for the filter graph. */ outputs->name = av_strdup("in"); outputs->filter_ctx = buffersrc_ctx; |