The fade Filter — Fade In and Fade Out
Fade In (gradually reveal the opening from black)
ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=2" output.mp4
| Parameter | Value | Description |
|---|---|---|
t |
in / out |
Direction of the fade |
st |
seconds | Start time of the fade |
d |
seconds | Duration of the fade |
Fade Out (fade the end of the video to black)
ffmpeg -i input.mp4 -vf "fade=t=out:st=8:d=2" output.mp4
st=8 starts the fade-out at 8 seconds, and the fade takes 2 seconds. Change st to fit the length of your video. To find where a video already fades to black, see detecting black frames with blackdetect.
Apply Fade In and Fade Out Together
ffmpeg -i input.mp4 \
-vf "fade=t=in:st=0:d=1.5, fade=t=out:st=8.5:d=1.5" \
output.mp4
Fade to a Color Other Than Black
ffmpeg -i input.mp4 \
-vf "fade=t=in:st=0:d=2:color=white" \
output.mp4
With color=white, the video fades in from white instead of black. To fade the sound as well, add an audio fade-in and fade-out with afade.
The xfade Filter — Crossfade Between Two Clips
Basic Crossfade
ffmpeg -i input1.mp4 -i input2.mp4 \
-filter_complex "[0][1]xfade=transition=fade:duration=1:offset=4" \
output.mp4
| Parameter | Description |
|---|---|
transition |
Name of the transition effect (see below) |
duration |
Duration of the transition (seconds) |
offset |
At what point in the first clip the transition begins (seconds) |
offset=4 means the transition (the effect that switches from one clip to the next) starts 4 seconds into the first clip.
Main Built-In Transition Effects
| Effect Name | Description |
|---|---|
fade |
Crossfade (default) |
wipeleft |
Wipe to the left |
wiperight |
Wipe to the right |
wipeup |
Wipe upward |
wipedown |
Wipe downward |
slideleft |
Slide left |
slideright |
Slide right |
slideup |
Slide up |
slidedown |
Slide down |
circlecrop |
Circular crop |
rectcrop |
Rectangular crop |
distance |
Distance-based |
fadeblack |
Fade through black |
fadewhite |
Fade through white |
radial |
Radial wipe |
smoothleft |
Soft-edged wipe to the left |
smoothright |
Soft-edged wipe to the right |
smoothup |
Soft-edged wipe upward |
smoothdown |
Soft-edged wipe downward |
pixelize |
Pixelate |
diagtl |
Diagonal (bottom-right → top-left) |
diagtr |
Diagonal (bottom-left → top-right) |
diagbl |
Diagonal (top-right → bottom-left) |
diagbr |
Diagonal (top-left → bottom-right) |
hlslice |
Horizontal slice wipe |
hrslice |
Horizontal reverse slice wipe |
vuslice |
Vertical up slice wipe |
vdslice |
Vertical down slice wipe |
dissolve |
Dissolve |
hblur |
Horizontal blur transition |
fadegrays |
Grayscale fade |
squeezeh |
Horizontal squeeze |
squeezev |
Vertical squeeze |
FFmpeg 8.1 has 58 transitions, plus custom, where you write your own expression. Names not in the table include circleopen, wipetl, zoomin, coverleft and revealleft. ffmpeg -h filter=xfade lists the names your build supports, and the xfade article has the full list.
# Wipe-left example
ffmpeg -i input1.mp4 -i input2.mp4 \
-filter_complex "[0][1]xfade=transition=wipeleft:duration=1:offset=4" \
output.mp4
A Note When the Two Clips Have Different Lengths
offset is a time in the first clip, in seconds. Keep offset + duration within the length of the first clip.
# If the first clip is 6 seconds long: offset=5, duration=1 is fine
ffmpeg -i clip1.mp4 -i clip2.mp4 \
-filter_complex "[0][1]xfade=transition=fade:duration=1:offset=5" \
output.mp4
Joining Three Clips with Two Transitions
ffmpeg -i clip1.mp4 -i clip2.mp4 -i clip3.mp4 \
-filter_complex \
"[0][1]xfade=transition=fade:duration=1:offset=4[v01]; \
[v01][2]xfade=transition=wipeleft:duration=1:offset=8" \
output.mp4
- A fade between
clip1andclip2 - A wipe between that result and
clip3
Handling Clips with Audio
xfade handles only video. For the audio, use the acrossfade filter. acrossfade has no offset. It always overlaps the last d seconds of the first clip with the start of the second. So the picture and the sound switch at the same point only when offset equals the first clip’s length minus duration. The example below assumes the first clip is 5 seconds long. If it were 10 seconds long, the video would switch at 4 seconds and the audio at 9.
ffmpeg -i clip1.mp4 -i clip2.mp4 \
-filter_complex \
"[0:v][1:v]xfade=transition=fade:duration=1:offset=4[v]; \
[0:a][1:a]acrossfade=d=1[a]" \
-map "[v]" -map "[a]" \
output.mp4
Adding Crossfades to a Still-Image Slideshow
ffmpeg -loop 1 -t 3 -i img1.jpg \
-loop 1 -t 3 -i img2.jpg \
-filter_complex "[0][1]xfade=transition=fade:duration=1:offset=2" \
output.mp4
Things to Watch Out For
xfadeis available in FFmpeg 4.3 and later. Older versions neededoverlayandfadetogether.offsetmust be smaller than the length of the first clip.- Set
acrossfade’sdto the same value asxfade’sduration, and setoffsetto the first clip’s length minusduration. Then the video and audio switch at the same point.
Common Pitfalls
-
Symptom: the second clip never appears, or it cuts in halfway through the transition (no error is shown). Cause:
offset + durationis longer than the first clip. Ifoffsetis at or past the end of the first clip, the output ends at about the first clip’s length. Fix: keepoffsetat or below the first clip’s length minusduration. If the first clip is 6 seconds,offset=5:duration=1is the limit. -
Symptom: the crossfade works, but the audio disappears or cuts off. Cause:
xfadehandles only video, so the audio needs its own filter. Fix: addacrossfadeand map both results with-map "[v]" -map "[a]". Setacrossfade’sdto the same value asxfade’sduration, and setoffsetto the first clip’s length minusduration. -
Symptom: the fade-out starts at the wrong moment. Cause: in
fade=t=out,stis the time the fade starts, not the time it ends. Fix: to fade out the last 2 seconds of a 10-second clip, usest=8:d=2(because8+2=10). -
Symptom: the two clips differ in resolution or fps, and
xfadestops with an error such asFirst input link main parameters (size 640x360) do not match the corresponding second input link xfade parameters (size 1280x720). Cause:xfadeneeds both inputs to have the same size and frame rate. When only the fps differs, the error mentions thetimebaseorframe rateinstead. Fix: make them match withscaleandfpsbefore passing them toxfade.
FAQ
Q. What is the difference between fade and xfade?
A. fade fades one clip in from black or out to black (or another color you choose). xfade blends two clips as it switches from one to the other. It needs -filter_complex and two inputs.
Q. Can I fade to a color other than black or white?
A. With fade, yes: set any colour with color= (for example color=red or color=0x3366FF). xfade can fade through only black (fadeblack) or white (fadewhite), so no other colour is available as a transition name.
Q. Can I chain three or more clips?
A. Yes. Give the output of one xfade a label and use it as the input of the next one. Separate the steps with ;, as in the three-clip example above.
Q. Does it work for a still-image slideshow?
A. Yes. Turn each image into a looping input with -loop 1 -t 3 -i img1.jpg and join them with xfade. Set offset to match how long each image is shown.
Q. How many transition effects are there?
A. FFmpeg 8.1 has 58, not counting custom. Besides fade, there are wipeleft, slideup, circlecrop, dissolve and more. Put the name after transition=.
Related Filters
afade— Audio fade in/outacrossfade— Audio crossfadeoverlay— Compositing video on top of videoconcat— Concatenating video