How to make fade in/out effect between concatenate

2019-04-13 05:34发布

问题:

I have three videos which divide into three parts on is the start then main video then end of the video in which I concatenate them together I want to add fade in/out effect at the end of the first video and at the start of the third video so they are separated nicely to the viewer.
i used this code to concatenate the video together by adding videos name to the text file

ffmpeg -f concat -i ffmpeg-sound.txt -c copy final_output.mp4

now what command should i pass so i can add this effect as iam not good at ffmgep. or if there is any other things to follow.
Thanks in advance

回答1:

Use the fade and concat filters. In this example each input is 30 seconds long and each complete fade is 4 seconds long.

ffmpeg -i in.mp4 -i main.mp4 -i out.mp4 -filter_complex \
  "[0:v]fade=type=out:duration=2:start_time=28,setpts=PTS-STARTPTS[v0]; \
   [1:v]fade=type=in:duration=2,fade=type=out:duration=2:start_time=28,setpts=PTS-STARTPTS[v1]; \
   [2:v]fade=type=in:duration=2,setpts=PTS-STARTPTS[v2]; \
   [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" \
  -map "[v]" -map "[a]" output.mp4

This assumes that each input has the same parameters (width, height, number of steams, etc). If not then add various filters, such as scale, to conform each input to a common set of parameters. There are many examples on this site showing how to do this.



标签: video ffmpeg