[Libav-user] decoding audio with libav

luigi luigi.giancristofaro at tim.it
Thu Apr 27 04:32:00 EEST 2017


Hello,

I'm trying to decode effectively audio in an .avi video file with

decode_audio4, etc.

I succeed as long as the decoded frames are stereo, but when I bump into 
avi files which have 5.1 channels I get weird audio reproduction.

I have so far tried to resample (swr_convert) the decoded frames, but 
with no success.

     av_opt_set_int(swr_ctx, "in_channel_layout", src_ch_layout, 0);
     av_opt_set_int(swr_ctx, "in_sample_rate",       src_rate, 0);
     av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", src_sample_fmt, 0);
     av_opt_set_int(swr_ctx, "in_channel_count", dec_fr->channels, 0);

     av_opt_set_int(swr_ctx, "out_channel_layout", dst_ch_layout, 0);
     av_opt_set_int(swr_ctx, "out_sample_rate",       dst_rate, 0);
     av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", dst_sample_fmt, 0);
     av_opt_set_int(swr_ctx, "out_channel_count", 2, 0);

Here, I would like to ask a few questions:

1) is the "in_channel_layout" the layout of the decoded frame before it 
is resampled?

2) what is it that swr_convert really does?

Thanks for any help to clarify my ideas

Luigi



More information about the Libav-user mailing list