Configure FFmpeg xfade Transition Duration and Easing
This article explains how to configure the transition duration, start
offset, and easing curves using the xfade filter in FFmpeg.
You will learn the exact syntax required to apply smooth transitions
between video clips, calculate timing offsets, and choose from various
built-in transition curves to achieve professional visual effects.
The xfade (crossfade) filter in FFmpeg is the standard
tool for applying transitions between two video inputs. Unlike the older
fade filter, xfade supports dozens of
transition shapes and easing curves. To apply the filter successfully,
you must define the transition type, the start time (offset), and the
duration of the effect.
Setting Duration and Offset
The two main parameters for controlling the timing of an
xfade transition are duration and
offset. Both values are expressed in seconds.
duration: The length of time the transition effect lasts.offset: The exact timestamp in the timeline of the first video when the transition begins.
To calculate the correct offset, use this formula:
Offset = (Duration of Video 1) - (Transition Duration)
If Video 1 is 10 seconds long and you want a 2-second transition, the offset must be set to 8 seconds.
Here is the basic command structure:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]xfade=transition=fade:duration=2:offset=8[outv]" -map "[outv]" output.mp4Choosing Transition Shapes and Easing Curves
FFmpeg does not use separate easing curve parameters (like Bezier
curves); instead, it integrates easing styles and motion paths directly
into its predefined transition options.
Below are some of the most common transition curves available in the
xfade filter:
fade: A standard linear crossfade where the first video fades out while the second fades in.wipeleft/wiperight/wipeup/wipedown: Linear gradient wipes moving in the specified direction.slideleft/slideright/slideup/slidedown: One video slides over the other, mimicking a linear motion curve.circlecrop/rectcrop: Easing transitions that expand or shrink in circular or rectangular shapes.dissolve: A pixelated noise-based transition curve.
To change the easing curve or transition style, simply change the
value of the transition parameter:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]xfade=transition=slideleft:duration=1.5:offset=8[outv]" -map "[outv]" output.mp4Handling Audio Transitions
The xfade filter only processes video streams. To
prevent abrupt audio cuts during the transition, you should pair the
video xfade with the acrossfade audio filter.
Match the audio transition’s duration and
overlap to your video’s timing:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex \
"[0:v][1:v]xfade=transition=fade:duration=2:offset=8[outv]; \
[0:a][1:a]acrossfade=d=2:c1=tri:c2=tri[outa]" \
-map "[outv]" -map "[outa]" output.mp4In this audio filter, d=2 sets the duration to 2
seconds, while c1 and c2 define the transition
curves (e.g., tri for triangular, log for
logarithmic, or lin for linear) to ensure the audio ease-in
and ease-out match the video transition seamlessly.