ffmpeg concatenate 3 videos with crossfade [duplic

2019-06-28 06:32发布

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,

标签: ffmpeg
2条回答
孤傲高冷的网名
2楼-- · 2019-06-28 07:02

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
查看更多
走好不送
3楼-- · 2019-06-28 07:15

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
查看更多
登录 后发表回答