How to Use FFmpeg xfade Radial Transition
This guide explains how to apply a radial transition between two
video clips using FFmpeg's built-in xfade filter. You will
learn the exact command syntax, how to calculate the required time
offset, and how to configure video settings to ensure a seamless
circular wipe effect between your media files.
The Basic Command
To apply a radial transition between two videos, use the
xfade video filter within a -filter_complex
graph. The radial transition acts like a clock-hand wipe, revealing the
second video in a circular sweep.
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "xfade=transition=radial:duration=1:offset=4" -c:v libx264 -pix_fmt yuv420p -c:a aac output.mp4Understanding the Parameters
transition=radial: Specifies the radial wipe effect.duration: The length of the transition in seconds (e.g.,1for a one-second transition).offset: The exact timestamp in seconds on the timeline of the first video when the transition starts.
Calculating the Offset
The offset parameter is critical. If set incorrectly,
the transition will freeze or fail. The formula to calculate the offset
is:
\[\text{Offset} = \text{Duration of First Video} - \text{Transition Duration}\]
For example, if input1.mp4 is 5 seconds long and you
want a 1-second transition: \[\text{Offset} =
5 - 1 = 4\text{ seconds}\]
The transition will begin at second 4 and complete at second 5, seamlessly introducing the second clip.
Matching Video Properties
The xfade filter requires both input videos to share the
same resolution, pixel format, and frame rate. If your sources differ,
normalize them inside the filter graph before passing them to
xfade:
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex \
"[0:v]settb=AVTB,fps=30,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2[v0]; \
[1:v]settb=AVTB,fps=30,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2[v1]; \
[v0][v1]xfade=transition=radial:duration=1:offset=4[v]" \
-map "[v]" -c:v libx264 -pix_fmt yuv420p output.mp4Adding an Audio Crossfade
The xfade filter only handles video streams. To prevent
an abrupt cut in audio, pair xfade with the
acrossfade filter using the same duration:
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex \
"[0:v][1:v]xfade=transition=radial:duration=1:offset=4[v]; \
[0:a][1:a]acrossfade=d=1[a]" \
-map "[v]" -map "[a]" -c:v libx264 -pix_fmt yuv420p -c:a aac output.mp4