-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossfade.sh
executable file
·30 lines (28 loc) · 1.04 KB
/
crossfade.sh
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
#!/usr/bin/env bash
#
# crossfade.sh
# Merges two videos with a one second crossfade.
# Usage: crossfade.sh video1 video2 timetofade
# Output is a lossless H.264 MKV with PCM audio
#
INPUT1=$1
INPUT2=$2
FADETIME=$3
FADEEND=$(($FADETIME+1))
ffmpeg -i ${INPUT1} -i ${INPUT2} -an \
-filter_complex \
" [0:v]trim=start=0:end=${FADETIME},setpts=PTS-STARTPTS[firstclip];
[1:v]trim=start=1,setpts=PTS-STARTPTS[secondclip];
[0:v]trim=start=${FADETIME}:end=${FADEEND},setpts=PTS-STARTPTS[fadeoutsrc];
[1:v]trim=start=0:end=1,setpts=PTS-STARTPTS[fadeinsrc];
[fadeinsrc]format=pix_fmts=yuva420p,
fade=t=in:st=0:d=1:alpha=1[fadein];
[fadeoutsrc]format=pix_fmts=yuva420p,
fade=t=out:st=0:d=1:alpha=1[fadeout];
[fadein]fifo[fadeinfifo];
[fadeout]fifo[fadeoutfifo];
[fadeoutfifo][fadeinfifo]overlay[crossfade];
[firstclip][crossfade][secondclip]concat=n=3[output];
[0:a][1:a] acrossfade=d=1 [audio]
" \
-map "[output]" -map "[audio]" -y -c:a pcm_s16le -c:v libx264 -preset ultrafast -qp 0 crossfaded.mkv