Fade in and fade out video and audio with FFmpeg
Add fade-in / fade-out effects to video and audio. The fade and afade filters, the timing parameters, and the chain that does both at once.
When to use this
You apply fade in/out to video for production-quality openings/closings, social-media clip polish, advertisement transitions, or smoothing the audio at clip boundaries to avoid pops. Two filters: fade for video, afade for audio. They're independent — you can fade one without the other, but typically you fade both together. The pattern is the same across both.
Command variants
ffmpeg -i input.mp4 \
-vf "fade=in:0:60" \
-c:v libx264 -preset medium -crf 21 \
-c:a copy \
output.mp4fade=in:start_frame:num_frames. 0:60 = fade-in starting at frame 0, lasting 60 frames (2s at 30fps).
ffmpeg -i input.mp4 \
-vf "fade=t=in:st=0:d=2,fade=t=out:st=28:d=2" \
-c:v libx264 -preset medium -crf 21 \
-c:a copy \
output.mp4Time-based syntax: t=in/out, st=start_seconds, d=duration_seconds. Fade-in 0-2s, fade-out at 28s (assuming 30s clip).
ffmpeg -i input.mp4 \
-af "afade=t=in:st=0:d=2,afade=t=out:st=28:d=2" \
-c:v copy \
output.mp4afade with same syntax. Audio-only fade; video stream-copies.
ffmpeg -i input.mp4 \
-vf "fade=t=in:st=0:d=2,fade=t=out:st=28:d=2" \
-af "afade=t=in:st=0:d=2,afade=t=out:st=28:d=2" \
-c:v libx264 -preset medium -crf 21 \
-c:a aac -b:a 192k \
output.mp4Combine -vf and -af for synchronized fades on both tracks. Standard production opening/closing pattern.
What each parameter does
fade=t=type:st=start:d=durationTime-based fade syntax. Modern, readable, easy to chain.
fade=type:start_frame:num_framesFrame-based fade syntax (legacy). Useful for frame-accurate fades but harder to read at variable framerates.
afade=t=in/out:st=start:d=durationAudio fade with same parameters as video fade.
curve=tri/qsin/esin/logOptional fade curve. tri (triangular linear) is default; log gives a more natural-feeling fade especially for audio.
What this outputs
A re-encoded (video) or re-encoded (audio) file with fades applied. Stream-copy isn't possible because fades modify pixel/sample values.
Pitfalls
- Fade-out timing must subtract from clip length: for a 30-second clip with a 2-second fade-out, the fade starts at 28 seconds. Off-by-one math here is a common bug.
- Audio fades must extend the entire fade duration; clipping the fade because the clip ends abruptly produces audible pops.
- Frame-based fade syntax (fade=in:0:60) breaks if you don't know the framerate. Use time-based syntax (fade=t=in:st=0:d=2) for portable code.
- Fades on already-encoded content require re-encoding. For HLS-packaged content where you want fades, generate the master with fades baked in, then re-package.
- Crossfades between two clips require concat with overlap, not simple chaining. The concat filter's overlap mode handles this; FFmpeg's xfade filter is the modern approach.
At production scale
Fades are libx264-bound and minimal in compute cost — typically <2% overhead vs encoding without fades. For production pipelines applying fades as a standard step (e.g., social-clip generation with branded openings/closings), the cost is negligible.
MpegFlow models fades as parameterized DAG stages — opening/closing fades are per-customer configurable, applied as a final pass before delivery. The audit log records the exact fade parameters used.
- FFmpeg
- fade
- transition
- video-operations
- audio