# HG changeset patch # User reimar # Date 1307835412 0 # Node ID c36fec5ba5b6985b642838ad2f9044ace6a21205 # Parent e4f533bf5a9aac53ba1744e4dd28ab9146de40cb Always choose AV_SAMPLE_FMT_S16 then the encoder supports it. diff -r e4f533bf5a9a -r c36fec5ba5b6 libmpcodecs/ae_lavc.c --- a/libmpcodecs/ae_lavc.c Sat Jun 11 16:40:10 2011 +0000 +++ b/libmpcodecs/ae_lavc.c Sat Jun 11 23:36:52 2011 +0000 @@ -187,7 +187,17 @@ lavc_actx->codec_type = AVMEDIA_TYPE_AUDIO; lavc_actx->codec_id = lavc_acodec->id; // put sample parameters - lavc_actx->sample_fmt = lavc_acodec->sample_fmts ? lavc_acodec->sample_fmts[0] : AV_SAMPLE_FMT_S16; + lavc_actx->sample_fmt = AV_SAMPLE_FMT_S16; + if (lavc_acodec->sample_fmts) { + const enum AVSampleFormat *fmts; + lavc_actx->sample_fmt = lavc_acodec->sample_fmts[0]; // fallback to first format + for (fmts = lavc_acodec->sample_fmts; *fmts != AV_SAMPLE_FMT_NONE; fmts++) { + if (*fmts == AV_SAMPLE_FMT_S16) { // preferred format found + lavc_actx->sample_fmt = *fmts; + break; + } + } + } if (lavc_actx->sample_fmt != AV_SAMPLE_FMT_S16) mp_msg(MSGT_MENCODER, MSGL_ERR, "Encoder requires input not properly supported." "Try using e.g. 'ac3_fixed' instead of 'ac3' as codec\n");