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.mp3This 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.
- Formula:
Total Duration - Fade Duration = Start Time - Example: If your track is 120 seconds long:
120 - 5 = 115. Your start time is115.
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.mp3Command Breakdown:
-i input.mp3: Specifies the input audio file.-af: Applies the audio filter.type=out: Tells FFmpeg to fade the volume down (fade-out).start_time=115: The exact second the fade-out begins.duration=5: The length of the fade-out in seconds.output.mp3: The name of the newly created file with the fade-out effect.