First of all, this is a question asked more out of curiosity than desperate need of fixing. I seem to have "fixed" it by upgrading from FFmpeg 3.4.6 to FFmpeg 4.3.1. Or so I think, at least the result is much better.
I'm trying to mix 2 audio files (of the same length, so no scale variation here) using FFmpeg amix filter:
- A music which starts pretty loud in the beginning and then is almost quiet until the end,
- An audio that starts with silence (basically as long as the music is loud), then continues with a person speaking at an "average" volume
Now, I learnt that the filter will divide each input volume by 1/nb_active_inputs (by 2 in my case then), so I added a volume filter on the output to multiply its volume by 2. My command basically looks like this:
ffmpeg -i music.mp3 -i voice.mp3 -filter_complex amix=inputs=2:duration=first[mix];[mix]volume=2[out] -map [out] output.mp3
After that complex filter, my final output is completely distorted. The voice sounds overall very loud and saturated.
I'm not an expert with audio nor with FFmpeg so I assume I'm missing something. I'm trying to understand what is going on and why I am having this result since I use the same inputs, filters and filter options in both cases. Only the FFmpeg version differs.
I've tried to read the code of af_amix.c for both versions but can't seem to find any explanation for that difference. I've seen that the 4.3.1 has a weights option for inputs but from what I understood, they default to 1.0 if not specified. Any clue would be much appreciated.