FFMPEG amix filter volume issue with inputs of different duration

Solution 1:

amix scales each input's volume by 1/n where n = no. of active inputs. This is evaluated for each audio frame. So when an input drops out, the volume of the remaining inputs is scaled by a smaller amount, hence their volumes increase.

Changing the dropout_transition for all earlier inputs, as suggested in other answers, is one approach, but I think it will result in coarse volume modulations. Better method is to normalize the audio after the amix.

At present, you have two options, the loudnorm or the dynaudnorm filter. The latter is much faster

Syntax is to add it after the amix, so

[aud11][aud12]amix=inputs=13:duration=first:dropout_transition=0,dynaudnorm"

Read the documentation, if you wish to tweak parameters for maximum volume or RMS mode normalization..etc

Solution 2:

The latest version of FFMPEG includes the normalize parameter for the amix filter, which you can use to turn off the constantly changing normalization. Here's the documentation for it.

Your amix filter string can be changed to:

[aud12]amix=inputs=13:normalize=0