FFmpeg acrossfade: How to Crossfade Two Audio Files

This article provides a straightforward guide on how to use the FFmpeg acrossfade filter to seamlessly blend the end of one audio file into the beginning of another. You will learn the essential command syntax, key parameters such as transition duration and fade curves, and practical examples to help you achieve smooth audio transitions.

The Basic Command

To crossfade two audio files, you need to use FFmpeg’s -filter_complex option with the acrossfade filter. This filter takes two input audio streams, overlaps them by a specified duration, and applies a fade-out to the first file while applying a fade-in to the second.

Here is the standard command to crossfade two MP3 files with a 5-second overlap:

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

How It Works:


Key Parameters for acrossfade

You can customize the transition by adjusting the filter’s parameters:

Transition Curve Types

FFmpeg supports several curve shapes to control the volume transition speed. Common curves include: * tri (Double linear / triangular - default) * qsin (Quarter sine) * esin (Exponential sine) * log (Logarithmic) * exp (Exponential) * lin (Linear)


Advanced Example: Customizing Fade Curves

To create a more professional-sounding transition, you can specify custom fade curves. For example, using exponential curves (exp) often results in a smoother acoustic transition:

ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex "acrossfade=d=4:c1=exp:c2=exp" output.mp3

In this command: * The crossfade duration is set to 4 seconds (d=4). * Both the fade-out (c1=exp) and fade-in (c2=exp) use exponential curves to prevent sudden drops in volume during the mix.