[Libav-user] resampling audio and then encoding

Andrey Utkin andrey_utkin at fastmail.com
Thu Apr 28 19:44:44 CEST 2016


On Thu, Apr 28, 2016 at 02:09:21PM +0000, JULIAN GARDNER wrote:
> Ok added the code from filtering_audio.c to create a filterchain, changed my code to take the decoded frames and push into the filter.
> filt_frame is returned and this is pushed into the avcodec_encode_audio2 and guess what error i get
> 
> [mp2 @ xxxxxxxxxxx] nb_samples (1024) != frame_size (1152) (avencode_encoder_audio2)
> So question one, How do i fix this

Append this filter to your filtering string, with proper parameter.
http://ffmpeg.org/ffmpeg-filters.html#asetnsamples

> Question Two
> In this example code a filter string is passed "aresample=32000,aformat=sample_fmts=s16,channel_layout=stereo", to init_filter and parsed by a call to avfilter_graph_parse_ptr 
> 
> but also in the code these values are set 
> 
> static const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1);static const int64_t out_channel_layouts[] = { AV_CH_LAYOUT_STEREO, -1 };static const int out_sample_rates[] = { 32000, -1 };etc
> Is this duplication needed?

Cannot help on this.


More information about the Libav-user mailing list