From a63a42ee46c1092ff3dc0c03748c78238c8cbcbc Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 22 Apr 2026 14:23:30 +0000 Subject: [PATCH] Add Demoio directory for test videos with 8-day retention; capture gap warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit daily_sunrise_video.sh: - Test output now saves to DEMO_DIR// (default: MOVIES_DIR/demoio//) 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 --- daily_sunrise_video.sh | 25 +++++++++++++++++++++++-- sky-cam.conf | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/daily_sunrise_video.sh b/daily_sunrise_video.sh index 0d04d76..0bee487 100755 --- a/daily_sunrise_video.sh +++ b/daily_sunrise_video.sh @@ -114,6 +114,15 @@ first_t=$(basename "${images[0]}" .jpg | tr '-' ':') last_t=$(basename "${images[-1]}" .jpg | tr '-' ':') echo "Images: ${#images[@]} (${first_t} → ${last_t} overlay: ${SR_TIME})" +if ! $TEST_MODE; then + last_sec=$(time_to_seconds "$(basename "${images[-1]}" .jpg)") + gap=$(( end_sec - last_sec )) + if [ "$gap" -gt $(( ${CAPTURE_INTERVAL:-10} * 3 )) ]; then + echo "WARNING: last frame is $(( gap / 60 ))min ${gap}s before window end — capture gap near sunrise" + echo " Check: systemctl --user status sky-cam-capture-${CAM_NAME}.service" + fi +fi + # Concat list with explicit frame duration so each frame represents real elapsed # time. Without this, all frames collapse to timestamp 0 → one-frame video. # The final entry needs a duplicate without duration (ffmpeg concat requirement). @@ -261,7 +270,9 @@ fi # audio ✗ overlay ✓ → final has overlay, no audio # audio ✗ overlay ✗ → sped video promoted (no audio, no overlay) if $TEST_MODE; then - final_video="$output_dir/$current_date-daily-sunrise-test.mp4" + demo_dir="${DEMO_DIR:-$MOVIES_DIR/demoio}/$CAM_NAME" + mkdir -p "$demo_dir" + final_video="$demo_dir/$current_date-daily-sunrise-test.mp4" else final_video="$output_dir/$current_date-daily-sunrise.mp4" fi @@ -334,7 +345,17 @@ if $step3b_ok; then echo "Done: $final_video (${actual_dur}s, time: ${SR_TIME})" rm -f "$sped_video" "$temp_audio" 2>/dev/null || true; temp_audio="" - if ! $TEST_MODE; then + if $TEST_MODE; then + # ── Demo retention ──────────────────────────────────────────────────── + demo_retain="${DEMO_RETENTION_DAYS:-8}" + if [ "$demo_retain" -gt 0 ]; then + deleted_demo=$(find "${DEMO_DIR:-$MOVIES_DIR/demoio}" \ + -name "*-daily-sunrise-test.mp4" \ + -mtime +"$demo_retain" -print -delete 2>/dev/null | wc -l) + [ "$deleted_demo" -gt 0 ] && \ + echo "Demo retention: deleted $deleted_demo test file(s) older than ${demo_retain} days" + fi + else [ -f "${cam_audio:-}" ] && rm -f "${cam_audio:-}" "$SCRIPT_DIR/notify.sh" "Sunrise ready: $current_date" \ "$(basename "$final_video") — ${actual_dur}s, sunrise at ${SR_TIME} | $final_video" || true diff --git a/sky-cam.conf b/sky-cam.conf index 1d3add9..2039ef0 100644 --- a/sky-cam.conf +++ b/sky-cam.conf @@ -228,6 +228,10 @@ SUNRISE_RETENTION_DAYS=10 # Delete unpinned sunrise posts from Mattermost older than this many days. # Pinned posts are always kept regardless. Set 0 to disable Mattermost cleanup. MM_SUNRISE_RETENTION_DAYS=8 +# Output directory for --test runs. Kept separate from production sunrise videos. +# Test files older than DEMO_RETENTION_DAYS are deleted automatically. +DEMO_DIR="${DEMO_DIR:-$MOVIES_DIR/demoio}" +DEMO_RETENTION_DAYS=8 # ── Video encoding quality ──────────────────────────────────────────────────── # FFmpeg CRF: lower = higher quality / larger files. Typical range 18–30.