CrossFade, Dissolve, and other Effects using FFmpeg’s xfade Filter

When you join two videos or images, it is pleasing to the eye to use a crossfade, or dissolve, or a wipe-effect at the point of transition. You don’t need any expensive software to do this – all you need is FFmpeg and an understanding of the xfade filter to add an eye-catching crossfade, dissolve, or any other transition effect to your videos.

In this tutorial, let’s take a look at some common transitions to make your videos look amazing!

How do you add a CrossFade using FFmpeg?

The anatomy of a FFmpeg commandline using the xfade filter is as follows. Let’s look at it one line at a time.

ffmpeg \
-i video1.mp4 \
-i video2.mp4 \
-filter_complex xfade=transition=<FADE_TYPE>:\
duration=<TRANSITION_DURATION_IN_SECONDS>:\
offset=<OFFSET_RELATIVE_TO_FIRST_STREAM_IN_SECONDS> \
outputVideo.mp4
  • you need to provide two input videos – the first video appears before the transition and the second one appears after the transition
  • then we call upon the xfade filter with the following parameters –
    • <FADE_TYPE> – here, you can choose from a wide range of transitions that the xfade filter supports (fade, dissolve, wipeleft, wiperight, etc.)
    • <TRANSITION_DURATION_IN_SECONDS> – here, you specify how long you want the transition to last
    • <OFFSET_RELATIVE_TO_FIRST_STREAM_IN_SECONDS> – here, you can specify (in seconds)after how many seconds you want the transition to begin relative to the first video
  • finally, you specify the output video. Note, that you can also provide encoding parameters here. In the absence of any encoding parameters, FFmpeg will default to crf = 23 with libx264.

In the following sections, let’s take a look at almost all the transitions that are available in FFmpeg’s xfade filter. I have taken two video clips – CrowdRun and Parkjoy and I’ll be concatenating them using a different transition each time.

To make things easier, I’ve created a video for each transition and attached it here. YouTube might experience some buffering issues and start-up delay – please wait a couple of seconds and it will improve.

Okay, let’s get started.


Dissolve Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 \
-filter_complex xfade=transition=dissolve:duration=3:offset=3 \
dissolveVideo.mp4

radial Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=radial:duration=5:offset=0 radialVideo.mp4

circleopen Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=circleopen:duration=5:offset=0 circleOpenVideo.mp4

circleclose Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=circleclose:duration=5:offset=0 circleCloseVideo.mp4

pixelize Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=pixelize:duration=5:offset=0 pixelizeVideo.mp4

hlslice Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=hlslice:duration=5:offset=0 hlsliceVideo.mp4

hrslice Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=hrslice:duration=5:offset=0 hrsliceVideo.mp4

vuslice Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=vuslice:duration=5:offset=0 vusliceVideo.mp4

vdslice Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=vdslice:duration=5:offset=0 vdsliceVideo.mp4

hblur Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=hblur:duration=5:offset=0 hblurVideo.mp4

fadegrays Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=fadegrays:duration=5:offset=0 fadegraysVideo.mp4

fadeblack Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=fadeblack:duration=5:offset=0 fadeblackVideo.mp4

fadewhite Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=fadewhite:duration=5:offset=0 fadewhiteVideo.mp4

rectcrop Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=rectcrop:duration=5:offset=0 rectcropVideo.mp4

circlecrop Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=circlecrop:duration=5:offset=0 circlecropVideo.mp4

wipeleft Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=wipeleft:duration=5:offset=0 wipeleftVideo.mp4

wiperight Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=wiperight:duration=5:offset=0 wiperightVideo.mp4

slidedown Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=slidedown:duration=5:offset=0 slidedownVideo.mp4

slideup Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=slideup:duration=5:offset=0 slideupVideo.mp4

slideleft Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=slideleft:duration=5:offset=0 slideleftVideo.mp4

slideright Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=slideright:duration=5:offset=0 sliderightVideo.mp4

distance Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=distance:duration=5:offset=0 distanceVideo.mp4

diagtl Transition using FFmpeg

ffmpeg -i inputVideo1.mp4 -i inputVideo2.mp4 -filter_complex xfade=transition=diagtl:duration=5:offset=0 diagtlVideo.mp4

Reference

xfade filter documentation on the FFmpeg website. It contains a list of all the transitions that FFmpeg supports. You can download a static FFmpeg build for Windows 64 bit here on OTTVerse.com if you want to test some of these effects.

Click here to access the rest of OTTVerse’s articles.

Leave a Reply

Scroll to Top