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
This commit is contained in:
+50
@@ -111,6 +111,50 @@ write_timer "sky-cam-sunrise" "$SUNRISE_CAM: daily sunrise video" "$SCHEDULE_SUN
|
||||
|
||||
timers=(sky-cam-sunrise)
|
||||
|
||||
# ── Per-camera continuous capture services ────────────────────────────────────
|
||||
# capture.sh replaces MotionEye / any NVR for periodic JPEG capture.
|
||||
# Generated when CAM_RTSP_<cam> is set; Type=simple (long-running, not oneshot).
|
||||
capture_services=()
|
||||
for cam in "${CAMERAS[@]}"; do
|
||||
rtsp_var="CAM_RTSP_${cam}"
|
||||
if [ -n "${!rtsp_var:-}" ]; then
|
||||
cat > "$UNIT_DIR/sky-cam-capture-${cam}.service" <<EOF
|
||||
[Unit]
|
||||
Description=Sky-Cam — ${cam}: continuous RTSP frame capture
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=$SCRIPT_DIR/capture.sh ${cam}
|
||||
Restart=on-failure
|
||||
RestartSec=30
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
EOF
|
||||
echo " wrote sky-cam-capture-${cam}.service"
|
||||
capture_services+=("sky-cam-capture-${cam}")
|
||||
else
|
||||
echo " WARNING: CAM_RTSP_${cam} not set — skipping capture service for ${cam}"
|
||||
echo " (set CAM_RTSP_${cam}=rtsp://... in sky-cam.conf to enable)"
|
||||
fi
|
||||
done
|
||||
|
||||
# ── Sunrise audio capture ─────────────────────────────────────────────────────
|
||||
# Triggered at 03:00; waits internally until the right time before recording.
|
||||
if [ "${AUDIO_ENABLED:-false}" = "true" ]; then
|
||||
write_service "sky-cam-audio-capture" \
|
||||
"$SUNRISE_CAM: sunrise audio capture" \
|
||||
"sunrise-audio-capture.sh"
|
||||
write_timer "sky-cam-audio-capture" \
|
||||
"$SUNRISE_CAM: sunrise audio capture" \
|
||||
"03:00:00"
|
||||
timers+=("sky-cam-audio-capture")
|
||||
fi
|
||||
|
||||
# ── Per-camera Four Seasons and full-day jobs ─────────────────────────────────
|
||||
# Reads CAMERAS, SCHEDULE_SEASONS_<cam>, SCHEDULE_FULLDAY_<cam> from sky-cam.conf.
|
||||
# Scripts receive the camera name as $1 so they know which camera to process.
|
||||
@@ -146,6 +190,12 @@ done
|
||||
echo ""
|
||||
$SC daemon-reload
|
||||
|
||||
for svc in "${capture_services[@]}"; do
|
||||
$SC enable --now "${svc}.service" \
|
||||
&& echo " enabled + started ${svc}.service" \
|
||||
|| echo " WARNING: could not enable ${svc}.service"
|
||||
done
|
||||
|
||||
for timer in "${timers[@]}"; do
|
||||
$SC enable --now "${timer}.timer" \
|
||||
&& echo " enabled + started ${timer}.timer" \
|
||||
|
||||
Reference in New Issue
Block a user