How to crossfade between 2 videos | Smooth fade in and out transition between 2 video files

Опубликовано: 14 Октябрь 2021
на канале: The FFMPEG guy
1,229
27

Today, we show how to crossfade between videos. Crossfade is a smooth transition effect between videos where one video fades out and the other one fades in without a cut being visible. Parameters can of course be tuned to suit your individual needs.

EXAMPLES
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
❶ Crossfade between 2 videos, with:
Crossfade effect after 9 seconds
Crossfade duration 1 second
Small crossfading to black perceivable
Synchronous start video 1 and video 2
Sound of video 1 kept
→ ffmpeg -i input01.mp4 -i input02.mp4 -f lavfi -i color=black:s=1280x720 -filter_complex "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=9:d=1:alpha=1[iv0];[1:v]format=pix_fmts=yuva420p,fade=t=in:st=9:d=1:alpha=1[iv1];[2:v]trim=duration=15[bg];[bg][iv0]overlay[bg1];[bg1][iv1]overlay[outv]" -map [outv] -map 0:a output01.mp4

with:
-i input01.mp4 -i input02.mp4 = Reads files «input01.mp4» and «input02.mp4» …
-f lavfi -i color=black:s=1280x720 = … and creates a black 1280x720 video…
-filter_complex = Starts a series of complex filters
[0:v]format=pix_fmts=yuva420p = … converts the input01.mp4 video ([0:v]) to format yuva420p …
fade=t=out:st=9:d=1 = … and creates a 1 second fade OUT effect (to black) after 9 seconds…
alpha=1 = … fading only the alpha channel (i.e. the transparency)…
[iv0] = … calling the resulting video [iv0]…
[1:v]format=pix_fmts=yuva420p = Converts now the input02.mp4 video ([1:v]) to format yuva420p …
fade=t=in:st=9:d=1:alpha=1 = … and creates a 1 second fade IN effect (to black) after 9 seconds, fading only the alpha channel (i.e. the transparency)…
[iv1] = … calling the resulting video [iv1]…
[2:v]trim=duration=15[bg] = Focuses now on the third input (the 1280x720 black video) and cuts it to 15 seconds calling the resulting video [bg]…
[bg][iv0]overlay[bg1] = … overlays now [iv0] on top of [bg] and calls the result [bg1]…
[bg1][iv1]overlay[outv] = … and overlays [iv1] on top of [bg1] and calls the result [outv]…
-map [outv] = Stitches back together the [outv] video result…
-map 0:a = … and the soundtrack of input video “input01.mp4” (0:a)…
output01.mp4 = … and outputs the result to file «output01.mp4»

❷ Crossfade between 2 videos
Crossfade effect after 9 seconds
Crossfade duration 1 second
No small crossfading to black perceivable
Delayed start video 2
→ ffmpeg -i input01.mp4 -i input02.mp4 -f lavfi -i color=black:s=1280x720 -filter_complex "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=9.5:d=1:alpha=1,setpts=PTS-STARTPTS[iv0];[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+9/TB[iv1];[2:v]trim=duration=15[bg];[bg][iv0]overlay[bg1];[bg1][iv1]overlay[outv]" -map [outv] -map 1:a output02.mp4

with:
-i input01.mp4 -i input02.mp4 = Reads files «input01.mp4»
and «input02.mp4» …
-f lavfi -i color=black:s=1280x720 = … and creates a black 1280x720 video…
-filter_complex = Starts a series of complex video filters...
[0:v]format=pix_fmts=yuva420p = … converts the input01.mp4 video ([0:v]) to format yuva420p …
fade=t=out:st=9.5:d=1:alpha=1 = … and creates a 1 second fade OUT effect (to black) after 9.5s fading only the alpha channel…
setpts=PTS-STARTPTS = … considering the start of the video (STARTPTS) as the 0 for timestamping…
[iv0] = … calling the resulting video [iv0]…
[1:v]format=pix_fmts=yuva420p = Converts now the input02.mp4 video ([1:v]) to format yuva420p …
fade=t=in:st=0:d=1:alpha=1 = … and creates a 1 second fade IN effect (to black) after 0 second, fading only the alpha channel (i.e. the transparency)…
setpts=PTS-STARTPTS+9/TB = … setting up the video to start after 9 seconds…
[iv1] = … calling the resulting video [iv1]…
[2:v]trim=duration=15[bg] = Focuses now on the third input (the 1280x720 black video) and cuts it to 15 seconds calling the resulting video [bg]…
[bg][iv0]overlay[bg1] = … overlays now [iv0] on top of [bg] and calls the result [bg1]…
[bg1][iv1]overlay[outv] = … and overlays [iv1] on top of [bg1] and calls the result [outv]…
-map [outv] = Stitches back together the [outv] video result…
-map 1:a = … and the soundtrack of input video “input02.mp4” (1:a)…
output02.mp4 = … and outputs the result to file «output02.mp4»
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Catch up with the FFMPEG guy Channel
   • ALL THE VIDEOS FROM THE CHANNEL  
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
MUSIC
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
→ Bright Eyed Blues - Unicorn Heads
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ
An FFMPEG question?
Ask the FFMPEG guy
ꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷꟷ


Смотрите видео How to crossfade between 2 videos | Smooth fade in and out transition between 2 video files онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь The FFMPEG guy 14 Октябрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,229 раз и оно понравилось 27 людям.