DEV Community

Discussion on: Concatenate Videos Together Using ffmpeg!

Collapse
 
gkarumba profile image
gkarumba • Edited

thank you, this works perfectly final question how can I introduce a fadeIn and fadeOut to the video being inserted?

Thread Thread
 
dak425 profile image
Donald Feury

Try something like this, might need tweaking.

This will add a fade out to the end of the first section, a fade in to the start of the second section, a fade out at the end of the second section, and finally a fade in to the start of the last section.

This should mimic the effect of an actual scene transition

ffmpeg -t 20 -i video1.mp4 -i video2.mp4 -ss 20 -i video1.mp4 -filter_complex \
"[0:v]fade=t=out:st=19.5:d=0.5[v0];
[1:v]fade=t=in:st=0:d=0.5,fade=t=out:st=9.5:d=0.5[v1];
[2:v]fade=t=in:st=0:d=0.5[v2];
[v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" final.mp4

You notice that the argument I passed in for the st value of the fade filters for the fade out effects is basically equal to

CLIP_LENGTH - DURATION_OF_FADE_OUT_EFFECT