[Libav-user] Not able to resample with libavfilter

Paul B Mahol onemda at gmail.com
Mon Jun 19 23:41:20 EEST 2017

On 6/19/17, amey jain <amey.jain7 at gmail.com> wrote:
> Hi,
> I want resampled output of 5512 Hz, mono channel, in float. I am using
> aformat filter with these parameters and buffersrc sink. All things
> are working fine except for the output frames collected from sink.
> When I get sample_rate using frame->sample_rate, I get 48000 as
> output. Also the value to nb_samples remains same. Can someone guide
> me out here. Below is code I am using.
> //buffer src aformat initialized
> resample = avfilter_get_by_name("aformat");
> resample_ctx = avfilter_graph_alloc_filter(filter_graph, resample,
> "aformat");
> av_get_channel_layout_string(ch_layout, sizeof(ch_layout),
> av_opt_set(resample_ctx, "channel_layout", ch_layout,
> av_opt_set(resample_ctx,
> "sample_fmt",av_get_sample_fmt_name(AV_SAMPLE_FMT_FLT),
> av_opt_set_q(resample_ctx, "time_base", (AVRational){ 1, 5512
> av_opt_set_int(resample_ctx, "sample_rate", 5512, AV_OPT_SEARCH_CHILDREN);
> avfilter_init_str(resample_ctx, NULL);
> //buffer sink abuffersink initialized and all three linked together

Mandatory code is missing. We can not guess it, please provide it or
ask for help
somewhere else.

More information about the Libav-user mailing list