Utoljára aktív 2 weeks ago

The scripts that I use for the timelapse video shown at my weather website. Including systemd unit files to be placed in the systemd user directory ($HOME/.config/systemd/user)

dominic gist felülvizsgálása 2 weeks ago. Revízióhoz ugrás

6 files changed, 113 insertions

wxcam-timelapse.service(fájl létrehozva)

@@ -0,0 +1,10 @@
1 + [Unit]
2 + Description="Generate timelapse video from images"
3 + After=network.target
4 +
5 + [Service]
6 + Type=oneshot
7 + ExecStart=/home/dominic/bin/wxcam-timelapse.sh
8 +
9 + [Install]
10 + WantedBy=default.target

wxcam-timelapse.sh(fájl létrehozva)

@@ -0,0 +1,33 @@
1 + #!/bin/sh
2 + # Creates a timelapse video of all the images stored in
3 + # ~/timelapse - done by the other script wxcam-update.sh
4 + #
5 + # Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
6 + # Created: 2025-02-21 20:26
7 + # Lastmod: 2025-04-26 12:15
8 + #
9 + # Changelog:
10 + # - 2025-03-20 05:56
11 + # no idea what i changed here
12 + # - 2025-04-26T12:13:53+0200
13 + # changed framerate from 15 to 10
14 + #
15 + # -pix_fmt yuv420p
16 +
17 + (ffmpeg -y -loglevel info -framerate 10 -pattern_type glob \
18 + -i "/home/dominic/timelapse/*.jpg" -c:v libtheora -q:v 7 -an \
19 + -pix_fmt yuv420p /srv/http/pub/wx/timelapse.ogv && \
20 + ffmpeg -y -loglevel info -framerate 10 -pattern_type glob \
21 + -i "/home/dominic/timelapse/*.jpg" -c:v libx264 -an \
22 + -tune zerolatency -movflags +faststart -crf 24 \
23 + -pix_fmt yuv420p /srv/http/pub/wx/timelapse.mp4 && \
24 + ffmpeg -y -loglevel info -framerate 10 -pattern_type glob \
25 + -i "/home/dominic/timelapse/*.jpg" -c:v libvpx-vp9 -an \
26 + -movflags +faststart -b:v 2M -maxrate 3M -bufsize 3M \
27 + -pix_fmt yuv420p /srv/http/pub/wx/timelapse.webm) >> /home/dominic/ffmpeg-logfile.txt
28 +
29 + if [ "$?" -eq 0 ]; then
30 + cp /srv/http/pub/wx/timelapse.webm /srv/http/pub/wx/timelapse/timelapse-$(date +"%Y%m%d").webm
31 + rm -f /home/dominic/timelapse/*.jpg
32 + rm -f /home/dominic/ffmpeg-logfile.txt
33 + fi

wxcam-timelapse.timer(fájl létrehozva)

@@ -0,0 +1,9 @@
1 + [Unit]
2 + Description="Generate timelapse from images"
3 +
4 + [Timer]
5 + OnCalendar=23:03
6 + Unit=wxcam-timelapse.service
7 +
8 + [Install]
9 + WantedBy=default.target

wxcam-update.service(fájl létrehozva)

@@ -0,0 +1,10 @@
1 + [Unit]
2 + Description="wxcam-update script"
3 + After=network.target
4 +
5 + [Service]
6 + Type=oneshot
7 + ExecStart=/home/dominic/bin/wxcam-update.sh
8 +
9 + [Install]
10 + WantedBy=default.target

wxcam-update.sh(fájl létrehozva)

@@ -0,0 +1,41 @@
1 + #!/bin/sh
2 + # Updates the WX image on the weather station page.
3 + #
4 + # Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
5 + # Created: 2025-02-21 20:12
6 + # Lastmod: 2025-02-23 06:59 2025-08-17 10:38
7 +
8 + # file where the last timestamp is saved
9 + FILE=/tmp/wxcam-timestamp
10 +
11 + # wait for TDIFF seconds before sending another email warning (default 1800 seconds (30minuts))
12 + TDIFF=$((1800))
13 +
14 + if [ ! -w ${FILE} ]; then
15 + # create empty file
16 + >${FILE}
17 + date +%s > ${FILE}
18 + fi
19 +
20 + hour=$(date +%k | sed "s/^ //")
21 +
22 + # echo $hour
23 +
24 + curl -f -s -o /tmp/wx.jpg http://wxcam.lan/jpg
25 +
26 + if [ "$?" -eq 0 ]; then
27 + magick /tmp/wx.jpg -gravity SouthWest -pointsize 30 -font NeoSpleen-Nerd-Font -fill yellow -annotate 0 " $(LANG="""C""" date +"""%a, %Y-%m-%d %H:%M""") · Längenfeld · OE7DRT-13" /srv/http/pub/wx/wxcam.jpg
28 +
29 + if [ "$hour" -gt 3 ] && [ "$hour" -lt 23 ]; then
30 + cp /srv/http/pub/wx/wxcam.jpg /home/dominic/timelapse/tmp-$(date +"%Y%m%d-%H%M%S").jpg
31 + fi
32 + else
33 + old_timestamp=$(<${FILE})
34 + new_timestamp=$(date +%s)
35 + diff=$(expr "$new_timestamp" - "$old_timestamp")
36 +
37 + if [[ "$diff" -ge "${TDIFF}" ]]; then
38 + echo -e "The weather webcam is not reachable.\nI'll wait for ${TDIFF} seconds for the next notification!\n\nhttp://wxcam.lan/mjpeg/1\nhttp://wxcam.lan/jpg\n\nhttps://wxcam.oe7drt.net/mjpeg/1\nhttps://wxcam.oe7drt.net/jpg\n\nCurl exit-code: ${?}" | mutt -s "Weather webcam offline" -- "dominic@mm.st"
39 + date +%s > ${FILE}
40 + fi
41 + fi

wxcam-update.timer(fájl létrehozva)

@@ -0,0 +1,10 @@
1 + [Unit]
2 + Description="Update actual wxcam image"
3 +
4 + [Timer]
5 + OnBootSec=20sec
6 + OnUnitActiveSec=2min
7 + Unit=wxcam-update.service
8 +
9 + [Install]
10 + WantedBy=default.target
Újabb Régebbi