-
Notifications
You must be signed in to change notification settings - Fork 0
/
video-combine
executable file
·48 lines (38 loc) · 1.03 KB
/
video-combine
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
#!/bin/bash
########################################################################
#=> common libs
########################################################################
source "$HOME/CodeHub/SHELL/libs/bootstrap.sh"
HELP_MESSAGE="
Video combine easily with ffmpeg.
usage:
video-combine filename ... outputfile
-h | --help Show help message
"
#=> Show help
if [[ -z "$1" || "$1" == "--help" || "$1" == "-h" ]]; then
helpShow
fi
#=> Main code
TEMPFILE="/tmp/"$(randchar)
OUTPUTFILE=${!#}
# FILEEXT="${OUTPUTFILE##*.}"
# [[ "$FILEEXT" == "$OUTPUTFILE" ]] && FILEEXT=''
if [[ $# < 3 ]]; then
msg_error 'parames count must be over 2'
exit 1
fi
# check files and write file list to tempfile
until [[ $# == 0 ]]; do
FILE="$1"
if [[ "$FILE" != "$OUTPUTFILE" ]]; then
file_exists "$FILE"
die_if_false $? "File does not exist"
echo "file $PWD/$FILE" >> "$TEMPFILE"
fi
shift
done
# combine
ffmpeg -f concat -i "$TEMPFILE" -c copy "$OUTPUTFILE"
# delete the temp file
rm -f "$TEMPFILE"