diff options
| author | St33v <github@f3rr3t.com> | 2026-06-09 13:07:17 +1000 |
|---|---|---|
| committer | St33v <github@f3rr3t.com> | 2026-06-09 13:07:17 +1000 |
| commit | 421b7cbb42341bf2ce6ce99afe782ac89738519d (patch) | |
| tree | 4d45959bf3ea4aaf303807350705410b11443c69 | |
| parent | f058e83da43b0b661b45a7bd4c82b49c57e61d93 (diff) | |
Use ffmpeg apng muxer for radar loop
ImageMagick on Arch lacks the APNG png-writer; magick was silently
producing single-frame PNGs. Switch to ffmpeg's concat demuxer +
apng muxer, which gives proper animated APNG with per-frame
durations (last frame still gets END_PAUSE).
Add ffmpeg to the pacman install list in setup.sh.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
| -rwxr-xr-x | radarFetch.sh | 22 | ||||
| -rwxr-xr-x | setup.sh | 2 |
2 files changed, 16 insertions, 8 deletions
diff --git a/radarFetch.sh b/radarFetch.sh index 0dcc457..4ba302c 100755 --- a/radarFetch.sh +++ b/radarFetch.sh @@ -30,6 +30,7 @@ require_cmd() { } require_cmd curl require_cmd magick +require_cmd ffmpeg mkdir -p "$TRANS_DIR" "$FRAMES_DIR" "$PLATES_DIR" "$OUT_DIR" @@ -167,22 +168,29 @@ if [ "${#composited[@]}" -eq 0 ]; then exit 0 fi -# --- 6. Assemble APNG loop ----------------------------------------------- -# Per-frame delays: last frame gets END_PAUSE so the eye can rest on "now". +# --- 6. Assemble APNG loop via ffmpeg concat demuxer --------------------- +# ImageMagick's PNG writer on Arch lacks APNG support; ffmpeg's apng muxer +# handles it. Per-frame durations: last frame gets END_PAUSE. mkdir -p "$PUBLISH_DIR" TMP_APNG="${OUT_DIR}/loop.apng.tmp" +LIST_FILE="${OUT_DIR}/concat.txt" -build_cmd=(magick -loop 0) +: > "$LIST_FILE" last_idx=$(( ${#composited[@]} - 1 )) for i in "${!composited[@]}"; do + printf "file '%s'\n" "${composited[$i]}" >> "$LIST_FILE" if [ "$i" -eq "$last_idx" ]; then - build_cmd+=(-delay "$END_PAUSE" "${composited[$i]}") + printf "duration %s\n" "$(awk "BEGIN{print $END_PAUSE/100}")" >> "$LIST_FILE" else - build_cmd+=(-delay "$FRAME_DELAY" "${composited[$i]}") + printf "duration %s\n" "$(awk "BEGIN{print $FRAME_DELAY/100}")" >> "$LIST_FILE" fi done -build_cmd+=("$TMP_APNG") -"${build_cmd[@]}" +# ffmpeg concat quirk: last file must be repeated without a duration line +printf "file '%s'\n" "${composited[$last_idx]}" >> "$LIST_FILE" + +ffmpeg -y -hide_banner -loglevel error \ + -f concat -safe 0 -i "$LIST_FILE" \ + -plays 0 -f apng "$TMP_APNG" install -m 644 "$TMP_APNG" "$PUBLISH_PATH" rm -f "$TMP_APNG" @@ -16,7 +16,7 @@ OWNER=st33v # Packages # --------------------------------------------------------------------------- echo "==> Installing required packages..." -pacman -Sy --needed --noconfirm curl imagemagick ghostscript nginx +pacman -Sy --needed --noconfirm curl imagemagick ghostscript ffmpeg nginx # --------------------------------------------------------------------------- # Nginx conflict checks |
