Son aktivite 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)

wxcam-timelapse.service Ham
1[Unit]
2Description="Generate timelapse video from images"
3After=network.target
4
5[Service]
6Type=oneshot
7ExecStart=/home/dominic/bin/wxcam-timelapse.sh
8
9[Install]
10WantedBy=default.target
wxcam-timelapse.sh Ham
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 && \
20ffmpeg -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 && \
24ffmpeg -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
29if [ "$?" -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
33fi
wxcam-timelapse.timer Ham
1[Unit]
2Description="Generate timelapse from images"
3
4[Timer]
5OnCalendar=23:03
6Unit=wxcam-timelapse.service
7
8[Install]
9WantedBy=default.target
wxcam-update.service Ham
1[Unit]
2Description="wxcam-update script"
3After=network.target
4
5[Service]
6Type=oneshot
7ExecStart=/home/dominic/bin/wxcam-update.sh
8
9[Install]
10WantedBy=default.target
wxcam-update.sh Ham
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
9FILE=/tmp/wxcam-timestamp
10
11# wait for TDIFF seconds before sending another email warning (default 1800 seconds (30minuts))
12TDIFF=$((1800))
13
14if [ ! -w ${FILE} ]; then
15 # create empty file
16 >${FILE}
17 date +%s > ${FILE}
18fi
19
20hour=$(date +%k | sed "s/^ //")
21
22# echo $hour
23
24curl -f -s -o /tmp/wx.jpg http://wxcam.lan/jpg
25
26if [ "$?" -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
32else
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
41fi
wxcam-update.timer Ham
1[Unit]
2Description="Update actual wxcam image"
3
4[Timer]
5OnBootSec=20sec
6OnUnitActiveSec=2min
7Unit=wxcam-update.service
8
9[Install]
10WantedBy=default.target