Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg concatenate 3 videos with crossfade [duplicate]

Tags:

ffmpeg

Im trying to join 3 videos together with a crossfade effect.

I can get this working for 2 videos (sourced from stackoverflow but cant find the link):

ffmpeg -y -i part1.mp4 -i part2.mp4 -f lavfi -i color=black:s=1920x1080 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS[va0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[va1]; \
 [2:v]trim=duration=20[over]; \
 [over][va0]overlay[over1]; \
 [over1][va1]overlay=format=yuv420[outv]" \
-vcodec libx264 -map [outv] merged.mp4

But cant work out how to make this work for 3 videos.

I don't need any audio. Any ideas?

Cheers,

like image 296
Crikey Mikey Avatar asked Jan 10 '17 06:01

Crikey Mikey


2 Answers

ffmpeg-concat is the easiest way to accomplish what you want and allows you to use a bunch of sexy OpenGL transitions, with the default being crossfade.

ffmpeg-concat 0.mp4 1.mp4 2.mp4 -o out.mp4

ffmpeg-gl-transition is a more complicated custom ffmpeg filter which allows you to use GLSL to smoothly transition between two video streams. This filter is significantly easier to use and customize than the alternatives listed here.

./ffmpeg -i 0.mp4 -i 1.mp4 -filter_complex "gltransition=duration=4:offset=1.5" out.mp4
like image 111
fisch2 Avatar answered Oct 18 '22 05:10

fisch2


ok so im not sure if this is the best way to do this but i got it working:

ffmpeg -y -i part1.mp4 -i part2.mp4  -i part3.mp4 -f lavfi -i color=black:s=1920x1080 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3:v]trim=duration=30[over]; \
 [over][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]" \
-vcodec libx264 -map [outv] merge.mp4
like image 25
Crikey Mikey Avatar answered Oct 18 '22 04:10

Crikey Mikey