The xfade and xfade_opencl filters can create transitions between two inputs with various wipes, slides, crossfades, and other effects.


MP4 output

Fade between two images. Each image has a duration of 5 seconds. The fade duration is set to 1 second with the duration option, and it occurs at 4.5 seconds using the offset option.

ffmpeg -loop 1 -t 5 -i 1.png -loop 1 -t 5 -i 2.png -filter_complex "[0][1]xfade=transition=fade:duration=1:offset=4.5,format=yuv420p" output.mp4

GIF output

Using the split, palettegen, and paletteuse filters:

ffmpeg -loop 1 -t 5 -i 1.png -loop 1 -t 5 -i 2.png -filter_complex "[0][1]xfade=transition=fade:duration=1:offset=4.5,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif


Below is gallery of the available effects. fade is the default transition. Names in bold are also available in xfade_opencl.

fade (default) fadeblack fadewhite distance
wipeleft wiperight wipeup wipedown
slideleft slideright slideup slidedown
smoothleft smoothright smoothup smoothdown
rectcrop circlecrop circleclose circleopen
horzclose horzopen vertclose vertopen
diagbl diagbr diagtl diagtr
hlslice hrslice vuslice vdslice
dissolve pixelize radial hblur
wipetl wipetr wipebl wipebr
zoomin transition for xfade
fadegrays squeezev squeezeh zoomin

Command used to make each gallery image; as reference for future gallery additions:

ffmpeg -f lavfi -i "color=c=blue:s=180x136:r=15:d=2,format=rgb24,drawtext=text='fadeblack':x=(w-text_w)/2:y=(h-text_h)/2:box=1:boxborderw=4:boxcolor=white:fontfile=/usr/share/fonts/TTF/VeraMono.ttf:fontsize=20" -f lavfi -i "color=c=aqua:s=180x136:r=15:d=2,format=rgb24,drawtext=text='fadeblack':x=(w-text_w)/2:y=(h-text_h)/2:box=1:boxborderw=4:boxcolor=white:fontfile=/usr/share/fonts/TTF/VeraMono.ttf:fontsize=20" -filter_complex "[0][1]xfade=duration=1:offset=1:transition=fadeblack,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" fadeblack.gif

Custom effects

You can make your own custom effects using transition=custom and the expr options. See the xfade documentation for more info.


xfade_opencl is the Open CL variant of the xfade filter. This filter supports a subset of the filters available in xfade (see bold names in gallery above) and also supports creation of custom effects. It requires ffmpeg to be configured with --enable-opencl and you must initialize a hardware device in your command. See OpenCL Video Filters for general info.

Last modified 6 weeks ago Last modified on Oct 17, 2021, 9:58:53 PM

Attachments (44)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.