- 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
67 lines
2.0 KiB
Bash
Executable File
67 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# capture.sh <cam-name> — continuous JPEG frame capture from a camera's RTSP
|
|
# stream. Replaces MotionEye or any NVR for sky-cam's timelapse pipeline.
|
|
# Pure ffmpeg — no NVR software required.
|
|
#
|
|
# Run as a long-running systemd service (Type=simple), one per camera.
|
|
# install.sh generates sky-cam-capture-<cam>.service automatically when
|
|
# CAM_RTSP_<cam> is set in sky-cam.conf.
|
|
#
|
|
# Writes: BASE_DIR/<cam>/YYYY-MM-DD/HH-MM-SS.jpg
|
|
# Restarts ffmpeg at midnight so images land in the correct date directory.
|
|
# On camera disconnect, waits 30 s then reconnects automatically.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
|
|
source "$SCRIPT_DIR/sky-cam.conf"
|
|
export TZ="$TIMEZONE"
|
|
|
|
CAM="${1:-}"
|
|
if [ -z "$CAM" ]; then
|
|
echo "Usage: $0 <camera-name>"
|
|
exit 1
|
|
fi
|
|
|
|
rtsp_var="CAM_RTSP_${CAM}"
|
|
RTSP_URL="${!rtsp_var:-}"
|
|
if [ -z "$RTSP_URL" ]; then
|
|
echo "ERROR: CAM_RTSP_${CAM} not set in sky-cam.conf"
|
|
exit 1
|
|
fi
|
|
|
|
INTERVAL="${CAPTURE_INTERVAL:-10}"
|
|
echo "Starting capture: cam=$CAM interval=${INTERVAL}s"
|
|
|
|
while true; do
|
|
today=$(date +%Y-%m-%d)
|
|
dir="$BASE_DIR/$CAM/$today"
|
|
mkdir -p "$dir"
|
|
|
|
# Run until midnight + 5 s so the new day's directory is ready on restart
|
|
midnight=$(date -d "tomorrow 00:00:00" +%s)
|
|
now=$(date +%s)
|
|
duration=$(( midnight - now + 5 ))
|
|
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Capturing → $dir (rollover in ${duration}s)"
|
|
|
|
# -strftime 1 expands %H-%M-%S in the output path using the frame timestamp
|
|
ffmpeg -loglevel warning \
|
|
-rtsp_transport tcp \
|
|
-i "$RTSP_URL" \
|
|
-t "$duration" \
|
|
-vf "fps=1/${INTERVAL}" \
|
|
-f image2 \
|
|
-strftime 1 \
|
|
-q:v 2 \
|
|
"${dir}/%H-%M-%S.jpg" || true
|
|
|
|
# If ffmpeg exited before midnight the camera dropped — wait then retry
|
|
if [ "$(date +%s)" -lt "$midnight" ]; then
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$CAM] stream lost — retrying in 30s"
|
|
sleep 30
|
|
else
|
|
sleep 2 # brief pause at midnight before day rollover restart
|
|
fi
|
|
done
|