The xfade and xfade_opencl filters can create transitions between two inputs with various wipes, slides, crossfades, and other effects.
Offset Parameter
If it is not obvious by logical reasoning, the offset parameter should be set to value such as full duration of transition is possible between two videos, thus offset parameter into first video stream should not be greater than duration of first video minus duration of transition itself and also duration of second video should be at least long as transition duration itself.
Examples
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 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,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,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Gallery
Below is gallery of the available effects. fade
is the default transition. Names in bold are also available in xfade_opencl.
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
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.
Attachments (44)
- circlecrop.gif (8.4 KB ) - added by 3 years ago.
- distance.gif (29.0 KB ) - added by 3 years ago.
- fade.gif (8.1 KB ) - added by 3 years ago.
- fadeblack.gif (18.9 KB ) - added by 3 years ago.
- fadewhite.gif (18.7 KB ) - added by 3 years ago.
- radial.gif (31.7 KB ) - added by 3 years ago.
- rectcrop.gif (8.7 KB ) - added by 3 years ago.
- slidedown.gif (23.1 KB ) - added by 3 years ago.
- slideleft.gif (23.6 KB ) - added by 3 years ago.
- slideright.gif (26.2 KB ) - added by 3 years ago.
- smoothup.gif (25.9 KB ) - added by 3 years ago.
- slideup.gif (19.4 KB ) - added by 3 years ago.
- wipedown.gif (4.8 KB ) - added by 3 years ago.
- wipeleft.gif (4.8 KB ) - added by 3 years ago.
- wiperight.gif (5.0 KB ) - added by 3 years ago.
- wipeup.gif (4.5 KB ) - added by 3 years ago.
- smoothleft.gif (33.2 KB ) - added by 3 years ago.
- smoothright.gif (33.3 KB ) - added by 3 years ago.
- smoothdown.gif (25.2 KB ) - added by 3 years ago.
- circleclose.gif (52.4 KB ) - added by 3 years ago.
- circleopen.gif (51.9 KB ) - added by 3 years ago.
- horzclose.gif (22.1 KB ) - added by 3 years ago.
- horzopen.gif (21.9 KB ) - added by 3 years ago.
- vertclose.gif (34.0 KB ) - added by 3 years ago.
- vertopen.gif (34.8 KB ) - added by 3 years ago.
- diagbl.gif (59.8 KB ) - added by 3 years ago.
- diagbr.gif (59.7 KB ) - added by 3 years ago.
- diagtl.gif (60.6 KB ) - added by 3 years ago.
- diagtr.gif (60.8 KB ) - added by 3 years ago.
- dissolve.gif (25.9 KB ) - added by 3 years ago.
- pixelize.gif (14.5 KB ) - added by 3 years ago.
- hlslice.gif (10.4 KB ) - added by 3 years ago.
- hrslice.gif (10.5 KB ) - added by 3 years ago.
- vdslice.gif (5.7 KB ) - added by 3 years ago.
- vuslice.gif (5.7 KB ) - added by 3 years ago.
- wipebl.gif (7.3 KB ) - added by 3 years ago.
- wipebr.gif (7.8 KB ) - added by 3 years ago.
- wipetl.gif (7.5 KB ) - added by 3 years ago.
- wipetr.gif (7.5 KB ) - added by 3 years ago.
- fadegrays.gif (27.1 KB ) - added by 3 years ago.
- hblur.gif (33.0 KB ) - added by 3 years ago.
- squeezeh.gif (9.7 KB ) - added by 2 years ago.
- squeezev.gif (17.3 KB ) - added by 2 years ago.
-
zoomin.gif
(19.3 KB
) - added by 17 months ago.
zoomin transition for xfade
Download all attachments as: .zip