Frigate NVR: Difference between revisions
No edit summary |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
Add the Docker repository in /etc/apt/sources.list.d/docker.list: | Add the Docker repository in /etc/apt/sources.list.d/docker.list: | ||
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu | deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable | ||
Allow unattended updates from this repository by add to /etc/apt/apt.conf.d/50unattended-upgrades: | Allow unattended updates from this repository by add to /etc/apt/apt.conf.d/50unattended-upgrades: | ||
Line 35: | Line 35: | ||
systemctl stop containerd.service | systemctl stop containerd.service | ||
Move the Docker root directory: | Move the Docker root directory: (optional) | ||
mv /var/lib/docker /srv/data | mv /var/lib/docker /srv/data | ||
Line 41: | Line 41: | ||
Edit the systemd service for Docker: | Edit the systemd service for Docker: | ||
systemctl edit docker.service | systemctl edit docker.service (only if moving) | ||
Add the following to the top of the override file: | Add the following to the top of the override file: | ||
Line 84: | Line 84: | ||
Restart Docker: | Restart Docker: | ||
systemctl | systemctl restart docker.service | ||
Line 98: | Line 98: | ||
mkdir /etc/frigate | mkdir /etc/frigate | ||
Create /etc/frigate/docker-compose.yml: | Create /etc/frigate/docker-compose.yml: | ||
Line 126: | Line 108: | ||
privileged: true # this may not be necessary for all setups | privileged: true # this may not be necessary for all setups | ||
restart: unless-stopped | restart: unless-stopped | ||
image: blakeblackshear/frigate:stable | image: ghcr.io/blakeblackshear/frigate:stable-tensorrt | ||
network_mode: bridge | network_mode: bridge | ||
deploy: | deploy: | ||
Line 136: | Line 118: | ||
capabilities: [gpu] | capabilities: [gpu] | ||
shm_size: "128mb" # update for your cameras based on calculation above | shm_size: "128mb" # update for your cameras based on calculation above | ||
# devices: | |||
# - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions | |||
volumes: | volumes: | ||
- /etc/localtime:/etc/localtime:ro | - /etc/localtime:/etc/localtime:ro | ||
- /etc/frigate/ | # - /etc/frigate/trt-models:/trt-models:ro | ||
- /etc/frigate/:/config | |||
- /srv/cctv:/media/frigate | - /srv/cctv:/media/frigate | ||
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear | - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear | ||
Line 149: | Line 131: | ||
ports: | ports: | ||
- "5000:5000" | - "5000:5000" | ||
- " | - "8554:8554" # RTSP feeds | ||
- "8555:8555/tcp" # WebRTC over tcp | |||
- "8555:8555/udp" # WebRTC over udp | |||
environment: | environment: | ||
# - FRIGATE_RTSP_PASSWORD: "Rd54bRZYghUuDWoXC2SPVr" | |||
- YOLO_MODELS=yolov7-tiny-416 | |||
</pre> | </pre> | ||
Line 158: | Line 143: | ||
<pre> | <pre> | ||
mqtt: | mqtt: | ||
host: mqtt. | host: mqtt.scottworld.net | ||
user: | user: scottbroker | ||
password: | password: mqtt1 | ||
#detectors: | |||
# coral: | |||
# type: edgetpu | |||
# device: usb | |||
detectors: | detectors: | ||
tensorrt: | |||
type: | type: tensorrt | ||
device: | device: 0 | ||
model: | |||
path: /config/model_cache/tensorrt/yolov7-tiny-416.trt | |||
input_tensor: nchw | |||
input_pixel_format: rgb | |||
width: 416 | |||
height: 416 | |||
ffmpeg: | ffmpeg: | ||
hwaccel_args: - | hwaccel_args: preset-nvidia-h264 | ||
input_args: - | input_args: preset-http-reolink | ||
output_args: | |||
record: preset-record-generic-audio-copy | |||
timestamp_style: | |||
format: '%Y-%m-%d %H:%M:%S' | |||
go2rtc: | |||
streams: | |||
FrontCam: | |||
- http://frontcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_main.bcs&user=camera&password=camera | |||
BackCam: | |||
- http://backcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_main.bcs&user=camera&password=camera | |||
Doorbell: | |||
- http://doorbell.scottworld.net/flv?port-1935&app=bcs&stream=channel0_main.bcs&user=camera&password=camera | |||
cameras: | cameras: | ||
FrontCam: | |||
ffmpeg: | ffmpeg: | ||
inputs: | inputs: | ||
- path: | |||
http://frontcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_ext.bcs&user=camera&password=camera | |||
roles: | |||
- detect | |||
- path: | - path: rtsp://127.0.0.1:8554/FrontCam?video=copy&audio=aac | ||
input_args: preset-rtsp-restream | |||
roles: | |||
- record | |||
motion: | |||
mask: | |||
- 896,0,500,0,505,36,896,39 | |||
objects: | |||
track: | |||
- person | |||
- car | |||
- bicycle | |||
- motorcycle | |||
zones: | |||
front_drive: | |||
coordinates: 896,277,896,672,0,672,0,105,250,45,244,119,470,227,482,107 | |||
objects: | |||
- person | |||
- car | |||
- bicycle | |||
- motorcycle | |||
BackCam: | |||
ffmpeg: | |||
inputs: | |||
- path: | |||
http://backcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_ext.bcs&user=camera&password=camera | |||
roles: | |||
- detect | |||
- path: rtsp://127.0.0.1:8554/BackCam?video=copy&audio=aac | |||
input_args: preset-rtsp-restream | |||
roles: | |||
- record | |||
motion: | |||
mask: | |||
- 896,0,896,41,511,46,517,0 | |||
objects: | |||
track: | |||
- person | |||
- cat | |||
- bird | |||
zones: | |||
back_garden: | |||
coordinates: 436,672,0,672,0,0,488,0,484,59,714,63,896,139,896,672 | |||
objects: | |||
- person | |||
- cat | |||
- bird | |||
Doorbell: | |||
ffmpeg: | |||
inputs: | |||
- path: | |||
http://doorbell.scottworld.net/flv?port-1935&app=bcs&stream=channel0_ext.bcs&user=camera&password=camera | |||
roles: | |||
- detect | |||
- path: rtsp://127.0.0.1:8554/Doorbell?video=copy&audio=aac | |||
input_args: preset-rtsp-restream | |||
roles: | |||
- record | |||
motion: | |||
mask: | |||
- 896,0,896,332,0,287,0,0 | |||
objects: | |||
track: | |||
- person | |||
zones: | |||
front_porch: | |||
coordinates: 896,672,0,672,0,294,37,324,29,421,301,443,304,312,896,348 | |||
objects: | |||
- person | |||
birdseye: | |||
enabled: true | |||
mode: motion | |||
record: | record: | ||
enabled: | enabled: true | ||
retain: | retain: | ||
days: 14 | days: 14 | ||
mode: motion | mode: motion | ||
events: | events: | ||
required_zones: | |||
- front_drive | |||
- front_porch | |||
- back_garden | |||
retain: | retain: | ||
default: 90 | default: 90 | ||
mode: active_objects | mode: active_objects | ||
snapshots: | |||
enabled: true | |||
</pre> | </pre> | ||
Line 205: | Line 291: | ||
http://server:5000/ | http://server:5000/ | ||
Update the Image with | |||
<pre> | |||
docker compose -f /etc/frigate/docker-compose.yml down | |||
docker compose -f /etc/frigate/docker-compose.yml pull | |||
docker compose -f /etc/frigate/docker-compose.yml up (Add the -d option to start with a detach option) | |||
</pre> |
Latest revision as of 18:44, 19 March 2024
Frigate NVR
Docker
Download and save the Docker repository signing key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Add the Docker repository in /etc/apt/sources.list.d/docker.list:
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable
Allow unattended updates from this repository by add to /etc/apt/apt.conf.d/50unattended-upgrades:
Unattended-Upgrade::Allowed-Origins { // Append to end of existing entries "Docker:${distro_codename}"; };
Update the repositories and install the package:
apt update apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Check all is working with:
docker version
Stop the services:
systemctl stop docker.service systemctl stop docker.socket systemctl stop containerd.service
Move the Docker root directory: (optional)
mv /var/lib/docker /srv/data
Edit the systemd service for Docker:
systemctl edit docker.service (only if moving)
Add the following to the top of the override file:
[Service] ExecStart= ExecStart=/usr/bin/dockerd -–data-root=/srv/data/docker -H fd:// --containerd=/run/containerd/containerd.sock
Restart Docker:
systemctl daemon-reload systemctl start docker.service
Check it still works with:
docker run hello-world
GPU Hardware Acceleration
Download and save the NVIDIA repository signing key:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /etc/apt/keyrings/nvidia-container.gpg
Add the Docker repository in /etc/apt/sources.list.d/nvidia-container.list:
deb [signed-by=/etc/apt/keyrings/nvidia-container.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/$(ARCH) /
Allow unattended updates from this repository by add to /etc/apt/apt.conf.d/50unattended-upgrades:
Unattended-Upgrade::Origins-Pattern { "site=nvidia.github.io"; };
Update the repositories and install the package:
apt update apt install nvidia-docker2
Restart Docker:
systemctl restart docker.service
Frigate
If using ZFS, create a filesystem to store the video recordings (not used currently)
zfs create -o recordsize=1M -o compression=off -o quota=256G data/cctv
Create a configuration directory for Frigate:
mkdir /etc/frigate
Create /etc/frigate/docker-compose.yml:
version: "3.9"
services:
frigate:
container_name: frigate
privileged: true # this may not be necessary for all setups
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
network_mode: bridge
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
shm_size: "128mb" # update for your cameras based on calculation above
# devices:
# - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
volumes:
- /etc/localtime:/etc/localtime:ro
# - /etc/frigate/trt-models:/trt-models:ro
- /etc/frigate/:/config
- /srv/cctv:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "5000:5000"
- "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp
- "8555:8555/udp" # WebRTC over udp
environment:
# - FRIGATE_RTSP_PASSWORD: "Rd54bRZYghUuDWoXC2SPVr"
- YOLO_MODELS=yolov7-tiny-416
Create /etc/frigate/config.yml:
mqtt: host: mqtt.scottworld.net user: scottbroker password: mqtt1 #detectors: # coral: # type: edgetpu # device: usb detectors: tensorrt: type: tensorrt device: 0 model: path: /config/model_cache/tensorrt/yolov7-tiny-416.trt input_tensor: nchw input_pixel_format: rgb width: 416 height: 416 ffmpeg: hwaccel_args: preset-nvidia-h264 input_args: preset-http-reolink output_args: record: preset-record-generic-audio-copy timestamp_style: format: '%Y-%m-%d %H:%M:%S' go2rtc: streams: FrontCam: - http://frontcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_main.bcs&user=camera&password=camera BackCam: - http://backcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_main.bcs&user=camera&password=camera Doorbell: - http://doorbell.scottworld.net/flv?port-1935&app=bcs&stream=channel0_main.bcs&user=camera&password=camera cameras: FrontCam: ffmpeg: inputs: - path: http://frontcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_ext.bcs&user=camera&password=camera roles: - detect - path: rtsp://127.0.0.1:8554/FrontCam?video=copy&audio=aac input_args: preset-rtsp-restream roles: - record motion: mask: - 896,0,500,0,505,36,896,39 objects: track: - person - car - bicycle - motorcycle zones: front_drive: coordinates: 896,277,896,672,0,672,0,105,250,45,244,119,470,227,482,107 objects: - person - car - bicycle - motorcycle BackCam: ffmpeg: inputs: - path: http://backcam.scottworld.net/flv?port-1935&app=bcs&stream=channel0_ext.bcs&user=camera&password=camera roles: - detect - path: rtsp://127.0.0.1:8554/BackCam?video=copy&audio=aac input_args: preset-rtsp-restream roles: - record motion: mask: - 896,0,896,41,511,46,517,0 objects: track: - person - cat - bird zones: back_garden: coordinates: 436,672,0,672,0,0,488,0,484,59,714,63,896,139,896,672 objects: - person - cat - bird Doorbell: ffmpeg: inputs: - path: http://doorbell.scottworld.net/flv?port-1935&app=bcs&stream=channel0_ext.bcs&user=camera&password=camera roles: - detect - path: rtsp://127.0.0.1:8554/Doorbell?video=copy&audio=aac input_args: preset-rtsp-restream roles: - record motion: mask: - 896,0,896,332,0,287,0,0 objects: track: - person zones: front_porch: coordinates: 896,672,0,672,0,294,37,324,29,421,301,443,304,312,896,348 objects: - person birdseye: enabled: true mode: motion record: enabled: true retain: days: 14 mode: motion events: required_zones: - front_drive - front_porch - back_garden retain: default: 90 mode: active_objects snapshots: enabled: true
Start Frigate with:
docker compose -f /etc/frigate/docker-compose.yml up -d
Visit the Frigate interface via:
http://server:5000/
Update the Image with
docker compose -f /etc/frigate/docker-compose.yml down docker compose -f /etc/frigate/docker-compose.yml pull docker compose -f /etc/frigate/docker-compose.yml up (Add the -d option to start with a detach option)