How to Crossfade Audio in FFmpeg with acrossfade
This guide explains how to seamlessly blend two overlapping audio
tracks using the acrossfade filter in FFmpeg. You will
learn the exact command syntax, how to control the transition duration,
and how to apply different fade curves to achieve a
professional-sounding audio transition.
The acrossfade filter in FFmpeg is designed specifically
to crossfade two input audio streams. It overlays the end of the first
stream with the beginning of the second stream, fading the first one out
while fading the second one in.
The Basic Command
To crossfade two audio files, use the following basic command structure:
ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex "acrossfade=d=5:c1=tri:c2=tri" output.mp3Parameter Breakdown
-i input1.mp3 -i input2.mp3: Specifies the two input audio files you want to merge.-filter_complex: Directs FFmpeg to use a complex filtergraph, which is required when dealing with multiple input files.acrossfade=: Calls the crossfade filter.d=5: Sets the duration of the crossfade in seconds. In this example, the second track will begin fading in 5 seconds before the first track ends.c1=tri: Sets the fade-out curve for the first audio track.tristands for a triangular (linear) curve.c2=tri: Sets the fade-in curve for the second audio track.
Choosing Transition Curves
You can customize how the volume changes during the transition by
changing the curve parameters (c1 and c2).
Some of the most common curve options include:
tri: Linear transition (default). Ideal for general purposes.qsin: Quarter sine wave. Provides a smoother, more natural acoustic transition.exp: Exponential transition. Useful for dramatic, quick fades.log: Logarithmic transition. Good for a slow fade out and quick fade in.
For a smoother, more musical transition, a quarter-sine curve is often preferred:
ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex "acrossfade=d=8:c1=qsin:c2=qsin" output.mp3This command will create an 8-second overlap with an acoustic-style logarithmic volume curve.