wxcam-timelapse.service
· 184 B · SYSTEMD
Sin formato
[Unit]
Description="Generate timelapse video from images"
After=network.target
[Service]
Type=oneshot
ExecStart=/home/dominic/bin/wxcam-timelapse.sh
[Install]
WantedBy=default.target
| 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
· 1.2 KiB · Bash
Sin formato
#!/bin/sh
# Creates a timelapse video of all the images stored in
# ~/timelapse - done by the other script wxcam-update.sh
#
# Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
# Created: 2025-02-21 20:26
# Lastmod: 2025-04-26 12:15
#
# Changelog:
# - 2025-03-20 05:56
# no idea what i changed here
# - 2025-04-26T12:13:53+0200
# changed framerate from 15 to 10
#
# -pix_fmt yuv420p
(ffmpeg -y -loglevel info -framerate 10 -pattern_type glob \
-i "/home/dominic/timelapse/*.jpg" -c:v libtheora -q:v 7 -an \
-pix_fmt yuv420p /srv/http/pub/wx/timelapse.ogv && \
ffmpeg -y -loglevel info -framerate 10 -pattern_type glob \
-i "/home/dominic/timelapse/*.jpg" -c:v libx264 -an \
-tune zerolatency -movflags +faststart -crf 24 \
-pix_fmt yuv420p /srv/http/pub/wx/timelapse.mp4 && \
ffmpeg -y -loglevel info -framerate 10 -pattern_type glob \
-i "/home/dominic/timelapse/*.jpg" -c:v libvpx-vp9 -an \
-movflags +faststart -b:v 2M -maxrate 3M -bufsize 3M \
-pix_fmt yuv420p /srv/http/pub/wx/timelapse.webm) >> /home/dominic/ffmpeg-logfile.txt
if [ "$?" -eq 0 ]; then
cp /srv/http/pub/wx/timelapse.webm /srv/http/pub/wx/timelapse/timelapse-$(date +"%Y%m%d").webm
rm -f /home/dominic/timelapse/*.jpg
rm -f /home/dominic/ffmpeg-logfile.txt
fi
| 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
· 141 B · SYSTEMD
Sin formato
[Unit]
Description="Generate timelapse from images"
[Timer]
OnCalendar=23:03
Unit=wxcam-timelapse.service
[Install]
WantedBy=default.target
| 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
· 164 B · SYSTEMD
Sin formato
[Unit]
Description="wxcam-update script"
After=network.target
[Service]
Type=oneshot
ExecStart=/home/dominic/bin/wxcam-update.sh
[Install]
WantedBy=default.target
| 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
· 1.4 KiB · Bash
Sin formato
#!/bin/sh
# Updates the WX image on the weather station page.
#
# Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
# Created: 2025-02-21 20:12
# Lastmod: 2025-02-23 06:59 2025-08-17 10:38
# file where the last timestamp is saved
FILE=/tmp/wxcam-timestamp
# wait for TDIFF seconds before sending another email warning (default 1800 seconds (30minuts))
TDIFF=$((1800))
if [ ! -w ${FILE} ]; then
# create empty file
>${FILE}
date +%s > ${FILE}
fi
hour=$(date +%k | sed "s/^ //")
# echo $hour
curl -f -s -o /tmp/wx.jpg http://wxcam.lan/jpg
if [ "$?" -eq 0 ]; then
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
if [ "$hour" -gt 3 ] && [ "$hour" -lt 23 ]; then
cp /srv/http/pub/wx/wxcam.jpg /home/dominic/timelapse/tmp-$(date +"%Y%m%d-%H%M%S").jpg
fi
else
old_timestamp=$(<${FILE})
new_timestamp=$(date +%s)
diff=$(expr "$new_timestamp" - "$old_timestamp")
if [[ "$diff" -ge "${TDIFF}" ]]; then
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"
date +%s > ${FILE}
fi
fi
| 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
· 153 B · SYSTEMD
Sin formato
[Unit]
Description="Update actual wxcam image"
[Timer]
OnBootSec=20sec
OnUnitActiveSec=2min
Unit=wxcam-update.service
[Install]
WantedBy=default.target
| 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 |