-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-archive
executable file
·72 lines (60 loc) · 1.39 KB
/
create-archive
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
#!/bin/bash
if [ -n "$DEBUG" ]; then
set -x
fi
BASE="$HOME/archive/movies"
BITRATE=5000k
CRF=23
POSITION="unknown"
pwd | grep river
if [ $? -eq 0 ]; then
POSITION="river"
fi
pwd | grep street
if [ $? -eq 0 ]; then
POSITION="street"
fi
if [ $POSITION == "unknown" ]; then
echo "don't know where I am"
echo "can't find river nor street in current path"
echo "exit"
exit
fi
echo "direction is $POSITION"
cd $1
EXIF=$(stat -c%n exif*)
if [ $? -eq 0 ]
then
# in case there is more than one exif*, just pick the first
EXIF=$(stat -c%n exif*|head -1)
echo "processing $EXIF"
else
echo "start process of $(pwd)"
process-tl-dir -v 1
EXIF=$(stat -c%n exif*|head -1)
fi
cd $EXIF
mkmov -c hevc -2 -q $CRF -b $BITRATE -v
YEAR=$(stat -c%n *.mp4| head -1 | cut -b1-4)
if [ $? -ne 0 ]; then
echo "couldn't find output mp4"
exit
fi
MONTH=$(stat -c%n *.mp4| head -1 | cut -b6-7)
mkdir -p $BASE/{webm,x265}
TGTDIR="$YEAR/$MONTH-$(date -d "$YEAR-$MONTH-01" +%B)"
mkdir -p $BASE/x265/$POSITION/$TGTDIR
mv -v *.mp4 $BASE/x265/$POSITION/$TGTDIR
mkmov -c vp9 -2 -q $CRF -b $BITRATE -v
YEAR=$(stat -c%n *.webm| head -1 | cut -b1-4)
if [ $? -ne 0 ]; then
echo "couldn't find output webm"
exit
fi
MONTH=$(stat -c%n *.webm| head -1 | cut -b6-7)
TGTDIR="$YEAR/$MONTH-$(date -d "$YEAR-$MONTH-01" +%B)"
mkdir -p $BASE/webm/$POSITION/$TGTDIR
mv -v *.webm $BASE/webm/$POSITION/$TGTDIR
cd ..
rm -rf exif*
cd ..