forked from afrum/my_ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossfade
39 lines (29 loc) · 2.06 KB
/
crossfade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# fading 2 videos into each other - youtube example https://youtu.be/hJH2tJTK8Kc
# I got this from this link: https://ffmpeg.org/ffmpeg-filters.html#Examples-121
# fading 2 videos together:
ffmpeg -i 1.MOV -i 2.MOV -filter_complex xfade=transition=fade:duration=2:offset=5 output.MOV
# video wipes up:
ffmpeg -i 1.MOV -i 2.MOV -filter_complex xfade=transition=wipeup:duration=2:offset=3 output.MOV
# video transitions from the center:
ffmpeg -i 1.MOV -i 2.MOV -filter_complex xfade=transition=circleclose:duration=2:offset=3 output.MOV
# xfade 5 videos in one command you can change transition, duration and offset to suit
ffmpeg -i 1.MOV -i 2.MOV -i 3.MOV -i 4.MOV -i 5.MOV -filter_complex \
"[0:v][1:v] xfade=transition=fade:duration=2:offset=5 [tmp1];\
[tmp1][2:v] xfade=transition=fade:duration=2:offset=8 [tmp2];\
[tmp2][3:v] xfade=transition=circleclose:duration=2:offset=10 [tmp3];\
[tmp3][4:v] xfade=transition=wipeup:duration=2:offset=12" multifade.MOV
# Syahrizal Akbar in the comments of the youtube video provided a solution
# for joining multiple videos with fade effect using overlay that
# solves some of the problems with the cross fade command. Thanks Syahrizal.
ffmpeg -i video.mp4 -i video.mp4 -i video.mp4 -filter_complex \
"[0:v]setpts=PTS-STARTPTS[v1]; \
[1:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(8/TB)[v2];
[2:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(16/TB)[v3];
[v1][v2]overlay[v12]; [v12][v3]overlay,format=yuv420p[v]" \
-map [v] result.mp4
# the xfade command crashed when I first ran it, I cut the video up into 10 second chunks and it worked fine.
# my other video on how to do that https://youtu.be/sAl1lZMVr5A
# when I tried to concatenate the videos as I have done previously it came up with an error: Non-monotonous DTS in output stream 0:0
# After a few different attempts I decided to use the overlay command which I have shown an example at 2:00
# And heres a link to the documentaion on overlay: https://ffmpeg.org/ffmpeg-all.html#Commands-58
# link to xfade: https://ffmpeg.org/ffmpeg-all.html#Examples-159