Frigate NVR: Difference between revisions
(Created page with "=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 jammy stable Allow unattended updates from this repository by add to /etc/apt/apt.conf.d/50unattended-upgrades:...") |
No edit summary |
||
Line 85: | Line 85: | ||
systemctl start docker.service | systemctl start docker.service | ||
==Frigate== | |||
If using ZFS, create a filesystem to store the video recordings: | |||
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: | |||
<pre lang="YAML"> | |||
version: "3.9" | |||
services: | |||
frigate: | |||
container_name: frigate | |||
privileged: true # this may not be necessary for all setups | |||
restart: unless-stopped | |||
image: blakeblackshear/frigate:stable | |||
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 | |||
# - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux | |||
volumes: | |||
- /etc/localtime:/etc/localtime:ro | |||
- /etc/frigate/config.yml:/config/config.yml:ro | |||
- /srv/cctv:/media/frigate | |||
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear | |||
target: /tmp/cache | |||
tmpfs: | |||
size: 1000000000 | |||
ports: | |||
- "5000:5000" | |||
- "1935:1935" # RTMP feeds | |||
environment: | |||
FRIGATE_RTSP_PASSWORD: "<Strong Password>" | |||
</pre> | |||
Create /etc/frigate/config.yml: | |||
<pre> | |||
mqtt: | |||
host: mqtt.example.net | |||
user: mqttbr | |||
password: <Broker Password> | |||
detectors: | |||
coral: | |||
type: edgetpu | |||
device: usb | |||
ffmpeg: | |||
hwaccel_args: -c:v h264_cuvid | |||
input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rw_timeout 5000000 -use_wallclock_as_timestamps 1 -f live_flv | |||
cameras: | |||
BackGarden: | |||
ffmpeg: | |||
inputs: | |||
- path: rtmp://backgarden.iot.example.net/bcs/channel0_sub.bcs?channel=0&stream=0&user=frigate&password=<Camera Password> | |||
roles: | |||
- detect | |||
- rtmp | |||
- path: rtmp://backgarden.iot.example.net/bcs/channel0_main.bcs?channel=0&stream=0&user=frigate&password=<Camera Password> | |||
roles: | |||
- record | |||
detect: | |||
width: 640 | |||
height: 360 | |||
fps: 4 | |||
record: | |||
enabled: True | |||
retain: | |||
days: 14 | |||
mode: motion | |||
events: | |||
retain: | |||
default: 90 | |||
mode: active_objects | |||
</pre> | |||
Start Frigate with: | |||
docker compose -f /etc/frigate/docker-compose.yml up -d | |||
Visit the Frigate interface via: | |||
http://server:5000/ |
Revision as of 17:55, 15 December 2022
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 jammy 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:
mv /var/lib/docker /srv
Edit the systemd service for Docker:
systemctl edit docker.service
Add the following to the top of the override file:
[Service] ExecStart= ExecStart=/usr/bin/dockerd -–data-root=/srv/docker --storage-driver=zfs -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 start docker.service
Frigate
If using ZFS, create a filesystem to store the video recordings:
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: blakeblackshear/frigate:stable
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
# - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/frigate/config.yml:/config/config.yml:ro
- /srv/cctv:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "5000:5000"
- "1935:1935" # RTMP feeds
environment:
FRIGATE_RTSP_PASSWORD: "<Strong Password>"
Create /etc/frigate/config.yml:
mqtt: host: mqtt.example.net user: mqttbr password: <Broker Password> detectors: coral: type: edgetpu device: usb ffmpeg: hwaccel_args: -c:v h264_cuvid input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rw_timeout 5000000 -use_wallclock_as_timestamps 1 -f live_flv cameras: BackGarden: ffmpeg: inputs: - path: rtmp://backgarden.iot.example.net/bcs/channel0_sub.bcs?channel=0&stream=0&user=frigate&password=<Camera Password> roles: - detect - rtmp - path: rtmp://backgarden.iot.example.net/bcs/channel0_main.bcs?channel=0&stream=0&user=frigate&password=<Camera Password> roles: - record detect: width: 640 height: 360 fps: 4 record: enabled: True retain: days: 14 mode: motion events: retain: default: 90 mode: active_objects
Start Frigate with:
docker compose -f /etc/frigate/docker-compose.yml up -d
Visit the Frigate interface via:
http://server:5000/