Skip to content

Architecture

The setup has three layers: go2rtc obtains and restreams camera input, one ffmpeg service per camera writes segments, and systemd timers maintain the resulting filesystem.

camera RTSP inputs
        │
        ▼
go2rtc (127.0.0.1:8554/<name>)
        │
        ├── camera-recorder@1..4.service ──► /media/recordings/<name>/*.mkv
        │                                             │
        │                         organizer timer ◄──┘
        │                         cleanup timer   ──► expired files removed
        └── watchdog timer ──► restart stale recorder instances

The recorder template receives a camera number as its systemd instance name. The number selects CAMERA_N_NAME and CAMERA_N_URL from the configuration. ffmpeg maps the first video stream and optional first audio stream, then uses the segment muxer with clock-aligned filenames.

config/    examples only; production config lives in /etc
scripts/   installed into /usr/local/bin
systemd/   installed into /etc/systemd/system

The recorder requires go2rtc.service, restarts on failure, and uses NoNewPrivileges=true and PrivateTmp=true. The maintenance jobs are oneshot services invoked by their timers.