-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimelapse
executable file
·144 lines (125 loc) · 2.8 KB
/
timelapse
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# starts a timelapse process in the background
# first parameter has to be start or stop
# the following parameter will be appended to the libcamera-still command
BASE=/nfs/timelapse/$HOSTNAME
function help {
SCRIPT=${0##*/}
echo
if [ ! -z "$PID" ]; then
echo " libcamera-still is running on host $(hostname)"
echo " PID: $PID"
echo " output to $(cat ~/tmp/timelapse.dir)"
echo
echo " type '$SCRIPT stop' to end timelapse recording"
else
echo " libcamera-still is not running on host $(hostname)"
echo
echo " type '$SCRIPT start' to begin timelapse"
fi
exit
}
# check if the nfs mount is available
function mounted () {
MAXTRIES=10
WAIT=5
COUNTER=0
until mountpoint /nfs
do
echo "$COUNTER: wait for $WAIT seconds"
/bin/sleep $WAIT
COUNTER=$((COUNTER+1))
if [ $COUNTER -gt $MAXTRIES ]; then
echo "/nfs is not a mountpoint, exiting ..."
exit 1
fi
done
}
# default parameter
EX=night
TL=60000
WIDTH=1920
HEIGHT=1080
FLIP=
OUTPUTDIR=~/timelapse
while getopts ":nut:w:h:d:" opt; do
case $opt in
d)
echo OUTPUTDIR $OPTARG
OUTPUTDIR=$OPTARG
;;
n)
echo "night start"
EX="night"
;;
t)
echo "interval $OPTARG"
TL=$OPTARG
;;
w)
echo "width $OPTARG"
WIDTH=$OPTARG
;;
h)
echo "height $OPTARG"
HEIGHT=$OPTARG
;;
u)
echo "upside down mode"
FLIP="-vf -hf"
;;
\?)
echo "invalid option: -$OPTARG"
;;
esac
done
shift $((OPTIND-1))
CMD=$1
shift
echo libcamera-still --width $WIDTH --height $HEIGHT -ex $EX --timelapse $TL $CMD
PID=$(pgrep libcamera-still)
if [ "$CMD" = "start" ] || [ "$CMD" = "stop" ]
then
case "$CMD" in
stop)
if [ -z "$PID" ]
then
echo libcamera-still is not running
else
kill $PID
echo we stopped libcamera-still with pid: $PID
echo
echo "go to $(cat ~/tmp/timelapse.dir) for the output"
fi
;;
start)
if [ ! -z "$PID" ]
then
echo "found running libcamera-still, pid $PID"
else
mounted "~/timelapse"
DAYDIR=$OUTPUTDIR/`date +%Y%m%d`
mkdir -p $DAYDIR
DIR=$DAYDIR/`date +%Y%m%d-%H%M`
mkdir -p $DIR
mkdir -p ~/tmp
echo $DAYDIR > ~/tmp/timelapse.dir
FOTOS=~/pictures
mkdir -p $DIR
set -x
libcamera-still --verbose 0 --width $WIDTH --height $HEIGHT --timelapse $TL $FLIP -n -t 0 --latest $FOTOS/last.jpg --output $DIR/tl%06d.jpg $* &
ln -s ~steffenr/www/jq-galerie/galerie.html $DIR
set +x
echo libcamera-still started
echo stop with: timelapse stop
echo output directory: $DIR
fi
;;
*)
SCRIPTNAME=${0##*/}
echo "$SCRIPTNAME start|stop"
;;
esac
else
help
fi