- Frigate NVR - OpenCV, Tensorflow and MQTT
Frigate NVR - a complete and local NVR designed for Home Assistant with AI object detection. Uses OpenCV and Tensorflow to perform realtime object detection locally for IP cameras.
Frigate is a Docker container that can be run on any Docker host including as a HassOS Addon. Note that a Home Assistant Addon is not the same thing as the integration. The integration is required to integrate Frigate into Home Assistant.
MQTT broker - Frigate requires an MQTT broker. If using Home Assistant, Frigate and Home Assistant must be connected to the same MQTT broker.
Frigate uses the following locations for read/write operations in the container. Docker volume mappings can be used to map these to any location on your host machine.
/media/frigate/clips: Used for snapshot storage. In the future, it will likely be renamed from clips to snapshots. The file structure here cannot be modified and isn't intended to be browsed or managed manually.
/media/frigate/recordings: Internal system storage for recording segments. The file structure here cannot be modified and isn't intended to be browsed or managed manually.
/media/frigate/frigate.db: Default location for the sqlite database. You will also see several files alongside this file while frigate is running. If moving the database location (often needed when using a network drive at /media/frigate), it is recommended to mount a volume with docker at /db and change the storage location of the database to
/db/frigate.dbin the config file.
/tmp/cache: Cache location for recording segments. Initial recordings are written here before being checked and converted to mp4 and moved to the recordings folder.
/dev/shm: It is not recommended to modify this directory or map it with docker. This is the location for raw decoded frames in shared memory and it's size is impacted by the shm-size calculations below.
/config/config.yml: Default location of the config file.
mkdir -p /opt/frigate/storage
Frigate utilizes shared memory to store frames during processing. The default shm-size provided by Docker is 64m.
The default shm-size of 64m is fine for setups with 2 or less 1080p cameras. If frigate is exiting with "Bus error" messages, it is likely because you have too many high resolution cameras and you need to specify a higher shm size.
You can calculate the necessary shm-size for each camera with the following formula:
(width * height * 1.5 * 9 + 270480)/1048576 = <shm size in mb>
Frigate requires a functioning MQTT server. Start by adding the mqtt section at the top level in your config:
mqtt: host: <ip of your mqtt server>
If using the Mosquitto Addon in Home Assistant, a username and password is required. For example:
mqtt: host: 192.168.2.117 user: admin password: instar
cameras: camera_1: # <------ Name the camera ffmpeg: inputs: - path: rtsp://admin:firstname.lastname@example.org:554/livestream/12 # <----- Update for your camera roles: - detect - rtmp detect: width: 1920 # <---- update for your camera's resolution height: 1080 # <---- update for your camera's resolution
Pick a Frigate version from the Docker Hub, e.g.:
And edit the Docker-Compose file accordingly:
version: "3.9" services: frigate: container_name: frigate privileged: true # this may not be necessary for all setups restart: unless-stopped image: blakeblackshear/frigate:0.10.0-14c74e4-amd64 shm_size: "64mb" # 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/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware volumes: - /etc/localtime:/etc/localtime:ro - /opt/frigate/config.yml:/config/config.yml:ro - /opt/frigate/storage:/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: "password"