[FFmpeg-user] libavfilter : using amix

Nicolas George george at nsup.org
Sun Apr 20 20:22:06 CEST 2014

Le decadi 30 germinal, an CCXXII, Mr Artichaut a écrit :
> Here is all I have :
> https://gist.github.com/MrArtichaut/7e9c8c3cffec36030137

Ok, so your buffer overflow problem is gone, but the garbled music is still
there. Got it.

Your encoder works unconditionally with AV_SAMPLE_FMT_S16, 2 channels and
the same sample rate as the first input file. That is not correct.

For each parameter (sample format, channel count and layout, sample rate)
you must either configure the output encoder to use the same value as the
output of libavfilter or force libavfilter to convert to the format you want
to use.

The latter can be done by using av_opt_set* on abuffersink_ctx after initing

Note that most encoders will only support one or a few formats. For a lot of
encoders, there is a limit on the supported channel layouts, and some
annoying encoders have limits on the sample rate.

Your problem comes from the sample format, I told you amix works with float
while you configure your encoder for 16-bits ints.

I get correct results by adding:

av_opt_set_int_list(abuffersink_ctx, "sample_fmts",
    ((int[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }),


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20140420/7058947c/attachment.asc>

More information about the ffmpeg-user mailing list