Commit 02430408 authored by Thomas Guillem's avatar Thomas Guillem
Browse files

avcodec/encoder: fix fallback to stereo

Happens if the codec doesn't support more than 2 channels (like mp3lame).
Also ask for a channel conversion instead of dropping channels.
parent 50c43317
......@@ -667,9 +667,6 @@ int OpenEncoder( vlc_object_t *p_this )
}
else if( p_enc->fmt_in.i_cat == AUDIO_ES )
{
/* work around bug in libmp3lame encoding */
if( i_codec_id == AV_CODEC_ID_MP3 && p_enc->fmt_out.audio.i_channels > 2 )
p_enc->fmt_out.audio.i_channels = 2;
p_context->codec_type = AVMEDIA_TYPE_AUDIO;
p_context->sample_fmt = p_codec->sample_fmts ?
p_codec->sample_fmts[0] :
......@@ -892,7 +889,14 @@ errmsg:
if( p_context->channels > 2 )
{
p_context->channels = 2;
p_enc->fmt_in.audio.i_channels = 2; // FIXME
p_context->channel_layout = channel_mask[p_context->channels][1];
/* Change fmt_in in order to ask for a channels conversion */
p_enc->fmt_in.audio.i_channels =
p_enc->fmt_out.audio.i_channels = 2;
p_enc->fmt_in.audio.i_physical_channels =
p_enc->fmt_out.audio.i_physical_channels = AOUT_CHANS_STEREO;
p_sys->i_channels_to_reorder = 0;
msg_Warn( p_enc, "stereo mode selected (codec limitation)" );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment