diff --git a/thinkstation/frigate/config.yml b/thinkstation/frigate/config.yml new file mode 100644 index 0000000..2f105c0 --- /dev/null +++ b/thinkstation/frigate/config.yml @@ -0,0 +1,282 @@ +# Global Birdseye Settings +birdseye: + enabled: false + restream: true + width: 1280 + height: 720 + quality: 8 + mode: objects + +auth: + enabled: false + trusted_proxies: + - 192.168.88.110 + - 192.168.88.0/24 + - 172.16.0.0/12 + - 127.0.0.1 +proxy: + default_role: viewer + header_map: + user: Remote-User + role: Remote-Role +mqtt: + enabled: true + host: 192.168.88.39 + user: mqtt-user + password: jogiocsi + +# go2rtc stream layout: +# +# ALL cameras use H.265 (HEVC) on the main stream. Chrome/Firefox cannot play +# H.265 via MSE, so each camera has two go2rtc streams: +# +# camera_h265 = native H.265 from camera (stable go2rtc native RTSP connection) +# → used by Frigate ffmpeg for RECORDING (stream copy, keeps H.265 quality) +# camera = H.264 transcoded via "ffmpeg:camera_h265#video=h264" +# ffmpeg reads from go2rtc's localhost re-stream (not directly from camera) +# → used by Frigate for LIVE VIEW in browser (Chrome can play H.264) +# → reading from localhost avoids EOF crashes seen with direct camera connections +# +# All cameras: +# camera_sub = sub-stream → used for DETECTION only (low-res, efficient) +go2rtc: + streams: + # --- Native H.265 connections (stable, used for recording) --- + front_driveway_h265: + - rtsp://admin:Jogiocsi1211@192.168.88.105:554/h264Preview_01_main + front_right_h265: + - rtsp://admin:Jogiocsi1211@192.168.88.100:554/h264Preview_01_main + deck_h265: + - rtsp://admin:Jogiocsi1211@192.168.88.101:554/h264Preview_01_main + back_yard_h265: + - rtsp://admin:Jogiocsi1211@192.168.88.102:554/h264Preview_01_main + front_yard_h265: + - rtsp://admin:Jogiocsi1211@192.168.88.104:554/h264Preview_01_main + shop_h265: + - rtsp://admin:Jogiocsi1211@192.168.88.103:554/h264Preview_01_main + # --- H.264 transcoded (browser-compatible live view) --- + # ffmpeg reads from go2rtc's localhost re-stream, not directly from camera. + # This avoids the EOF crashes seen when ffmpeg connects directly to Reolink cameras. + front_driveway: + - "ffmpeg:front_driveway_h265#video=h264" + front_right: + - "ffmpeg:front_right_h265#video=h264" + deck: + - "ffmpeg:deck_h265#video=h264" + back_yard: + - "ffmpeg:back_yard_h265#video=h264" + front_yard: + - "ffmpeg:front_yard_h265#video=h264" + shop: + - "ffmpeg:shop_h265#video=h264" + + # --- Sub (low-resolution) streams for detection only --- + front_driveway_sub: + - rtsp://admin:Jogiocsi1211@192.168.88.105:554/h264Preview_01_sub + front_yard_sub: + - rtsp://admin:Jogiocsi1211@192.168.88.104:554/h264Preview_01_sub + front_right_sub: + - rtsp://admin:Jogiocsi1211@192.168.88.100:554/h264Preview_01_sub + deck_sub: + - rtsp://admin:Jogiocsi1211@192.168.88.101:554/h264Preview_01_sub + back_yard_sub: + - rtsp://admin:Jogiocsi1211@192.168.88.102:554/h264Preview_01_sub + shop_sub: + - rtsp://admin:Jogiocsi1211@192.168.88.103:554/h264Preview_01_sub + +ffmpeg: + hwaccel_args: preset-nvidia-h264 + +record: + enabled: true + alerts: + retain: + days: 30 + detections: + retain: + days: 30 + continuous: + days: 0 + motion: + days: 30 + +snapshots: + enabled: true + retain: + default: 30 + +detectors: + onnx: + type: onnx + +model: + model_type: yolo-generic + width: 320 + height: 320 + input_tensor: nchw + input_dtype: float + path: /config/model_cache/onnx/yolov9-t-320.onnx + labelmap_path: /labelmap/coco-80.txt + +detect: + enabled: true + +lpr: + enabled: true + device: GPU + model_size: small + known_plates: + Joe: + - "ABC1234" + Cynthia: + - "ABC4567" + Wesley: + - "XYZ9876" + replace_rules: + - pattern: "-" + replacement: "" + - pattern: " " + replacement: "" + +cameras: + front_driveway: + enabled: true + ui: + order: 1 + ffmpeg: + inputs: + # Sub stream → detect only (low-res, efficient) + - path: rtsp://127.0.0.1:8554/front_driveway_sub + roles: [detect] + # Native H.265 stream → record (best quality, stream copy) + - path: rtsp://127.0.0.1:8554/front_driveway_h265 + roles: [record] + detect: + width: 1536 + height: 432 + fps: 5 + objects: + track: [person, car, dog, cat, license_plate] + notifications: + enabled: true + zones: + front_driveway_zone: + coordinates: 0.515,0.475,0.715,0.484,0.989,0.857,0.97,0.968,0.541,0.982 + loitering_time: 0 + friendly_name: Front Driveway Zone + review: + alerts: + required_zones: front_driveway_zone + + front_yard: + enabled: true + ui: + order: 2 + ffmpeg: + inputs: + - path: rtsp://127.0.0.1:8554/front_yard_sub + roles: [detect] + # Native H.265 stream → record (best quality, stream copy) + - path: rtsp://127.0.0.1:8554/front_yard_h265 + roles: [record] + detect: + width: 640 + height: 360 + fps: 5 + objects: + track: [person, car, dog, cat] + notifications: + enabled: true + + front_right: + enabled: true + ui: + order: 6 + ffmpeg: + inputs: + - path: rtsp://127.0.0.1:8554/front_right_sub + roles: [detect] + - path: rtsp://127.0.0.1:8554/front_right_h265 + roles: [record] + detect: + width: 896 + height: 512 + fps: 5 + objects: + track: [person, car, dog, cat] + motion: + mask: 0.259,0.36,0.605,0.193,0.616,0.264,0.266,0.419 + notifications: + enabled: true + + deck: + enabled: true + ui: + order: 4 + ffmpeg: + inputs: + - path: rtsp://127.0.0.1:8554/deck_sub + roles: [detect] + - path: rtsp://127.0.0.1:8554/deck_h265 + roles: [record] + detect: + width: 640 + height: 360 + fps: 5 + objects: + track: [person, car, dog, cat] + notifications: + enabled: true + motion: + mask: + - 0.761,0.201,0.922,0.254,0.915,0.34,0.761,0.272 + - 0.205,0.528,0.266,0.452,0.314,0.603,0.243,0.643 + + back_yard: + enabled: true + ui: + order: 5 + ffmpeg: + inputs: + - path: rtsp://127.0.0.1:8554/back_yard_sub + roles: [detect] + - path: rtsp://127.0.0.1:8554/back_yard_h265 + roles: [record] + detect: + width: 640 + height: 360 + fps: 5 + objects: + track: [person, car, dog, cat] + motion: + mask: + - 0.587,0.193,0.578,0.052,1,0.253,1,0.385 + - 0.25,0.272,0.237,0.373,0.258,0.364 + notifications: + enabled: true + + shop: + enabled: true + ui: + order: 3 + ffmpeg: + inputs: + - path: rtsp://127.0.0.1:8554/shop_sub + roles: [detect] + # Native H.265 stream → record (best quality, stream copy) + - path: rtsp://127.0.0.1:8554/shop_h265 + roles: [record] + detect: + width: 640 + height: 360 + fps: 5 + objects: + track: [person, car, dog, cat] + motion: + mask: + - 0.644,0.053,1,0.216,0.996,0.267,0.64,0.134 + - 0.427,0.424,0.522,0.418,0.521,0.574,0.452,0.567 + notifications: + enabled: true + +version: 0.17-0 diff --git a/thinkstation/frigate/frigate-cctv-setup.md b/thinkstation/frigate/frigate-cctv-setup.md new file mode 100644 index 0000000..653c38d --- /dev/null +++ b/thinkstation/frigate/frigate-cctv-setup.md @@ -0,0 +1,161 @@ +# Frigate NVR & CCTV Setup + +**Last Updated:** May 2026 +**Host:** thinkstation-p710 — `192.168.88.41` + +--- + +## Hardware + +| Component | Details | +|-----------|---------| +| Machine | Lenovo ThinkStation P710 | +| CPU | Intel Xeon E5-2623 v4 @ 2.60 GHz (4 cores / 8 threads, boost to 3.2 GHz) | +| RAM | 24 GB | +| GPU | NVIDIA GeForce GTX 1050 Ti (4 GB VRAM) | +| OS Disk | 234 GB SSD (`/dev/sda2`) | +| Media Storage | 14 TB HDD — mounted at `/mnt/14TB-HD/frigate/media` | + +--- + +## Frigate Docker Setup + +| Item | Value | +|------|-------| +| Image | `ghcr.io/blakeblackshear/frigate:stable-tensorrt` | +| Container name | `frigate` | +| Config path | `/srv/docker/frigate/config/` | +| Media path | `/mnt/14TB-HD/frigate/media` | +| Compose file | `thinkstation/frigate/docker-compose.yml` (this repo) | +| Web UI | `http://192.168.88.41:5000` → `https://cameras.jgitta.com` | +| RTSP port | `8554` | +| WebRTC port | `8555` | + +**GPU acceleration:** Container runs with `runtime: nvidia` and `NVIDIA_VISIBLE_DEVICES=all`. The GTX 1050 Ti handles: +- LPR (licence plate recognition) via GPU +- Birdseye re-stream encoding via `h264_nvenc` +- ONNX object detection via the `onnx` detector + +**Shared memory:** `shm_size: 1024mb` — required for frame buffers across 6 cameras. + +--- + +## Object Detection + +| Item | Value | +|------|-------| +| Detector | ONNX (GPU-accelerated) | +| Model | YOLOv9-t-320 (`yolov9-t-320.onnx`) | +| Input size | 320 × 320 | +| Label map | COCO-80 | +| Model path | `/config/model_cache/onnx/yolov9-t-320.onnx` | + +--- + +## Licence Plate Recognition (LPR) + +| Item | Value | +|------|-------| +| Enabled | Yes | +| Device | GPU | +| Model size | Small | + +**Known plates:** + +| Name | Plate | +|------|-------| +| Joe | ABC1234 | +| Cynthia | ABC4567 | +| Wesley | XYZ9876 | + +--- + +## Camera Inventory + +All cameras are **Reolink** PoE units on the `192.168.88.0/24` subnet. + +| Camera | IP | Model notes | Mount location | +|--------|----|-------------|----------------| +| front_driveway | 192.168.88.105 | Dual-lens panoramic (7680×2160 = two 4K sensors stitched) | Front driveway | +| front_yard | 192.168.88.104 | 4K 811A | Front yard | +| shop | 192.168.88.103 | 4K 811A (uses HTTPS for API) | Shop / outbuilding | +| deck | 192.168.88.101 | 4K 811A | Deck | +| back_yard | 192.168.88.102 | 4K 811A | Back yard | +| front_right | 192.168.88.100 | 4512×2512 sensor (non-standard resolution) | Front right | + +--- + +## Camera Stream Settings + +All cameras confirmed via Reolink API (May 2026): + +| Camera | Main Resolution | Main Codec | Bitrate | FPS | I-frame | Sub Resolution | Sub Codec | +|--------|----------------|------------|---------|-----|---------|----------------|-----------| +| front_driveway (.105) | 7680×2160 | H.265 | 10240 Kbps | 20 | 1x | 1536×432 | H.264 | +| front_yard (.104) | 3840×2160 | H.265 | 6144 Kbps | 25 | 1x | 640×360 | H.264 | +| shop (.103) | 3840×2160 | H.265 | 6144 Kbps | 25 | 1x | 640×360 | H.264 | +| deck (.101) | 3840×2160 | H.265 | 6144 Kbps | 25 | 1x | 640×360 | H.264 | +| back_yard (.102) | 3840×2160 | H.265 | 6144 Kbps | 25 | 1x | 640×360 | H.264 | +| front_right (.100) | 4512×2512 | H.265 | 8192 Kbps | 20 | 1x | 896×512 | H.264 | + +**I-frame interval** set to 1x on all cameras so Frigate can start/end recording clips cleanly without waiting for a keyframe. + +--- + +## go2rtc Stream Architecture + +Chrome/Firefox cannot play H.265 (HEVC) via MSE (Media Source Extensions), so each camera requires two go2rtc streams: + +``` +camera_h265 → native H.265 RTSP from camera + └─ consumed by Frigate ffmpeg for RECORDING (stream copy, no re-encode) + +camera → ffmpeg:camera_h265#video=h264 (software H.265 → H.264 transcode) + └─ served to browser via MSE WebSocket for LIVE VIEW + +camera_sub → native low-res H.264 RTSP sub-stream + └─ consumed by Frigate for OBJECT DETECTION only +``` + +**Key behaviour notes:** +- go2rtc uses **lazy initialization** — transcoders only start when a browser opens the live view, and shut down ~30 seconds after the last viewer leaves. This causes a 2–3 second gray screen on first view, which is expected and unavoidable. +- The `_h265` streams are kept alive continuously by Frigate's recording ffmpeg processes, so recording starts instantly. +- The `#hardware` flag for NVENC transcoding in go2rtc causes EOF crashes with Reolink cameras and **must not be used**. Software transcoding (`libx264`) is used instead. +- Reolink cameras drop RTSP connections every 5–20 minutes (firmware behaviour). go2rtc reconnects automatically; this produces a brief gray screen, not static. + +### shop camera note +The shop camera (`192.168.88.103`) redirects HTTP → HTTPS. All API calls to shop must use `https://` with `-k` (skip cert verification). + +--- + +## Frigate Camera Detection Zones + +| Camera | Detect Resolution | Tracked Objects | Notes | +|--------|------------------|-----------------|-------| +| front_driveway | 1536×432 | person, car, dog, cat, license_plate | Has zone + LPR; alerts require `front_driveway_zone` | +| front_yard | 640×360 | person, car, dog, cat | — | +| shop | 640×360 | person, car, dog, cat | Motion mask on upper-right and mid-frame | +| deck | 640×360 | person, car, dog, cat | Two motion masks | +| back_yard | 640×360 | person, car, dog, cat | Two motion masks | +| front_right | 896×512 | person, car, dog, cat | Motion mask on upper-centre | + +--- + +## Recording & Retention + +| Type | Retention | +|------|-----------| +| Alert clips | 30 days | +| Detection clips | 30 days | +| Motion clips | 30 days | +| Continuous | Disabled | +| Snapshots | 30 days | + +--- + +## Known Issues & Quirks + +- **Reolink H.265 sub-stream firmware bug:** On some Reolink firmware versions, setting the sub-stream to H.265 produces a corrupted bitstream that go2rtc rejects with 404. Sub-streams should always remain H.264. +- **front_driveway panoramic:** The 7680×2160 resolution is two 4K sensors stitched side by side. The wide 1536×432 detect resolution in the Frigate config accounts for this. +- **front_right non-standard resolution:** Camera reports 4512×2512 rather than standard 4K. Model unknown — may be a 5MP variant or older sensor. +- **Swap pressure:** ThinkStation runs ~5.5 GB swap used under normal load. Monitor if adding more cameras or enabling Birdseye.