FuJuntang
2022-07-06 e795b6226a92961ae10d5ef497d2f78fe88fb918
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
54
55
56
#!/bin/sh
 
exist_file()
{
  if [ -e "$1" ]
  then
    return 1
  else
    return 2
  fi  
}
 
if [ $# != 2 ] ; then
echo "USAGE: $0 media_src1 media_src2"
exit 1;
fi
 
arg1=`basename $1`
 
arg2=`basename $2`
 
mainN1=${arg1%%.*}
mainE=${arg1#*.}
mainN2=${arg2%%.*}
 
dirname=`dirname $1`
 
exist_file $1
value=$?
 
if [ $value -eq 2 ] 
then 
  echo "No source media ${arg1} found in the directory! Put it here firstly!\n"
  exit
fi
 
exist_file $2
value=$?
 
if [ $value -eq 2 ] 
then 
  echo "No source media ${arg2} found in the directory! Put it here firstly!\n"
  exit
fi
 
output1=${mainN1}.ts
output2=${mainN2}.ts
 
ffmpeg -i $1 -vcodec copy -acodec copy -vbsf h264_mp4toannexb ${output1}
ffmpeg -i $2 -vcodec copy -acodec copy -vbsf h264_mp4toannexb ${output2}
ffmpeg -i "concat:${output1}|${output2}" -acodec copy -vcodec copy -absf aac_adtstoasc ${mainN1}.${mainE}
 
rm -rf ${output1}
rm -rf ${output2}
rm -rf $1
mv ${mainN1}.${mainE} ${dirname}