FFmpeg acrossfade: Set Duration and Curve Shape
This guide explains how to use the FFmpeg acrossfade
filter to transition between two audio streams. You will learn how to
configure the crossfade overlap duration and select different curve
shapes to control how the audio fades in and out.
The acrossfade filter mixes the end of the first audio
stream with the beginning of the second audio stream. To control this
transition, you use parameters for duration and curve shapes.
Setting the Overlap Duration
The duration of the crossfade determines how long the two audio
sources overlap. You can configure this using either the
duration (or d) parameter or the
nb_samples (or ns) parameter.
duration/d: Sets the duration of the overlap in seconds.nb_samples/ns: Sets the duration of the overlap in number of samples (the default is 44100).
To set a 5-second overlap, use the d parameter:
ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex "acrossfade=d=5" output.mp3Configuring the Curve Shapes
You can customize the fade-out shape of the first stream and the fade-in shape of the second stream. This controls the volume transition profile.
curve1/c1: Sets the curve for the fade-out (first stream).curve2/c2: Sets the curve for the fade-in (second stream).
Available Curve Types
FFmpeg supports several curve shapes, including:
tri: Triangular / linear (default)qsin: Quarter of sine wavehsin: Half of sine waveexp: Exponentiallog: Logarithmicsqu: Square root
Practical Example
To apply a 4-second crossfade where the first input fades out using a
logarithmic curve (log) and the second input fades in using
an exponential curve (exp), use the following command:
ffmpeg -i input1.wav -i input2.wav -filter_complex "acrossfade=d=4:c1=log:c2=exp" output.wav