-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcat.sh
More file actions
executable file
·76 lines (64 loc) · 1.84 KB
/
Copy pathconcat.sh
File metadata and controls
executable file
·76 lines (64 loc) · 1.84 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Depends now on coreutils (for realpath):
# $ brew install coreutils
INPUT_PATH=$1
OUTPUT_PATH=$2
OUTPUT_FN=$3
REALPATH_LOC=$(which realpath)
if [[ $REALPATH_LOC == "" ]];
then
echo "Missing realpath binary, install it (via coreutils) before using this script"
exit
fi
IN_PATH=$(realpath $INPUT_PATH 2>/dev/null)
if [[ $IN_PATH == "" ]]; then
echo "Missing input path parameter: $INPUT_PATH is not valid"
echo "Usage $0 <input path> <output path> <(optional) output file name>"
exit
fi
OUT_PATH=$(realpath $OUTPUT_PATH)
if [[ $OUT_PATH == "" ]]; then
echo "Missing output path parameter: $OUTPUT_PATH is not valid"
echo "Usage $0 <input path> <output path> <(optional) output file name>"
exit
fi
if [[ ! -e $OUT_PATH ]]; then
echo "Output directory does not exist: $OUT_PATH attempting to make.."
mkdir -p "$OUT_PATH"
fi;
if [[ ! -e $OUT_PATH ]]; then
echo "Output directory does not exist: $OUT_PATH failed to make.."
exit
fi;
if [[ ! -d $OUT_PATH ]]; then
echo "Output directory is invalid: $OUT_PATH is not a directory"
exit
fi
if [[ $OUTPUT_FN == "" ]]; then
echo "Missing output file parameter.. taking a guess"
OUTPUT_FN=$(ls "$IN_PATH" | sort | head -1)
OUTPUT_FN=$(basename $OUTPUT_FN .mp4)_full.mp4
echo "Determined output to be: $OUTPUT_FN"
fi
if [[ $OUTPUT_FN == "" ]]; then
echo "Guessed output file invalid, exiting"
exit
fi
OUTPUT_FILE_PATH=$OUT_PATH/$OUTPUT_FN
echo "OUTPUT: $OUTPUT_FILE_PATH"
TMP=$(mktemp)
echo "Tmp file is $TMP:"
i=0;
for file in $(ls "$IN_PATH" | grep mp4 | sort)
do
file=$(realpath "$IN_PATH"/$file)
if [[ ! -f $file ]];
then
echo "Skipping $file"
continue;
fi
echo -e "\t [$i]: $file"
echo "file '$file'" >> $TMP
((i++))
done
ffmpeg -f concat -safe 0 -i $TMP -c copy "$OUTPUT_FILE_PATH"