-
Notifications
You must be signed in to change notification settings - Fork 1
/
concat_mp4.sh
53 lines (37 loc) · 1.01 KB
/
concat_mp4.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/bash
##################
# INSTALL avconv #
##################
# sudo apt-get install libav-tools
##########
# MANUAL #
##########
# mkfifo temp0 temp1
# avconv -i MVI_3395.MP4 -c copy -bsf:v h264_mp4toannexb -f mpegts -y temp0 2> /dev/null & \
# avconv -i MVI_3394.MP4 -c copy -bsf:v h264_mp4toannexb -f mpegts -y temp1 2> /dev/null & \
# avconv -f mpegts -i "concat:temp0|temp1" -c copy -bsf:a aac_adtstoasc output.mp4
#############
# AUTOMATED #
#############
# . ./concat_mp4.sh MVI_3395.MP4 MVI_3394.MP4
output="output.mp4"
find . -name "temp*" -exec rm {} \;
rm -rf $output
i=0
cmd=""
concat=""
for var in "$@"
do
i=$((i+1))
mkfifo "temp$i"
cmd="$cmd avconv -i \"$var\" -c copy -bsf:v h264_mp4toannexb -f mpegts -y temp$i 2> /dev/null &"
if [ $i == 1 ]; then
concat="concat:temp$i"
else
concat="$concat|temp$i"
fi
done
cmd="$cmd avconv -f mpegts -i \"$concat\" -c copy -bsf:a aac_adtstoasc \"$output\""
echo $cmd
eval $cmd
find . -name "temp*" -exec rm {} \;