[FFmpeg-devel] [PATCH] examples/filtering_audio: get rid of AVABufferSinkParams

Pavel Koshevoy pkoshevoy at gmail.com
Wed Apr 17 16:03:37 CEST 2013


On 4/17/13 3:17 AM, Nicolas George wrote:
> L'octidi 28 germinal, an CCXXI, pkoshevoy at gmail.com a écrit :
>> From: Pavel Koshevoy <pkoshevoy at gmail.com>
>>
>> AVABufferSinkParams are ignored by avfilter_graph_create_filter,
>> therefore the example is misleading.  Use av_opt_set_int_list to
>> configure abuffersink directly.
> Thanks for the patch. Comments follow below.
>
>> Also, make the example a bit more interesting.
> I believe the two changes belong in different patches.
>
>> Signed-off-by: Pavel Koshevoy <pkoshevoy at gmail.com>
>> ---
>>   doc/examples/filtering_audio.c |   45 +++++++++++++++++++++++++++++++++-------
>>   1 file changed, 37 insertions(+), 8 deletions(-)
>>
>> diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c
>> index 67588aa..c891dfe 100644
>> --- a/doc/examples/filtering_audio.c
>> +++ b/doc/examples/filtering_audio.c
>> @@ -36,9 +36,19 @@
>>   #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 -";
>> +/*
>> + * Example of pitch-shifting effect:
>> + *
>> + * 1. use atempo filter at 48KHz and increase playback tempo
>> + * by a factor of 2 thus reducing number of samples per second in half.
>> + *
>> + * 2. use ffplay to ingest raw audio at 24KHz thus increasing playback
>> + * duration by a factor of 2 and resulting in playback at a lower pitch.
>> +*/
>> +const char *filter_descr = "aresample=48000, atempo=2.0";
>> +const char *player       = "ffplay -f s16le -ar 24000 -ac 2 -";
> I believe this kind of mismatch is most likely to confuse users, and
> therefore should be avoided in an example.

OK, but another example should be considered that doesn't just use 
aresample (it's redundant).  I'll still take a look at valgrind memory 
errors which Michael noticed that may be atempo related.


<snip>

>> +    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;
>> +    }
>> +
> IMHO, since the lists are available as local arrays, av_opt_set_bin and
> sizeof are more elegant. Possibly, an example should show both
> possibilities.

I am not well versed with options API to make such refinements.

Thank you,
     Pavel




More information about the ffmpeg-devel mailing list