diff --git a/main.go b/main.go index dc007b0..8b87a24 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,16 @@ func main() { snaps.StartAll(cfg.Cameras) app.snapshots = snaps + // Start FFmpeg recorder for all enabled cameras. + rec := NewRecorderManager(cfg.Storage) + rec.StartAll(cfg.Cameras) + app.recorder = rec + + // Start retention cleaner. + cln := NewCleaner(cfg.Storage) + go cln.Start() + app.cleaner = cln + // Start the HTTP server (blocks). errCh := make(chan error, 1) go func() { @@ -110,6 +120,8 @@ type App struct { server *Server go2rtc *Go2RTCManager snapshots *SnapshotEngine + recorder *RecorderManager + cleaner *Cleaner } // StartServer initializes and starts the HTTP server. @@ -124,6 +136,12 @@ func (a *App) StartServer() error { // Shutdown performs a graceful shutdown of all services. func (a *App) Shutdown() { + if a.recorder != nil { + a.recorder.StopAll() + } + if a.cleaner != nil { + a.cleaner.Stop() + } if a.snapshots != nil { a.snapshots.StopAll() } diff --git a/recorder.go b/recorder.go index f34cccc..adaf950 100644 --- a/recorder.go +++ b/recorder.go @@ -127,7 +127,8 @@ func (rm *RecorderManager) startRecorder(cam CameraConfig) { "-hide_banner", "-loglevel", "error", "-rtsp_transport", "tcp", "-i", rtspURL, - "-c", "copy", // stream-copy: zero transcoding, near-zero CPU + "-an", // drop audio (pcm_mulaw not supported in MP4) + "-c:v", "copy", // stream-copy video: zero transcoding, near-zero CPU "-t", "300", // hard stop after 300 seconds (5 minutes) "-y", // overwrite output without asking partFile,