[Libav-user] resampling audio and then encoding

JULIAN GARDNER joolzg at btinternet.com
Thu Apr 28 16:09:21 CEST 2016


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
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?
joolz


    On Thursday, 28 April 2016, 15:11, Andrey Utkin <andrey_utkin at fastmail.com> wrote:
 
 

 On Thu, Apr 28, 2016 at 01:00:37PM +0000, JULIAN GARDNER wrote:
> So my question is do I have to split the input to be the correct size or am i missing something in the audio encoding setup to allow it to do the buffering correctly?

Apparently yes.
I believe libavfilter API can do both parts (resampling and splitting)
for you, filtering is easier to setup than handling of every aspect of
conversion manually.


 
   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160428/2c739677/attachment.html>


More information about the Libav-user mailing list