Set amix Filter Dropout Transition Time in FFmpeg
When mixing multiple audio streams using FFmpeg’s amix
filter, the volume of the remaining streams automatically renormalizes
(increases) when one stream ends. To prevent a sudden, jarring jump in
volume, you can configure the dropout_transition parameter
to smoothly fade the volume adjustment over a specified number of
seconds. This guide shows you how to use this parameter with clear
syntax and practical command examples.
The
dropout_transition Parameter
The dropout_transition option defines the transition
time (in seconds) for volume renormalization when an input stream
ends.
- Default Value: 2 seconds.
- Value of 0: Instantly adjusts the volume (can cause sudden volume spikes).
- Higher Values: Creates a longer, smoother fade to the new volume level.
Command Syntax
To set the dropout transition time, append the
dropout_transition option to your amix filter
chain in the -filter_complex or -af flag:
amix=inputs=X:dropout_transition=Yinputs=X: The number of input audio streams.dropout_transition=Y: The duration in seconds for the volume transition.
Practical Example
In the following example, we mix two audio files
(music.mp3 and voiceover.mp3) and set the
dropout transition time to 5 seconds. This means when
the voiceover track ends, the music track’s volume will gradually
increase to its solo level over a 5-second window.
ffmpeg -i music.mp3 -i voiceover.mp3 -filter_complex "amix=inputs=2:dropout_transition=5" output.mp3If you want to disable the transition entirely and have the volume
adjust immediately, set the value to 0:
ffmpeg -i music.mp3 -i voiceover.mp3 -filter_complex "amix=inputs=2:dropout_transition=0" output.mp3