Commit Graph
100 Commits
Author SHA1 Message Date
Claude 5244fbb89b Fix missed raw draw.text in render_phase_closeup
The previous commit replaced the caption block in composite_full_moon
but missed render_phase_closeup because that block had no comment to
match the replace_all pattern. Both caption sites now go through
_draw_caption() so the Unicode / font fix applies everywhere.

https://claude.ai/code/session_01HkTxpNSTWtViZzxbrbKytR
2026-05-01 18:10:25 +00:00
Claude b45ef3a791 Fix UnicodeEncodeError in caption drawing
The default PIL bitmap font only covers latin-1, so the em dash (U+2014)
in captions raised UnicodeEncodeError at runtime.

Add _load_font() which tries DejaVu Sans TTF from common system paths
(the fonts-dejavu package is already a listed dependency) and falls back
to the PIL default only when no TTF is found.  Add _draw_caption() which
wraps both the font load and the two-pass drop-shadow draw, and sanitises
the string for the bitmap fallback path so it never crashes.

Replace both raw draw.text caption blocks in composite_full_moon() and
render_phase_closeup() with _draw_caption().

https://claude.ai/code/session_01HkTxpNSTWtViZzxbrbKytR
2026-05-01 18:07:53 +00:00
Claude 09fda8d8af Add smoke-test script for cloud-veil composite
test_moon_composite.py uses the existing repo sample frames
(21-07-00.jpg east frame with thin cloud cover + full_moon_closeup.jpg
as NASA render stand-in) to produce test_composite_out.jpg without
needing a live NASA API call or moon detection run.

Run: python3 test_moon_composite.py

https://claude.ai/code/session_01HkTxpNSTWtViZzxbrbKytR
2026-05-01 17:16:50 +00:00
Claude 3ededd68b8 Add per-event NASA moon images with east-sky cloud veil
Three changes driven by the same goal: make each monthly moon post
look like east captured it at that exact moment.

Tighter illumination windows (±4% of target phase):
  Full moon:   95% → 96–100%  (was a 5-point band; now hugs exact full)
  Quarters:    40–65% → 46–54%  (was a 25-point band; now ±4% of 50%)
This ensures the NASA Dial-a-Moon render timestamp is pulled within
4 percentage points of the true phase, making the fetched image
genuinely represent that night's moon.  One fresh fetch per event,
~3/month, cached by hour — never reused across months.

Atmospheric cloud veil from east's surrounding sky:
  _extract_cloud_veil() samples the annular sky region just outside
  east's moon disk (2×–5× radius), scales it to the output frame,
  blurs heavily (GaussianBlur r≈output_width/10) so it reads as haze
  rather than an upscaled photo, then blends it over the NASA composite
  at an opacity proportional to sky brightness:
    sky < 5% mean brightness → no veil (clear dark night)
    sky ~10%                 → ~17% veil (thin haze / airglow)
    sky ≥ 20%                → 40% veil (max, MOON_CLOUD_OVERLAY_MAX_OPACITY)
  After the veil pass the NASA moon disk is re-pasted sharply so the
  haze sits naturally behind the crisp lunar surface.
  This is the honest answer to "east can't capture high-res clouds":
  east's real atmospheric fingerprint becomes the veil texture.

New sky-cam.conf keys:
  MOON_CLOUD_OVERLAY_ENABLED=true
  MOON_CLOUD_OVERLAY_MAX_OPACITY=0.40
  #MOON_CLOUD_OVERLAY_BLUR=0  (0 = auto)

https://claude.ai/code/session_01HkTxpNSTWtViZzxbrbKytR
2026-05-01 17:07:16 +00:00
Claude 28c3c1dc63 Switch monthly phase close-ups to NASA SVS Dial-a-Moon at fullscreen
The previous east-flavored composite (tight-crop east region + lunar
texture overlay) was honest but visually limited: 38-px source moon, no
real terminator shadows on quarters, and a faint upscaled-halo
background that was less compelling than just a clean lunar render.

New flow:
- East stays the witness (verifies the moon was visible during the
  collection window) and supplies the timestamp.
- moon_dialamoon.py fetches the NASA SVS Dial-a-Moon render for that
  exact UTC hour. Free, public-domain, real-physics: correct phase,
  libration, and crater shadows for any timestamp.
- moon_composite.render_phase_closeup() places that render at ~92% of
  frame height on a 1920x1080 black background -- the long-telephoto
  look the user asked for.
- One API call per phase event (~36/year), cached forever in
  moon-ref/dialamoon/.

Quarter moons now show real 3D crater shadows along the terminator,
which the prior algorithmic phase-shadow couldn't simulate from a
full-moon reference.

Adds MOON_REQUIRE_EAST_VERIFY=true|false toggle so the user can choose
"only post when east saw it" (default, current behavior) vs "post every
cycle regardless of weather over east."

Drops the install-time lunar reference download (no longer needed) and
the now-unused per-phase phase-shadow path stays in moon_composite.py
for reference / future reuse.

https://claude.ai/code/session_015PBVDESC3KLMbq1LpA6qLn
2026-05-01 11:54:46 +00:00
Claude ed8982da0e Fix afade: bc omits leading zero for values < 1 (.850 → 0.850)
fade_dur = SUNRISE_TARGET_SECS * 0.085 = 0.850 at the default 10s target.
bc outputs .850 without a leading zero, which ffmpeg's afade filter rejects
with "Unable to parse option value .850 as duration". Pipe bc output through
sed to prepend the zero when the value starts with '.'.

https://claude.ai/code/session_01DANuzLCLhhQ7Li12RTcswY
2026-05-01 05:09:57 +00:00
Claude 61e9e4d0be Add ambient chunk as 2nd audio fallback; fix capture service exit-code bug
daily_sunrise_video.sh:
- Insert continuous ambient recording extract as 2nd fallback (after today's
  scheduled sunrise audio, before live RTSP).  Finds the chunk file in
  AUDIO_DIR/<cam>/<date>/ whose start time is the latest one at or before
  sunrise, then ffmpeg-copies SUNRISE_TARGET_SECS centred on sunrise_sec.
- Renumber remaining fallbacks: live RTSP → 3rd, yesterday → 4th, library → 5th.

sunrise-audio-capture.sh:
- Fix: retention find pipeline could exit non-zero (directory not yet created
  or permission error) and with set -euo pipefail cause the service to report
  status=1/FAILURE even after a successful capture.  Guard with [ -d ] and
  add || true so a retention failure never masks a successful recording.

https://claude.ai/code/session_01DANuzLCLhhQ7Li12RTcswY
2026-04-30 19:47:53 +00:00
Claude 65b8caf7f9 Reorder audio fallback chain: today → live RTSP → yesterday → library
Moves live RTSP capture to 2nd position so current ambient sound is
preferred over a day-old recording when today's scheduled capture is missing.

https://claude.ai/code/session_01DANuzLCLhhQ7Li12RTcswY
2026-04-30 11:53:57 +00:00
Claude c2d4d97361 Fix audio: live RTSP fallback + mix retry + journal in ntfy; overlay at 15%
- daily_sunrise_video.sh: add live RTSP capture as final fallback in production
  audio selection (fires when today, yesterday, and library all miss)
- On audio mix failure, retry once with a fresh live RTSP capture before
  giving up — handles corrupt/incompatible pre-recorded files
- When mix still fails after retry, append last 30 lines of
  sky-cam-audio-capture.service journal to the ntfy notification body
- Move sunrise-time text overlay from 5% to 15% above the bottom edge

https://claude.ai/code/session_01DANuzLCLhhQ7Li12RTcswY
2026-04-30 11:50:02 +00:00
Claude 5fb7ff09a3 Add nightly moon-track timelapse and monthly moon-phase composites
Two new jobs operate on the SUNRISE_CAM, sharing three Python helpers
(moon_phase, moon_detect, moon_composite) and one cached lunar texture:

- moon-track.sh: nightly batch detects the moon in each east frame,
  crops a 480x480 box around it, stitches into an mp4 that holds the
  moon roughly centred while clouds and stars drift past.

- moon-phase-monthly.sh: daily check that runs whichever phase composite
  is due that day. Handles full moon (posts D+3), first quarter (D+2,
  best-effort due to daytime-only geometry from east), and third quarter
  (D+2). Picks the frame closest in time to the exact phase moment that
  meets quality / altitude / illumination thresholds, then composites
  the cached lunar texture into it -- sky/halo/parallactic-angle/timing
  real from east, surface detail borrowed from the reference image.

Honest-by-design: a 38-px white blob from a wide-field IP camera cannot
be enhanced into crater detail by software. The composite makes the
borrowing explicit and constrains everything else (when, where, sky,
orientation) to match what east actually saw.

install.sh now downloads the skyfield ephemeris (de421.bsp) and the
default lunar reference (Wikipedia CC BY-SA full-moon photo) on first
run. Both can be overridden via .env.

https://claude.ai/code/session_015PBVDESC3KLMbq1LpA6qLn
2026-04-30 11:40:11 +00:00
Claude 5810ab0194 Trim weather-tag vocabulary to audio-relevant precipitation only
Drops clear/cloudy/fog/windy and the wind-speed override — those
conditions sound the same on the recordings, so they don't earn a tag.
Also renames "rainshower" → "rainstorm" and rebalances the rain
mapping so 503/504/522 (extreme + heavy showers) get the storm tag.

Final vocabulary: thunderstorm, rain, rainstorm, snow, snowstorm.
Anything else falls through to the un-tagged filename.
2026-04-29 18:55:59 +00:00
Claude 9e1087f875 Tag ambient audio chunks with current OpenWeather conditions
Adds weather-tag.sh, a small failure-safe helper that queries OpenWeather's
free "Current weather" endpoint and prints one tag from a fixed vocabulary
(thunderstorm, rain, rainshower, snow, snowstorm, fog, windy, cloudy, clear)
or nothing on any failure.

ambient-record.sh calls it just before each 30-minute chunk so the filename
reflects conditions at the moment of capture, e.g.
  east-08-30-00-thunderstorm.m4a
  east-12-00-00-clear.m4a
A foggy dawn no longer mislabels the sunny afternoon files.

Off by default. Enable with WEATHER_ENABLED=true and an
OPENWEATHER_API_KEY entry in .env; missing key / API error / disabled
toggle all fall through to the un-tagged filename, never blocking the
recorder.
2026-04-29 18:40:27 +00:00
Claude 7c5a703222 Fix sky-cam-audio-capture.service spurious failure on no-op retention
The retention block ended with `[ test ] && echo`, which under `set -e`
returns exit 1 when `deleted` is 0 — the normal case on most days. As
the script's last command, that bash exit propagated to systemd, which
marked the unit failed and fired the OnFailure ntfy even though the
audio file was written successfully.

Add `|| true` and an explicit `exit 0` so a no-op retention pass is
treated as success.
2026-04-29 18:33:03 +00:00
Claude cba5b5b1e8 Document drawtext overlay settings for easy customization
Adds a quick-edit cheatsheet covering font, color, size, position, and
shadow/border for the sunrise-time overlay so the layout can be tweaked
without grokking ffmpeg's drawtext syntax.
2026-04-29 18:20:20 +00:00
Claude 93935876de sunrise: scale audio fades to 8.5% of target duration
Replaces the fixed 0.3s fade with SUNRISE_TARGET_SECS * 0.085, so a 10s
clip now fades 0.85s in and out.  The fade scales automatically if the
target duration is tuned later.
2026-04-24 12:27:52 +00:00
Claude 63b4d2e2d9 sunrise: quicker audio fades, raise overlay, yesterday-audio fallback
- Shorten audio fade in/out to 0.3s so they fit comfortably in the 10s clip.
- Lift the sunrise-time overlay by ~5% of frame height to clear the
  burnt-in timestamp on the source images.
- When today's sunrise recording is missing, fall back to yesterday's
  clip before reaching for the library fallback.
2026-04-24 12:15:07 +00:00
Claude d776fad0cb 4-seasons: add progress reporting during validation and encoding
- Print "Validating N frames..." before the loop, including active
  filter thresholds when grey-checking is on
- Print "X / N frames checked..." every 500 frames so the user can
  see the loop is alive during the long ImageMagick pass
- Print "Validation done: N valid frames" after the loop
- Note "(may take several minutes)" on the Step 1 encode echo
- Show the speed factor and target together: "28.8x → 11.08s target"

https://claude.ai/code/session_01U29A8NpgJ41tboiggZNmk8
2026-04-23 14:21:50 +00:00
Claude 307224fc26 4-seasons: fix silent exit in grey-frame filter (read + set -e)
When SEASONS_GREY_STDDEV_MIN is enabled, ImageMagick's convert outputs
the stddev/mean values without a trailing newline.  read exits 1 on EOF-
without-newline even when it successfully populated the variables.  With
set -euo pipefail this kills the script silently on the very first image
that enters the grey-filter code path — producing the observed symptom:
script stops after "Images found:" with no error and no video.

Fix: append || true so read's EOF exit code is absorbed.  The variables
are still set correctly; only the exit code changes.

https://claude.ai/code/session_01U29A8NpgJ41tboiggZNmk8
2026-04-23 14:02:24 +00:00
Claude 4a14d539a4 4-seasons: fix silent exit on clean days (set -e + && gotcha)
When no corrupt or grey frames exist (bad=0, grey=0), the two
conditional-echo lines

  [ "$bad"  -gt 0 ] && echo "WARNING: ..."
  [ "$grey" -gt 0 ] && echo "INFO: ..."

exit with code 1 because [ 0 -gt 0 ] is false and && short-circuits.
With set -euo pipefail the script treats that 1 as an error and exits
immediately with no output — producing exactly the "ran without making
a video, no error, no notification" symptom on any normal day where all
frames are valid.

Fix: append || true to each line so the expression always exits 0.

https://claude.ai/code/session_01U29A8NpgJ41tboiggZNmk8
2026-04-23 13:52:29 +00:00
Claude 2ba34cd5fe 4-seasons: fix VFR pause/jump in daily MVT clips
Without explicit duration in the concat file, ffmpeg assigns timestamps
from EXIF metadata or defaults — producing a variable frame-rate raw
video with uneven frame spacing.  Applying setpts without fps= then
preserved that unevenness into the final clip, causing the observed
pause-then-jump-minutes/hours behaviour.

Fix 1: write `duration 0.04` (1/25 s) for every JPEG in the concat
list, making the raw video a true 25 fps CFR stream.  The duplicate
final-entry is appended as required by the ffmpeg concat demuxer so the
last content frame keeps its full display duration.

Fix 2: add `fps=25` to the setpts filter in step 2, resampling to
standard 25 fps CFR regardless of the speed factor, which guarantees
smooth, uniform playback in the final clip.

https://claude.ai/code/session_01U29A8NpgJ41tboiggZNmk8
2026-04-23 12:22:00 +00:00
Claude 8a7739502c fix: daily_sunrise_video.sh exits non-zero, blocking OnSuccess= upload
Conditional expressions like `[ "$count" -gt 0 ] && echo ...` return 1
when count is 0 (nothing to delete). Under set -euo pipefail with no
explicit exit 0, that false becomes the script's exit code. systemd sees
failure, OnSuccess= for sunrise2mm.py never fires, and the Mattermost
upload is silently skipped every day.

Fix: add || true to all end-of-script conditional-echo statements and to
the cam_audio cleanup line, then add an explicit exit 0 so the success
path always exits cleanly.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-23 12:00:57 +00:00
Claude 98dcf23687 4-seasons: replace size-rejection with 1MB fast-skip for grey filter
File size can't reliably reject bad frames (200KB can be good or bad).
Remove SEASONS_MIN_FRAME_BYTES.  Instead, the grey/green uniform-colour
filter (SEASONS_GREY_STDDEV_MIN) now skips the expensive ImageMagick
check for files above SEASONS_LARGE_FRAME_BYTES (default 1 MB) since
those are always good.  Only sub-1MB files get the content check, making
the filter practical on days with 40k+ images.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-23 02:34:26 +00:00
Claude a9faa63cd9 4-seasons: remove per-frame ffprobe validation — too slow at scale
43k images × ffprobe process launch = 30-90 min before encoding starts.
Every corrupt file seen in practice has been 0-byte (caught instantly by
[ ! -s ]).  Non-zero corrupt files are rare; if ffmpeg hits one the
existing drift warning flags the short output.  Removing ffprobe restores
the fast path: one stat() call per image.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-23 01:52:38 +00:00
Claude 3f5b89e5da README: document backfilling multiple dates with 4-seasons.sh loop
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 22:31:06 +00:00
Claude be784a9452 README: add git workflow section — install, pull, overwrite local changes
Covers: installing git, first clone, pulling updates, stash vs reset
--hard, checking diffs, switching branches, and a note that .env is
never touched by git pulls.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 20:55:20 +00:00
Claude d00d4bf15e 4-seasons: add optional date argument
Allows processing any past date instead of always yesterday:
  ./4-seasons.sh east 2026-04-19

Useful for backfilling days with existing images.
Systemd (no date arg) continues to default to yesterday.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 20:41:45 +00:00
Claude d0399fb72d 4-seasons: restore original concat approach — no duration per frame
duration=INTERVAL in the concat file made a 0.1fps raw video, which
x264 couldn't speed up 4000x cleanly and produced 20s of the last
frame instead.  The original script used plain 'file path' entries
with no duration, letting ffmpeg default to 25fps internally.  The
speed_factor calculation against raw_duration compensates correctly
either way, but only the standard-fps raw video survives the extreme
setpts transform.  Also removed the coverage_pct check which was
based on images*INTERVAL and became meaningless without duration.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 18:29:58 +00:00
Claude 32bd64459e 4-seasons: exit cleanly when all frames fail validation
Accessing ${images[-1]} on an empty array under set -u causes a bash
error.  Guard with an explicit check so a fully-corrupt image directory
exits with a clear message instead of a cryptic crash.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 16:58:16 +00:00
Claude 8b79261b81 4-seasons: remove fps=25 from speed-adjust — keep all source frames
fps=25 caused ffmpeg to discard 15 of every 16 source frames, making
the final clip jump by ~2.5 minutes per frame.  The original script
had no fps filter, so all source frames were preserved.  Without it,
the setpts speed-adjust keeps every frame; the effective framerate in
the output rises proportionally (e.g. ~400fps for a full day at 10s
intervals into an 11s clip), which is fine for H.264 and all
downstream montage steps.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 16:32:47 +00:00
Claude 9d34240ac0 sky-cam.conf: comment out grey filter — must be explicitly enabled
The SEASONS_GREY_STDDEV_MIN and SEASONS_GREY_DARK_FLOOR settings are
now commented out so the filter is fully inert by default and requires
a deliberate edit to activate.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 16:22:25 +00:00
Claude ec8eb7aebf 4-seasons: protect night frames from grey filter with brightness floor
A stddev-only filter would wrongly drop near-black night frames.
Now only skips a frame when BOTH stddev < GREY_MIN AND mean brightness
> GREY_DARK_FLOOR (default 30/255).  Night frames are dark so they
always pass; bad-signal grey frames are mid-bright so they are caught.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 16:17:22 +00:00
Claude 4aeee6b3d5 4-seasons: validate JPEGs with ffprobe, add optional grey-frame filter
The previous size check caught empty files but not corrupt JPEGs with
a partial header (common first frame after a camera reconnect).
Replace with ffprobe codec detection — if ffprobe can't identify a
video stream in the file it's skipped with a clear "corrupt" message.

Also adds SEASONS_GREY_STDDEV_MIN (default 0 = off): when enabled,
frames with near-zero pixel standard deviation (uniform grey = bad
RTSP signal) are silently dropped before encoding.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 16:07:29 +00:00
Claude 292824b48d 4-seasons: skip empty/unreadable frames, warn on low day coverage
Corrupt or 0-byte JPEGs (e.g. first frame after a camera reconnect)
caused ffmpeg concat to silently truncate the output, missing all
images after the bad file.  Now filters those out before building the
concat list and logs a warning + notification when raw video covers
less than 50% of the expected image count.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 15:51:59 +00:00
Claude 45af48e46d Fix Python config parser swallowing inline comments as part of values
read_config / _read_conf now strips trailing inline shell comments
(whitespace + # + anything) before processing the value.  Without this,
a line like:

  SUNRISE_CAM=east                   # which camera faces east

produced SUNRISE_CAM = 'east                   # which camera faces east',
causing sunrise2mm.py to build a path with the comment embedded in it.

The regex \s+#.*$ requires at least one whitespace before # so passwords
or URLs containing # (e.g. %23 URL-encoded) are unaffected.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 15:01:53 +00:00
Claude e56663209e Prepend <cam> to all output filenames consistently
Audio:
  AUDIO_DIR/<cam>/YYYY-MM-DD/<cam>-HH-MM-SS.m4a

Movies — cam name now always leads the filename:
  daily_sunrise_video.sh:
    east-2026-04-22-daily-sunrise.mp4
    east-2026-04-22-daily-sunrise-sped.mp4  (intermediate)
    east-2026-04-22-daily-sunrise-test.mp4  (demo)
  4-seasons.sh:
    east-2026-04-21_Mvt2-Day2of31-final.mp4  (was: 2026-04-21_east_Mvt2-...)
  montage-mvt.sh:
    east-2026-03-20_Spring_Mvt1-Sped.mp4
    east-2026-03-20_Spring_Mvt1-Montage.mp4
  year-end-join.sh:
    east-2026.mp4  (already had cam at front)

sunrise2mm.py updated to look for the new east-YYYY-MM-DD-daily-sunrise.mp4
filename. Retention find patterns (wildcards) already match both formats.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 14:45:36 +00:00
Claude 11d4630197 Restructure audio into AUDIO_DIR with per-camera retention
New AUDIO_DIR variable (like BASE_DIR/MOVIES_DIR) is the root for all
audio recordings.  Set in .env to put audio on a separate drive.

Directory layout:
  AUDIO_DIR/<cam>/YYYY-MM-DD/HH-MM-SS.m4a        — ambient recordings
  AUDIO_DIR/sunrise/<cam>/YYYY-MM-DD/sunrise-audio.m4a — sunrise clips

sky-cam.conf:
- Add AUDIO_DIR="${AUDIO_DIR:-$BASE_DIR/audio}" in storage section
- Remove AMBIENT_DIR (replaced by AUDIO_DIR)
- Add SUNRISE_AUDIO_RETENTION_DAYS=7 (sunrise clips kept separately from ambient)
- Add per-camera ambient retention examples:
    AMBIENT_RETENTION_DAYS_south=60  (keep bird recordings longer)

ambient-record.sh:
- Use AUDIO_DIR instead of AMBIENT_DIR
- Per-camera retention: AMBIENT_RETENTION_DAYS_<cam> overrides global default

sunrise-audio-capture.sh:
- Save clips to AUDIO_DIR/sunrise/<cam>/<date>/sunrise-audio.m4a
- Rolling retention of sunrise clips (SUNRISE_AUDIO_RETENTION_DAYS)

daily_sunrise_video.sh:
- Look for cam_audio in new AUDIO_DIR/sunrise path first, fall back to
  old BASE_DIR path so existing recordings keep working

install.sh:
- Pre-create AUDIO_DIR/<cam> and AUDIO_DIR/sunrise/<SUNRISE_CAM> dirs
- Add AUDIO_DIR to .env.example storage section

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 14:43:05 +00:00
Claude a63a42ee46 Add Demoio directory for test videos with 8-day retention; capture gap warning
daily_sunrise_video.sh:
- Test output now saves to DEMO_DIR/<cam>/ (default: MOVIES_DIR/demoio/<cam>/)
  instead of the production sunrise-only directory
- After each test run, deletes test files older than DEMO_RETENTION_DAYS (8)
- Production mode: warns if the last selected frame is >3 intervals before
  the window end, which indicates the capture service had a gap near sunrise:
    WARNING: last frame is 20min 0s before window end — capture gap near sunrise
             Check: systemctl --user status sky-cam-capture-east.service

sky-cam.conf: add DEMO_DIR and DEMO_RETENTION_DAYS settings

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 14:23:30 +00:00
Claude 9fefe698cb Fix sunrise window logging and Mattermost cleanup scope
daily_sunrise_video.sh:
- Fix "Sunrise (UTC)" label — sunrise.py has always returned local time;
  now labelled correctly as "Sunrise (local)"
- After image selection, log first and last frame timestamps alongside the
  overlay time so the window can be verified at a glance:
    Images: 481  (05:22:10 → 06:43:00  overlay: 06:32)

sunrise2mm.py:
- Cleanup now only deletes posts whose message matches "Sunrise YYYY-MM-DD"
  (the format this script posts), so other posts with attachments in the
  channel are never touched

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 14:16:15 +00:00
Claude 1cf51eaa26 Auto-delete old unpinned sunrise posts from Mattermost after each upload
sunrise2mm.py: after a successful upload, scan the channel and delete any
post older than MM_SUNRISE_RETENTION_DAYS that is not pinned and has a file
attachment. Pinned posts are always preserved regardless of age.

sky-cam.conf: add MM_SUNRISE_RETENTION_DAYS=8 (independent of the local
disk SUNRISE_RETENTION_DAYS so the two retentions can differ).

Also modernises sunrise2mm.py: uses the same ${VAR:-default} aware
read_config as sunrise.py, consistent error handling, cleaner structure.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 14:09:27 +00:00
Claude 3c50e5dad2 Clarify .env vs sky-cam.conf split for toggles and private values
Rule is now consistent throughout:
- *_ENABLED flags are plain true/false in sky-cam.conf — flip them there
- Private values (URLs, credentials, location) go in .env only

sky-cam.conf:
- NTFY_ENABLED, EMAIL_ENABLED, MM_NOTIFY_ENABLED are now plain false (not
  using the ${VAR:-} pattern, which implied they could go in .env)
- NTFY_URL, EMAIL_TO, EMAIL_FROM, MM_NOTIFY_CHANNEL_ID use ${VAR:-} pattern
  so they are set in .env
- LATITUDE/LONGITUDE comment clarified with example .env lines

install.sh .env.example: updated notification comment to match

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 13:56:58 +00:00
Claude 2a28c8e5ea Expand .env.example to cover all machine-specific config
Adds TIMEZONE, BASE_DIR, MOVIES_DIR (commented out) so .env.example
is a complete reference — location, storage paths, RTSP URLs, Mattermost
credentials, and notification endpoints all in one place.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 13:43:02 +00:00
Claude 74a74570fc Move location/music/ntfy config to .env; add paths to notifications
sky-cam.conf:
- MUSIC_DIR now uses override pattern (MUSIC_DIR="${MUSIC_DIR:-$SCRIPT_DIR/music}")
  so the real path can be set in .env without hardcoding it
- LATITUDE/LONGITUDE use override pattern; set real coords in .env to keep
  location private and out of git
- NTFY_URL now uses override pattern with empty default; set in .env
- NTFY_ENABLED moved out of comments into active config with false default

sunrise.py:
- Reads .env after sky-cam.conf so .env values override (same source order
  as sky-cam.conf itself)
- Handles ${VAR:-default} bash syntax when parsing sky-cam.conf values

All completion notifications now include the full output file path so you
can tell at a glance where the file landed:
- daily_sunrise_video.sh: "filename — Xs, sunrise at HH:MM | /full/path"
- 4-seasons.sh: "filename — Xs | /full/path"
- montage-mvt.sh: "filename | checks | /full/path | verify: ..."
- year-end-join.sh: "filename — Xmin | /full/path" (also adds [cam] to title)

install.sh .env.example now includes LATITUDE, LONGITUDE, MUSIC_DIR, NTFY_URL

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 13:30:02 +00:00
Claude ae40b898f6 Fix executable bits and add camera name to 4-seasons notifications
- chmod +x all *.sh and *.py in install.sh so permissions survive git checkouts
- Fix daily_sunrise_video.sh and Python scripts missing executable bit
- Add [CAM_NAME] prefix to all 4-seasons.sh notify.sh calls so multi-camera
  setups show which camera each daily clip came from
- Include camera name in output filename: YYYY-MM-DD_<cam>_MvtN-DayXofY-final.mp4

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 12:56:37 +00:00
Claude dbdd59677f Per-camera capture interval; ambient recorder; fix 4-seasons one-frame bug
Per-camera capture interval:
  CAPTURE_INTERVAL_<cam> in sky-cam.conf overrides the global value for
  a specific camera.  capture.sh and 4-seasons.sh both respect it.
  Example: south at 30s saves storage; north at 5s gives smoother motion.

4-seasons.sh one-frame bug fix:
  Same root cause as the sunrise scripts — concat list had no 'duration'
  entries, collapsing all JPEG frames to timestamp 0.  Fixed by writing
  'duration INTERVAL' per frame.  Added fps=25 to the speed-adjust step
  so the VFR source resamples to a standard frame rate.

ambient-record.sh (new):
  Continuous AAC recorder for natural sounds (birds, rain, wind).
  Saves AMBIENT_CHUNK_SECS chunks to AMBIENT_DIR/<cam>/YYYY-MM-DD/HH-MM-SS.m4a.
  Reconnects automatically on stream failure.  Rolling retention via
  AMBIENT_RETENTION_DAYS.  Enabled by setting AMBIENT_ENABLED=true and
  listing cameras in AMBIENT_CAMS in sky-cam.conf, then re-running install.sh.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 21:08:10 +00:00
Claude cdaca67d31 notify.sh: source .env so NTFY_URL and other creds are available
Notification config (NTFY_URL, MM_NOTIFY_CHANNEL_ID, etc.) lives in
.env but notify.sh was only sourcing sky-cam.conf, so notifications
were silently skipped even when configured.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 18:42:08 +00:00
Claude c5474714be install.sh: restart capture services instead of enable --now
enable --now only starts a service that is not yet running — it leaves
an already-running service untouched, so changes to .env credentials
are never picked up without a manual restart.

Switching to enable + restart means every install.sh run brings capture
services in sync with the current sky-cam.conf and .env: new cameras
start, reconfigured cameras restart, and nothing needs manual follow-up.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 18:28:44 +00:00
Claude 9707e5ca37 capture.sh: source .env so RTSP credentials are available
CAM_RTSP_<cam> is set in .env, not sky-cam.conf, but capture.sh was
only sourcing sky-cam.conf — causing the service to fail with "not set"
even after credentials were added to .env.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 18:24:29 +00:00
Claude 1a1ff1a041 Fix one-frame bug; add --test mode to daily_sunrise_video.sh
Root cause: the concat list had no 'duration' entries, so all JPEG
frames collapsed to timestamp 0 and only one frame survived encoding.
Fix: add 'duration CAPTURE_INTERVAL' per entry in both scripts.

Also add fps=25 to the speed-adjust step so the VFR source is resampled
to a standard frame rate — without this, players see ~6fps and may drop
frames to reach the declared rate.

daily_sunrise_video.sh --test [MINUTES]:
  Skips sunrise.py lookup and capture-window wait. Uses the last MINUTES
  minutes of captured frames (default 2). Overlay shows the mid-point
  frame's timestamp. Audio grabbed live from RTSP immediately.
  Output: <date>-daily-sunrise-test.mp4 — no notifications or upload.

  Usage: ./daily_sunrise_video.sh east --test 2

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 17:52:29 +00:00
Claude 4c02de5fd4 Overlay: yellow text, lower-right position; test-sunrise uses captured frames
- fontcolor: white → yellow (both scripts)
- y position: (h-th)/2 → h-th-18 (vertically centered → lower-right corner)
- test-sunrise.sh: reverted to reading last 60 frames from capture directory
  (~10 minutes at 10s interval) instead of live RTSP capture

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 17:32:31 +00:00
Claude f3839ce1cf Fix overlay vertical text; test-sunrise captures fresh RTSP frames
Overlay fix (both scripts):
  Switch from text='...\n...' to drawtext's textfile= option. Writing
  each character on its own line eliminates the \n escape ambiguity in
  ffmpeg's filter-string single-quote parser, which was causing 'n' to
  appear literally instead of as a line break.

test-sunrise.sh redesign:
  Now captures NUM_FRAMES fresh RTSP frames (120s at default interval)
  at run time instead of reading pre-existing frames from the capture
  directory. The RTSP URL must be set in .env — the script fails early
  with a clear message if it is not.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 17:14:17 +00:00
Claude eba8ddd550 Fix sunrise overlay vertical text and test-sunrise.sh pipeline bugs
- Overlay text was showing characters run together (e.g. '1n2n') because
  inside ffmpeg single-quoted filter text, \n is consumed as just 'n'.
  Fix: use \\\\n in bash double-quotes which stores \\n in the variable,
  which ffmpeg then parses as \n, which drawtext renders as a newline.
  Applied to both test-sunrise.sh (MID_VERT) and daily_sunrise_video.sh
  (SR_VERT, replacing the awk one-liner with the same bash approach).

- test-sunrise.sh concat list was missing per-frame duration entries,
  causing 12 frames to encode as 0.48s (25fps default) and then slow
  down instead of compress.  Fixed by writing 'duration INTERVAL' per
  frame so 12 frames × 10s = 120s raw → 12× compression to 10s.

- Removed 2>/dev/null from audio ffmpeg call in test-sunrise.sh so
  capture failures are visible for diagnosis.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 16:35:25 +00:00
Claude 84fa60b857 Add test-sunrise.sh pipeline smoke test
Runs the same 4-step pipeline as daily_sunrise_video.sh but uses the
most recent ~2 minutes of captured frames instead of the sunrise window,
grabs live RTSP audio for the audio mix step, and accepts an arbitrary
output path — so it can be run at any time of day to verify the full
pipeline (speed-adjust, audio mix, vertical time overlay) without
waiting for tomorrow's sunrise.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 16:20:15 +00:00
Claude 5c88b12b9f Pre-create camera data directories in install.sh
capture.sh creates the per-day subdirectory at runtime, but BASE_DIR/<cam>
and MOVIES_DIR/<cam> need to exist first. Create them during install so the
capture service works immediately on first start without needing a separate
manual mkdir step.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 16:00:48 +00:00
Claude 21463c22fc Replace url-encode-password.sh with Python script
The shell version had to pass the password through a shell variable into
a Python subprocess, which is fragile for special characters.

The Python version uses getpass.getpass() which reads directly from the
terminal at the Python level — no shell variable, no quoting issues, no
risk of special characters being mishandled.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 15:34:02 +00:00
Claude 98cef1bcd8 Add url-encode-password.sh helper
Prompts for a password without echoing, URL-encodes it via Python's
urllib.parse.quote, and prints the result with a ready-to-paste .env
snippet.  Password is passed via environment variable to avoid any
shell quoting or injection issues — never written to disk or network.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 15:26:42 +00:00
Claude 3c2e413ea2 Expand URL-encoding reference in .env.example
Full number-row special character table with percent codes, safe
characters called out, and a note on : and / which break URL parsing.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 15:25:12 +00:00
Claude 9d4d50b91c Fix install.sh for non-login shell environments
- Set XDG_RUNTIME_DIR before systemctl --user calls so daemon-reload
  and enable --now work when run outside a login session (e.g. via SSH
  or sudo)
- Run loginctl enable-linger so user services start at boot without a
  login session
- Update .env.example to use single quotes around RTSP URLs and
  document URL-encoding for special characters in passwords

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 15:21:12 +00:00
Claude 37ad990af9 Default ENCODE_PRESET/CRF_SEASONS_FINAL in make-finals.sh
Older sky-cam.conf versions may not define these. Fall back to the
canonical defaults so make-finals.sh works without requiring the user
to update their local conf.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 11:27:37 +00:00
Claude c2b54077a9 Add --cam/--season/--mvt filters to make-finals.sh
Allows processing a single movement without waiting for the full backup
scan, e.g.:
  ./make-finals.sh ~/drives/data2-main --cam north --season Autumn --mvt 1

Filters are applied as soon as the relevant variable is known (cam before
calling season_info.py, season/mvt after) so skipped files cost almost
nothing.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 11:11:15 +00:00
Claude 62f1330d9c Fix corrupt-file detection in make-finals.sh
The previous check used || true which masked ffprobe's non-zero exit
code.  For files with a missing/partial moov atom ffprobe can print a
duration estimate then exit non-zero — the || true let that through.

Now use || raw_dur="" to honour the exit code, and add a second probe
for an actual video stream codec so files that report a duration but
have no decodable stream are also caught.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-21 10:51:29 +00:00
Claude 0ccfb2dae0 Add MONTAGE_MUSIC_LOOPS per-movement music loop multiplier
Short adagio movements (Summer Mvt 2 at 107s, Winter Mvt 2 at 132s, etc.)
compress each day to only 3-5 seconds of screen time at 1×.  Looping the
music N times multiplies the per-day target duration proportionally so the
footage is less aggressively sped up and more watchable.

- sky-cam.conf: add MONTAGE_MUSIC_LOOPS and per-movement overrides
  (Summer Mvt2=3×, Winter Mvt2=3×, Autumn Mvt2=2×, Summer Mvt3=2×, Spring Mvt2=2×)
- 4-seasons.sh: multiply target_per_clip by loops
- montage-mvt.sh: compute effective_duration, use -stream_loop for audio,
  fix fade_out_start, -t, and post-build duration check
- make-finals.sh: multiply target by loops

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 20:11:10 +00:00
Claude 387b84f367 make-finals.sh: skip corrupt temp files (moov atom not found)
Check ffprobe output before encoding — empty/N/A duration means the
file is corrupt or truncated; skip with a clear message rather than
passing a bad input to ffmpeg.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 20:02:04 +00:00
Claude 26414f9883 Add make-finals.sh — one-off recovery script for backup temp files
Scans all *-temp.mp4 files under a backup root regardless of directory
structure, infers camera name from path, uses season_info.py for correct
movement sizing, writes finals to MOVIES_DIR. Handles messy nested paths
(south/south/, movies/south/, etc.) and deduplicates via EXISTS check.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 19:57:13 +00:00
Claude 507ecf32c8 Fix reorg-backup.sh camera scoping — prevent 2026/ dir misidentified as cam
Restructure find loop to iterate known CAMERAS+sunrise in the main shell
so cam_name is visible in the while body. Previously the for loop ran in
a process substitution subshell, making cam_name unavailable and causing
top-level year dirs (e.g. 2026/) to be treated as camera names.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 18:49:34 +00:00
Claude da35dc862c Add reorg-backup.sh — reorganize backup files into astro-YEAR folders
Moves Season/MvtN mp4 files from flat camera dirs into
astro-YEAR/<cam>/Season/MvtN/ using season_info.py for correct
year assignment. Handles cross-year mixing in old backup structure.
Dry-run support; never deletes files.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 18:39:15 +00:00
Claude d4e39a5554 Add resize-temps.sh — re-size backup temp files to correct movement targets
Re-processes *-temp.mp4 files from a backup location using season_info.py
to compute the correct target duration per clip (music_duration / DAYS_IN_MVT),
producing properly-sized *-final.mp4 files without touching the backup source.
Skips finals that already exist. Fixes drift caused by old pipeline sizing clips
to the wrong movement structure.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 18:17:20 +00:00
Claude a395f9baba Encoding: H.265 final montages, slow preset, sunrise retention
- sky-cam.conf: add ENCODE_PRESET=slow (applied to all encodes);
  split CRF_MONTAGE (intermediates, H.264) from CRF_MONTAGE_FINAL=22
  (archive montage, H.265); add SUNRISE_RETENTION_DAYS=10; improve
  CAPTURE_INTERVAL comment with storage/density table
- montage-mvt.sh: steps 1+2 use preset; step 3 final switches to
  libx265 + CRF_MONTAGE_FINAL + -tag:v hvc1 for broad compatibility
- 4-seasons.sh: both encode steps use ENCODE_PRESET
- daily_sunrise_video.sh: all encode steps use ENCODE_PRESET; rolling
  retention deletes sunrise videos older than SUNRISE_RETENTION_DAYS

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 17:27:57 +00:00
Claude ab06c1cc2b Fix MUSIC_DIR path quoting — space in '4 Seasons' broke conf sourcing
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 16:40:55 +00:00
Claude c4fb086f1d Fix bugs found in post-refactor audit
- verify-mvt.sh: remove dead first _info= line (used MVT_START before
  defined); fix JPEG size loop to accumulate bytes correctly and display
  human-readable total; show size in delete confirmation
- montage-mvt.sh: grep -c uses || echo 0 instead of || true to be
  unambiguous about the no-match value under set -e
- capture.sh, capture-watchdog.sh: require camera name arg, remove
  silent SUNRISE_CAM fallback
- migrate-seasons.sh: require --cam arg, error if missing
- README.md, sky-cam.conf: remove stale fullday-video.sh references;
  README pipeline diagram updated to show verify-mvt.sh

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 16:34:05 +00:00
Claude 8c752fc165 Require camera name explicitly across all seasons scripts
No script defaults to SUNRISE_CAM (east) for the seasons pipeline.
Every direction is treated equally — camera name is a required arg,
not an optional override.

- 4-seasons.sh: $1 required, exits with usage if missing
- montage-mvt.sh: arg order changed to <cam> [date]; $1 required
- year-end-join.sh: $2 (cam) required
- verify-mvt.sh: $4 (cam) required
- migrate-seasons.sh: example commands updated to new arg order
- README.md: montage-mvt.sh examples updated

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 16:28:15 +00:00
Claude 91006bf5f6 sky-cam.conf: clean up schedule comments, west camera placeholder
Remove stale SCHEDULE_FULLDAY comment block; add commented west camera
slot with instructions so enabling it is a one-line uncomment.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 15:59:12 +00:00
Claude b4019ade9d Add north/south cameras, remove fullday, add verify-mvt.sh
- sky-cam.conf: CAMERAS now includes east, north, south with staggered
  SCHEDULE_SEASONS times (01:00, 01:30, 02:00); fullday schedules and
  tuning removed
- install.sh: fullday service/timer generation removed entirely
- fullday-video.sh + systemd units: deleted
- montage-mvt.sh: post-build technical checks (duration drift, video/audio
  stream presence) added; notification now includes check results and the
  exact verify-mvt.sh command to run
- verify-mvt.sh: new interactive CLI for montage review — shows checks,
  plays video, deletes source JPEG folders on approval, or re-runs montage

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 15:56:12 +00:00
Claude 04809cfe90 migrate-seasons.sh: add --cam flag, include Summer in search
--cam NAME overrides SUNRISE_CAM so the script can be used for any
camera (e.g. north).  Summer is now included in the find targets so
any ASTRO_YEAR=2025 Summer clips (Summer 2026) are also migrated.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 15:05:15 +00:00
Claude 8ba0619ead Fix music file matching: Mvt3 was resolving to Mvt1 for every season
The old pattern *Mvt*3* matched .mp3 in every MP3 filename, so sort|head-1
always picked track 01 (Mvt1). Fix by finding all files for the season
then filtering with grep -iE "Mvt[^0-9]*N[^0-9]", which requires the
movement number to be surrounded by non-digit characters (space, dot,
underscore) and cannot match digits embedded in .mp3 or track prefixes.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 14:30:32 +00:00
Claude 331bce38c4 Simplify migrate-seasons.sh: migrate all clips, drop quarantine logic
All *-final.mp4 clips are valid footage regardless of what speed factor
the old script used — montage-mvt.sh re-adjusts the full concatenated
video to match music duration anyway, so per-clip speed is irrelevant.

Move every ASTRO_YEAR=2025 clip to the correct new movement directory
based on its date. Spring Mvt1 now gets all 30 clips (Mar 21–Apr 19).

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 14:16:13 +00:00
Claude 7affbc5c54 Revise migrate-seasons.sh: ASTRO_YEAR=2025 only, move not symlink, quarantine bad clips
- Filter to ASTRO_YEAR=2025 (Winter 2025-26 onward); skip Autumn 2025 and earlier
- Move files instead of creating symlinks
- Quarantine clips matching Day<N>of92 (Spring clips from broken script with
  wrong 92-day movement total) to quarantine-old-scripts/ for review + deletion
- Preserve clips with Dayof92 (no day number, old legacy format) — these are
  migrated normally since montage-mvt.sh re-adjusts speed regardless
- Summary shows delete commands for temp files and quarantine folder

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 14:13:12 +00:00
Claude 32b82c7b7d Add one-shot migration script for old-format seasons clips
migrate-seasons.sh uses season_info.py to re-classify every old
*-final.mp4 clip by its YYYY-MM-DD filename prefix, placing a symlink
in the correct new-system directory regardless of how the old system
labelled movements. Handles the boundary mismatches between old and
new movement splits automatically.

Coverage after migration (based on available clips):
  Spring 2026 Mvt1  30/31 days  (missing Day 1 only — excellent)
  Winter Mvt1       ~18/29 days
  Winter Mvt2       ~24/29 days
  Winter Mvt3       ~20/31 days
  Autumn Mvt1       ~24/30 days
  Autumn Mvt3       ~18/30 days
  Autumn Mvt2       absent — year-end join will not fire for 2024 cycle

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 14:01:01 +00:00
Claude 3265ed80fd Add per-camera capture watchdog with stall and recovery notifications
capture-watchdog.sh: long-running script that checks the newest JPEG mtime
in each camera's output directory every CAPTURE_STALE_SECS/3 seconds (min 5s).
Sends a stall notification via notify.sh if no new frame has arrived within
CAPTURE_STALE_SECS. Sends a recovery notification once new frames resume.
Only alerts if the camera was previously working (avoids false positives on
first start or overnight before the first frame of the day).

sky-cam.conf: CAPTURE_STALE_SECS=30 added next to CAPTURE_INTERVAL with a
note that it should be at least 2x the interval.

install.sh: generates sky-cam-watchdog-<cam>.service for every camera that
has a RTSP URL configured. The watchdog service starts after and alongside
the capture service, restarts on failure, and is enabled/started with the
same loop as the capture service.

README.md: note about watchdog and journalctl command for its logs.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 01:13:49 +00:00
Claude 8b9ad74c58 Fix six bugs found in final audit
montage-mvt.sh, year-end-join.sh: CAM_NAME fallback referenced undefined
\$CAM_NAME — crashes under set -euo pipefail on manual runs without args.
Fixed to fall back to \$SUNRISE_CAM (same fix applied earlier to other scripts).

notify.sh: Mattermost notification guard only checked MM_NOTIFY_CHANNEL_ID,
not mattermost_url or access_token. If those are unset, curl would send a
malformed request silently. Added guards for all three required values.

install.sh: seasons/fullday service units had literal \n in After=/Wants=
lines because bash does not interpret \n in heredoc variable expansions.
Changed to \$'...' syntax so actual newlines are written, making valid
systemd unit files. Also: audio capture timer now uses \$SCHEDULE_SUNRISE
instead of hardcoded 03:00, keeping it in sync if the user changes the
schedule.

sunrise-audio-capture.sh: record_start_sec could theoretically go negative
(sunrise very early + large SUNRISE_TARGET_SECS). Added floor-at-zero guard.

daily_sunrise_video.sh: added comment explaining why audio_offset is always 0.

README.md: fix CAM_RTSP_sunrise example to CAM_RTSP_east.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 01:01:25 +00:00
Claude 64cec6b769 Rename default camera from 'sunrise' to 'east' for compass consistency
Cameras are now named by direction (east, north, south, west) throughout
config defaults, examples, and documentation. The config key SUNRISE_CAM
is unchanged — it still means 'which camera faces east and gets the sunrise
job'. Only the camera instance name value changes from 'sunrise' to 'east'.

sky-cam.conf: CAMERAS=(east), SUNRISE_CAM=east, SCHEDULE_*_east,
example comments updated to show all four compass points.
README.md: all command examples updated (4-seasons.sh east, journalctl
sky-cam-capture-east, etc.) — phenomenon references ('sunrise window',
'sunrise time') left unchanged.
bootstrap.sh: example updated to show compass directions.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 00:53:58 +00:00
Claude 9ea03d2249 Replace \$EDITOR with nano in README and bootstrap instructions
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 00:46:39 +00:00
Claude 4d5da05bc9 README: full rewrite — dependencies first, accurate quick start, current behavior
- Step 1 is now dependency installation (apt + pip3) before anything else
- SCRIPT_DIR removed from config table (auto-detected)
- RTSP/Mattermost credentials moved to .env section (step 4)
- install.sh now shown as generating .env.example before credentials are filled in
- Schedule settings explained: SEASONS/FULLDAY process yesterday; SUNRISE waits internally
- How it works: audio capture described as SUNRISE_TARGET_SECS centred on sunrise
- daily_sunrise_video.sh pipeline updated: steps 3a/3b shown separately
- Resilience section replaced with four-tier audio/overlay matrix table
- Camera audio section updated: exact duration, centred split, odd-second rule
- Manual operations: examples use explicit camera name argument

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 00:36:58 +00:00
Claude 9039803a51 Fix undefined CAM_NAME crash; log when window already closed on re-run
4-seasons.sh, fullday-video.sh: CAM_NAME fallback referenced undefined
\$CAM_NAME — under set -euo pipefail this crashes if called manually without
an argument. Changed to fall back to \$SUNRISE_CAM (matches capture.sh).

daily_sunrise_video.sh: add log message when the capture window has already
closed (manual re-run after the fact). Behaviour is unchanged — processing
proceeds immediately — but the operator now gets a clear confirmation rather
than silence.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 00:29:47 +00:00
Claude 4814c9e158 Audio capture records exactly SUNRISE_TARGET_SECS centred on sunrise
Previously sunrise-audio-capture.sh recorded the entire capture window
(70+ minutes) and daily_sunrise_video.sh sought to the right position with
a complex offset calculation.

Now: record floor(TARGET/2) seconds before sunrise and ceil(TARGET/2) after —
odd second goes to post-sunrise.  The file is exactly SUNRISE_TARGET_SECS long
and already centred, so no offset is needed when mixing.

AUDIO_PRE_BUFFER_MIN removed — it was part of the old whole-window scheme
and is no longer meaningful.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 00:22:35 +00:00
Claude be714affc0 Auto-detect SCRIPT_DIR/BASE_DIR; sunrise waits for capture window; optional overlay
sky-cam.conf:
- SCRIPT_DIR auto-detects from its own location via BASH_SOURCE — no manual
  path entry needed after bootstrap; override still works via environment.
- BASE_DIR defaults to \$SCRIPT_DIR/data; MOVIES_DIR defaults to \$BASE_DIR/movies.
  Override either to point at a drive/mount as before.
- SCHEDULE_SUNRISE changed to 03:00 — the script now waits internally until
  the capture window closes before touching images, so the schedule just needs
  to be early enough, not timed exactly to sunrise.
- Schedule section rewritten to explain what each job does and what day's data
  it processes (SEASONS/FULLDAY always process yesterday).
- SUNRISE_PRE_MIN/POST_MIN comments explain the window and its relationship to
  SUNRISE_TARGET_SECS.
- SUNRISE_OVERLAY_ENABLED=true added; set false to skip the timestamp entirely.

daily_sunrise_video.sh:
- After calculating the capture window, sleep until end_sec+30s if we fired
  before the window finished — guarantees all images are present.
- DT (drawtext filter) is only built when SUNRISE_OVERLAY_ENABLED=true.
- Step 3b skips ffmpeg entirely when overlay is disabled, moving work_video
  directly to final_video (faster, no re-encode).

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-20 00:18:43 +00:00
Claude a1cf1304e4 Fix first-run blockers: MOVIES_DIR path, CAM_NAME, .env for Python, eval safety
daily_sunrise_video.sh: use \$MOVIES_DIR instead of \$BASE_DIR/movies so the
override in sky-cam.conf is respected when videos live on a separate drive.

capture.sh: default camera name falls back to \$SUNRISE_CAM (not the
undefined \$CAM_NAME) when no argument is passed.

sunrise2mm.py: also loads .env after sky-cam.conf so Mattermost credentials
moved to .env are actually visible to the upload script.

sunrise.py: raise a clear error message when LATITUDE/LONGITUDE/TIMEZONE
are missing from sky-cam.conf instead of an opaque KeyError.

4-seasons.sh, montage-mvt.sh: capture season_info.py output before eval so
a Python failure exits cleanly with a diagnostic message rather than
silently continuing with undefined variables.

bootstrap.sh: add system package install step (ffmpeg bc fonts-dejavu) and
show the .env setup step after install.sh generates .env.example.

README.md: correct Python package names and add fonts-dejavu dependency.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 23:37:10 +00:00
Claude a1b9ffa8ee Add .env credentials file support; gitignore .env and sunrise-sounds/
sky-cam.conf now sources .env from the same directory at the bottom of the
file, so RTSP URLs, Mattermost tokens, and notification credentials can live
outside version control.  Plaintext credential placeholders removed from conf.

install.sh generates .env.example on every run with the correct CAM_RTSP_*
variable names derived from the CAMERAS list, so users always know exactly
what to put in .env for their specific camera setup.

.gitignore: add .env and sunrise-sounds/ (downloaded audio library).

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 23:08:01 +00:00
Claude ba1eb70436 bootstrap.sh: fix post-install instructions (remove CAM_NAME, add pip step)
CAM_NAME is no longer a config key; replace with CAMERAS + SUNRISE_CAM.
Add pip3 install step for suntime/pytz/requests as step 1.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 22:45:26 +00:00
Claude 66fe1f46ca Fix CAM_NAME bug, set -x noise, wrong Python package in README
daily_sunrise_video.sh: derive CAM_NAME from $1 (defaulting to SUNRISE_CAM)
instead of an undefined variable; this was causing empty image/output paths.

install.sh: pass $SUNRISE_CAM as argument to daily_sunrise_video.sh so it
matches the pattern used by every other per-camera script.

sunrise2mm.py: use SUNRISE_CAM config key (not the undefined CAM_NAME) to
locate the output directory; fixes silent path mismatch on non-default names.

4-seasons.sh: remove stray `set -x` that was flooding systemd logs with
shell trace output.

README.md: correct Python dependencies from `ephem` to `suntime pytz` to
match what sunrise.py actually imports.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 21:56:33 +00:00
Claude 16af99f0a3 Split step 3 into independent audio (3a) and overlay (3b) stages
Each stage can now fail independently, giving four upload paths:
audio+overlay, audio-only, overlay-only, or speed-only video.
Step 3a copies the video stream (no re-encode) when mixing audio,
so step 3b failure still leaves a clean audio-mixed file to promote.
Overlay failure notification now reports which quality was uploaded.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 21:34:04 +00:00
Claude 15b7970dfa README: document audio fallback library and download-sunrise-sounds.py usage
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 21:22:23 +00:00
Claude baf886fd23 Audio resilience: three-tier fallback for sunrise audio; add freesound download script
daily_sunrise_video.sh: priority chain is camera mic → library random MP3 →
overlay-only → sped video promotion.  If audio mixing fails a warning
notification fires and the script retries with overlay-only so a video is
always produced and uploaded.

download-sunrise-sounds.py: downloads CC-licensed ambient sounds from
freesound.org into 11 weather/season category folders (~275 files total at
25 per category), writing a manifest.json with attribution data.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 21:22:01 +00:00
Claude 9fe0051f70 Add pure-ffmpeg RTSP capture and camera audio for sunrise videos
Removes dependency on MotionEye or any NVR software.  Everything is now
CLI/ffmpeg configured entirely from sky-cam.conf.

capture.sh
  Long-running systemd service (one per camera) that pulls frames from the
  camera's RTSP stream at CAPTURE_INTERVAL seconds, writing HH-MM-SS.jpg
  into BASE_DIR/<cam>/YYYY-MM-DD/.  Restarts at midnight for the new date
  directory; auto-reconnects on camera disconnect.

sunrise-audio-capture.sh
  One-shot service triggered at 03:00.  Waits until (sunrise minus
  SUNRISE_PRE_MIN minus AUDIO_PRE_BUFFER_MIN), then records the RTSP audio
  stream for the full sunrise window.  Output deleted after mixing.

daily_sunrise_video.sh
  Step 3 now mixes in sunrise-audio.m4a when AUDIO_ENABLED=true and the
  file exists.  Audio is centred on actual sunrise time at natural speed
  while the video plays as the sped-up timelapse.  Uses filter_complex
  when audio is present (can't combine -vf with -filter_complex).

install.sh
  Generates sky-cam-capture-<cam>.service for each camera with CAM_RTSP_<cam>
  set, and sky-cam-audio-capture.{service,timer} when AUDIO_ENABLED=true.

sky-cam.conf
  New settings: CAM_RTSP_<cam>, CAPTURE_INTERVAL, AUDIO_ENABLED,
  AUDIO_PRE_BUFFER_MIN, CAPTURE_AUDIO_BITRATE.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 20:59:40 +00:00
Claude 6629f91219 Add README with quick-start, architecture overview, and operations guide
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 19:35:07 +00:00
Claude b911b228bb Degrade gracefully on overlay/audio failure; notify on upload success
Sunrise:
- Overlay failure no longer exits 1; the speed-only video is renamed to the
  expected final path so OnSuccess still fires and the upload still happens
- sunrise2mm.py now notifies on every upload outcome (success, post failure,
  file-not-found) via notify.sh so the user always knows whether the video
  reached Mattermost

Montage:
- Music+overlay failure no longer exits 1; the sped video is promoted to the
  *-Montage.mp4 path so year-end-join can still include this movement (as a
  silent, no-overlay clip) and the user is notified of the degraded output
- Year-end join trigger is now outside the success/failure branch so it fires
  in both cases

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 18:42:46 +00:00
Claude 9c929f28d8 Add per-step resilience and notifications across all video pipeline scripts
Each pipeline now saves intermediate files permanently before the step most
likely to fail, so a partial failure leaves a recoverable artifact:
- daily_sunrise_video.sh: speed-adjusted video (*-sped.mp4) survives if the
  drawtext overlay step fails; deleted automatically on success
- montage-mvt.sh: speed-adjusted video (*-Sped.mp4) survives if the
  music-mux + attribution overlay step fails; deleted on success
- 4-seasons.sh / montage-mvt.sh / year-end-join.sh: explicit ffmpeg error
  handling with targeted notify.sh calls naming the failed step and the
  surviving artifact path
- montage-mvt.sh / 4-seasons.sh / year-end-join.sh: clip-duration-sum vs
  music-duration drift check warns when cumulative float error exceeds 2 s

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 17:35:26 +00:00
Claude 62c787fc0b Add .gitignore to exclude __pycache__
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 16:48:18 +00:00
Claude 7486916f9f Sunrise time overlay; systemd upload separation; bug fixes
daily_sunrise_video.sh:
- Fixed: was using undefined \$MOVIES_DIR (now \$BASE_DIR/movies)
- Fixed: sunrise_overlay.py was called but never existed — would fail daily
- Fixed: speed-adjust step had no explicit codec (-c:v libx264 missing)
- New: sunrise time overlaid as stacked vertical characters on the right
  side using ffmpeg drawtext — no Python/Pillow dependency
- New: upload removed from script; now triggered by systemd OnSuccess=
- Combines speed-adjust and overlay into one ffmpeg pass (was two)
- SUNRISE_OVERLAY_OPACITY from conf controls transparency

install.sh:
- sky-cam-sunrise.service gains OnSuccess=sky-cam-sunrise-upload.service
  so upload only runs when video creation succeeds, with separate log
- New sky-cam-sunrise-upload.service runs sunrise2mm.py

sunrise2mm.py: add shebang + chmod +x so systemd ExecStart= calls it directly

sky-cam.conf: add SUNRISE_OVERLAY_OPACITY=0.45

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 16:35:33 +00:00
Claude 6d68010691 Expose encoding quality and overlay durations in sky-cam.conf
Adds six CRF vars, AUDIO_BITRATE, and three MONTAGE_* overlay durations.
Values match previous hardcoded defaults so behavior is unchanged.

The same CRF appeared in several scripts but with intentionally different
values per purpose (28 for draft intermediates, 26 for polished output).
Each script's CRF is now its own variable in conf, so changing one never
silently changes another.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 16:08:14 +00:00
Claude fffb19fd38 Add MOVIES_DIR to conf; remove hardcoded 'movies' subdir
All scripts now use $MOVIES_DIR instead of $BASE_DIR/movies.
Defaults to BASE_DIR/movies but can point to a separate drive.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-19 16:01:27 +00:00