forked from andrey-utkin/imgs2video
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcat.sh
executable file
·58 lines (53 loc) · 1.34 KB
/
cat.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
54
55
56
57
58
#!/bin/bash
if [[ -z $IMGS2VIDEO_CFGFILE ]]
then
echo 'IMGS2VIDEO_CFGFILE env var must be available'
exit 1
fi
if ! [[ -f $IMGS2VIDEO_CFGFILE ]]
then
echo "Cfg file $IMGS2VIDEO_CFGFILE does not exist"
exit 1
fi
source $IMGS2VIDEO_CFGFILE
if [[ $# -lt 3 ]]
then
echo 'Usage: <output file> -- <input file 1> [... <input file N>]'
echo 'Options are configured in config file, pass filename as $IMGS2VIDEO_CFGFILE env var'
exit 1
fi
DSTFILE=$1
shift 2
CATLIST="$@"
echo Catlist at cat.sh args: $CATLIST
CATLISTFILE=`mktemp`
for x in $CATLIST
do
x=`readlink -f $x`
echo "# `ls -l $x`" >> $CATLISTFILE
if $FFPROBE $x
then
echo "file $x" >> $CATLISTFILE
else
echo "# BROKEN, EXCLUDED" >> $CATLISTFILE
fi
done
DSTFILE_SRC=${DSTFILE}.src
RET=0
if [[ ! -e $DSTFILE_SRC ]] \
|| ( [[ `wc -l $DSTFILE_SRC | awk '{ print $1 }'` -le `wc -l $CATLISTFILE | awk '{ print $1 }'` ]] \
|| [[ -n "$CAT_EVEN_IF_SHORTER" ]] ) && ! diff -Nurd $DSTFILE_SRC $CATLISTFILE
then
$FFMPEG -f concat -i $CATLISTFILE -vcodec copy -movflags faststart -y $DSTFILE
RET=$?
if [[ $RET == 0 ]]
then
cp $CATLISTFILE $DSTFILE_SRC
else
echo "ERROR: Concatenation of $DSTFILE failed"
fi
else
echo 'Concatenation skipped due to source files matching'
fi
rm $CATLISTFILE
exit $RET