What You’ll Learn
- How to apply fade-in and fade-out with the
afadefilter - The meaning of
t(type),st(start time), andd(duration) - Differences between curve types (
tri,sin,exp, etc.) - How to apply fades to the audio track of a video file
- How to combine fade-in and fade-out in a single command
Tested with: FFmpeg 6.1 (verified on ubuntu-latest / CI) Platform: Windows / macOS / Linux
Basic Commands
Fade-in (gradually ramp up at the start)
ffmpeg -i input.mp3 -af "afade=t=in:st=0:d=3" output.mp3
| Parameter | Value | Description |
|---|---|---|
t=in | — | Fade in |
st=0 | 0 s | Fade start time |
d=3 | 3 s | Fade duration |
Fade-out (gradually ramp down at the end)
First check the length of the audio:
ffmpeg -i input.mp3 -f null /dev/null 2>&1 | grep Duration
Fade out over the last 10 seconds of a 60-second file:
ffmpeg -i input.mp3 -af "afade=t=out:st=50:d=10" output.mp3
| Parameter | Value | Description |
|---|---|---|
t=out | — | Fade out |
st=50 | 50 s | Fade start time |
d=10 | 10 s | Fade duration |
Applying Fade-In and Fade-Out Together
Chain multiple filters with a comma inside -af:
ffmpeg -i input.mp3 -af "afade=t=in:st=0:d=3,afade=t=out:st=50:d=10" output.mp3
Curve Types
Use the curve option to change the shape of the fade:
ffmpeg -i input.mp3 -af "afade=t=in:st=0:d=3:curve=qsin" output.mp3
| Curve | Description |
|---|---|
tri | Linear (triangular). The default |
qsin | Quarter sine wave. Natural-sounding |
hsin | Half sine wave. Smoother S-shape |
exp | Exponential. Changes sharply |
log | Logarithmic. Starts sharply, ends gently |
Apply Fades to the Audio Track of a Video File
ffmpeg -i input.mp4 -af "afade=t=in:st=0:d=2" -c:v copy output.mp4
-c:v copy keeps the video untouched and only re-encodes the audio.
Combine with Video Fades
Apply a matching video fade (fade) alongside the audio fade (afade):
ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=2" -af "afade=t=in:st=0:d=2" -c:a aac output.mp4
Common Pitfalls
Match st to the actual audio length for fade-out
If st + d goes past the end of the track FFmpeg will not error out, but the fade will be truncated. Check the duration first if the fade sounds cut short.
Combine with -c:v copy to re-encode only the audio
When the video doesn’t need any changes, -c:v copy preserves its quality and only the audio is re-encoded.
Frequently Asked Questions
What is the difference between afade and acrossfade?
afade fades a single track in or out, while acrossfade blends two tracks over a transition window. For BGM swaps, use acrossfade; for opener/closer fades, use afade.
How long should the fade be?
Speech: 0.3–0.5 s in, 1–2 s out. Music: 1–2 s in, 2–4 s out. Anything shorter than 100 ms can pop on cheaper speakers.
Can I fade only specific frequencies?
afade affects the whole signal. For frequency-selective fading you would chain a band filter (e.g. lowpass) before the fade.
Why does my fade start too early?
Check the st= (start time) parameter — fades default to 0. To fade out at the end of the file, compute start = duration − fade_length and pass it explicitly.
Does afade re-encode the file?
Yes — any audio filter forces re-encoding of the audio track. Video can stay copy-only by using -c:v copy alongside.
Related Articles
- Volume Level Detection — check peak and average loudness with volumedetect
- Extract Audio — use -vn to pull audio out of a video
Tested with ffmpeg 6.1 / Ubuntu 24.04 (GitHub Actions runner) Primary sources: ffmpeg.org/ffmpeg-filters.html#afade / trac.ffmpeg.org/wiki/AudioVolume