How to Fade Out Audio with FFmpeg afade Filter

This article provides a straightforward guide on how to use the FFmpeg afade filter to apply a smooth fade-out effect to an audio track. You will learn the basic command syntax, the essential parameters for controlling the timing of the fade, and practical examples for processing both standalone audio files and audio within video files.

Understanding the afade Filter Parameters

To apply a fade-out effect, you need to use the afade audio filter and define three primary parameters:

Basic Command Example for Audio Files

If you have an audio file (like an MP3 or WAV) and you want to start a 5-second fade-out at the 10-second mark, use the following command:

ffmpeg -i input.mp3 -filter_complex "afade=type=out:start_time=10:duration=5" output.mp3

Alternatively, you can use the shorthand parameter names:

ffmpeg -i input.mp3 -filter_complex "afade=t=out:st=10:d=5" output.mp3

In this example, the audio will play at normal volume until 10 seconds, gradually decrease in volume over the next 5 seconds, and become completely silent at 15 seconds.

Calculating Fade-Out for the End of an Audio Track

To fade out at the very end of an audio file, you must first know the total duration of the track. Use this formula to find your start time (st):

\[\text{st} = \text{Total Track Duration} - \text{Desired Fade Duration}\]

For example, if your audio track is exactly 3 minutes (180 seconds) long and you want a 10-second fade-out at the end:

The command will look like this:

ffmpeg -i input.wav -filter_complex "afade=t=out:st=170:d=10" output.wav

Applying Audio Fade-Out to a Video File

To apply an audio fade-out to a video file while keeping the original video stream intact without re-encoding it, use the following command structure:

ffmpeg -i input.mp4 -filter_complex "[0:a]afade=t=out:st=55:d=5[a]" -map 0:v -map "[a]" -c:v copy output.mp4