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
This commit is contained in:
@@ -86,11 +86,15 @@ size=$(du -h "$output" | cut -f1)
|
||||
echo "Audio capture complete: $output (${record_dur_sec}s, $size)"
|
||||
|
||||
# Rolling retention for sunrise audio clips
|
||||
# Guard with [ -d ] so find never exits non-zero under set -euo pipefail,
|
||||
# which would cause the service to report failure even after a clean capture.
|
||||
retain="${SUNRISE_AUDIO_RETENTION_DAYS:-7}"
|
||||
if [ "$retain" -gt 0 ]; then
|
||||
audio_root="${AUDIO_DIR:-$BASE_DIR/audio}/sunrise/$CAM"
|
||||
deleted=$(find "$audio_root" -name "sunrise-audio.m4a" -mtime +"$retain" -print -delete 2>/dev/null | wc -l)
|
||||
[ "$deleted" -gt 0 ] && echo "Retention: deleted $deleted sunrise audio clip(s) older than ${retain}d" || true
|
||||
if [ -d "$audio_root" ]; then
|
||||
deleted=$(find "$audio_root" -name "sunrise-audio.m4a" -mtime +"$retain" -print -delete 2>/dev/null | wc -l) || true
|
||||
[ "$deleted" -gt 0 ] && echo "Retention: deleted $deleted sunrise audio clip(s) older than ${retain}d" || true
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user