For compatibility issues we must try to get channels using the
codec->channels field if it's 0 we try using the function
av_get_channel_layout_cb_channels().
AVCodecContext *ctx = stream->codec;
info->bitrate = ctx->bit_rate;
- info->channels = av_get_channel_layout_nb_channels(ctx->channel_layout);
+ info->channels = ctx->channels;
+
+ if (!info->channels)
+ info->channels = av_get_channel_layout_nb_channels(ctx->channel_layout);
+
info->sampling_rate = ctx->sample_rate;
info->length = _get_stream_duration(fmt_ctx);