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.

To set a 5-second overlap, use the d parameter:

ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex "acrossfade=d=5" output.mp3

Configuring 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.

Available Curve Types

FFmpeg supports several curve shapes, including:

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