[Libav-user] Not able to resample with libavfilter

amey jain amey.jain7 at gmail.com
Mon Jun 19 23:28:14 EEST 2017


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), 0,AV_CH_LAYOUT_MONO);
av_opt_set(resample_ctx, "channel_layout", ch_layout, AV_OPT_SEARCH_CHILDREN);
av_opt_set(resample_ctx,
"sample_fmt",av_get_sample_fmt_name(AV_SAMPLE_FMT_FLT),
AV_OPT_SEARCH_CHILDREN);
av_opt_set_q(resample_ctx, "time_base", (AVRational){ 1, 5512
},AV_OPT_SEARCH_CHILDREN);
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

Regards


More information about the Libav-user mailing list