How to Fade Out Audio at the End Using FFmpeg

This article provides a quick, step-by-step guide on how to configure a 5-second fade-out effect at the end of an audio track using FFmpeg. You will learn how to find your audio track’s duration, calculate the correct start time for the fade, and run the precise command to apply the effect.

To apply a fade-out to the end of an audio track, you must use FFmpeg’s afade filter. Because FFmpeg requires a specific start time for the fade-out rather than calculating it backward from the end automatically, you need to follow these three steps.

Step 1: Find the Duration of the Audio Track

First, determine the total length of your audio file in seconds. You can find this using ffprobe with the following command:

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp3

This will output the total duration in seconds (for example, 120.5).

Step 2: Calculate the Fade Start Time

Subtract the desired fade duration (5 seconds) from the total duration of your track.

Step 3: Run the FFmpeg Command

Use the afade filter in your FFmpeg command. Use the type=out (or t=out) parameter, set the start time (start_time or st), and set the duration (duration or d) to 5.

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

Command Breakdown: