Setup Frigate NVR
Posted on October 2, 2012
Tags: hackhard
Summary:
- create frigate config file
~/.config/frigate/frigate.yml
- configure addr of MQTT server
- configure addr of RTSP camera
- create frigate Video folder
- This is location of recordings
- create a MQTT config file (New version makes MQTT optional)
- create a docker compose for both frigate and MQTT
- cd to this folder to startup frigate
1 Frigate Config file
cd ~
cd .config #if not exists, mkdir .config
mkdir frigate
cd frigate
touch frigate.yml
#mqtt:
# host: 192.168.1.245
# port: 1883
mqtt:
enabled: False
ffmpeg:
hwaccel_args: preset-vaapi
# above is for intel, comment out if necessary
record:
events:
retain:
default: 25
timestamp_style:
position: "tr"
format: "%m/%d/%Y %H:%M:%S"
thickness: 3
effect: "solid"
snapshots:
timestamp: True
cameras:
camera_1: # <------ Name the camera
ffmpeg:
inputs:
#- path: rtsp://admin:admin@192.168.1.132:554/11 # <----- Update for your camera
- path: rtsp://admin:admin@192.168.1.132/11/h264major
roles:
- detect
- rtmp
rtmp:
enabled: False # <-- RTMP should be disabled if your stream is not H264
detect:
width: 1920 # <---- update for your camera's resolution
height: 1080 # <---- update for your camera's resolution
fps: 8
objects:
track:
- person
- cat
filters:
person:
threshold: 0.7
record:
enabled: True
snapshots:
enabled: True
mqtt:
timestamp: True
#-------------------------------------------------
camera_2: # <------ Name the camera
ffmpeg:
inputs:
- path: rtsp://admin:admin@192.168.1.126:554/live/ch0 # <----- Update for your camera
roles:
- detect
- rtmp
rtmp:
enabled: False # <-- RTMP should be disabled if your stream is not H264
detect:
width: 1920 # <---- update for your camera's resolution
height: 1080 # <---- update for your camera's resolution
fps: 8
record:
enabled: True
snapshots:
enabled: True
mqtt:
timestamp: True
#-------------------------------------------------
camera_3: # <------ Name the camera
ffmpeg:
inputs:
- path: rtsp://admin:admin@192.168.1.127:554/live/ch0 # <----- Update for your camera
roles:
- detect
- rtmp
rtmp:
enabled: False # <-- RTMP should be disabled if your stream is not H264
detect:
width: 1920 # <---- update for your camera's resolution
height: 1080 # <---- update for your camera's resolution
fps: 8
record:
enabled: True
snapshots:
enabled: True
mqtt:
timestamp: True
1.1 Optional - ESP32
The input_args is neccessary or it wont run. disabling hwaccel or it will have a half green screen bug.
camera_4:
ffmpeg:
hwaccel_args: " "
input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg
inputs:
- path: http://192.168.22.11:81/stream
roles:
- detect
- rtmp
rtmp:
enabled: False
2 Create frigate Video folder
cd ~
cd Videos
mkdir frigateMedia
3 create a MQTT config file (Now Optional)
- new frigate version makes MQTT optional
cd ~
cd .config
mkdir mosquitto
cd mosquitto
mkdir config
touch mosquitto.conf
persistence false
log_dest stdout
allow_anonymous true
connection_messages true
listener 1883 0.0.0.0
4 docker-compose
cd ~
mkdir frigate
cd frigate
touch docker-compose.yml
version: "3.9"
services:
frigate:
container_name: frigate
privileged: true # this may not be necessary for all setups
image: "ghcr.io/blakeblackshear/frigate:stable"
shm_size: "999mb" # update for your cameras based on calculation above
devices:
- /dev/dri/renderD128 #for intel hwaccel
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/ubuntu/.config/frigate/config.yml:/config/config.yml:ro
- /home/ubuntu/Videos/frigateMedia:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "5000:5000"
environment:
FRIGATE_RTSP_PASSWORD: "password"
restart: always
docker-compose build
docker-compose up
5 Misc
ONVIF url
http://192.168.1.132:8080
1920x1080
rtsp://admin:admin@192.168.1.132:554/11
640x352
rtsp://admin:admin@192.168.1.132:554/12
http://192.168.1.127:8899
http://192.168.1.126:8899
rtsp://admin:admin@192.168.1.126:554/live/ch0
rtsp://admin:admin@192.168.1.126:554/live/ch1
http://192.168.1.127:8899
rtsp://admin:admin@192.168.1.127:554/live/ch0 rtsp://admin:admin@192.168.1.127:554/live/ch1
5.1 Troubleshooting
if it doesnt work try turning off hardware acceleration by commenting out
- /dev/dri/renderD128 #for intel hwaccel
indocker-compose.yml
hwaccel_args: preset-vaapi
in~/.config/frigate/config.yml
6 Frigate configs that uses Webcam
The difference is we add Mediamtx container to out docker-compose
version: "3.9"
services:
Mediamtx:
container_name: rtsp-simple-server
privileged: true
image: aler9/rtsp-simple-server
network_mode: "host"
ports:
- 8554:8554
restart: always
frigate:
container_name: frigate
privileged: true # this may not be necessary for all setups
image: "ghcr.io/blakeblackshear/frigate:stable"
shm_size: "999mb" # update for your cameras based on calculation above
devices:
- /dev/dri/renderD128 #for intel hwaccel
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/ubuntu/.config/frigate/config.yml:/config/config.yml:ro
- /home/ubuntu/Videos/frigateMedia:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "5000:5000"
depends_on:
- "Mediamtx"
environment:
FRIGATE_RTSP_PASSWORD: "password"
restart: always
sudo ffmpeg -f v4l2 -framerate 25 -video_size 1280x1024 -i /dev/video0 -f rtsp -rtsp_transport udp rtsp://192.168.1.226:8554/mystream
- mediamtx starts a rtsp server from docker-compose
- ffmpeg bash command will push video stream to that mediamtx server
- mediamtx server will broadcast the stream so that frigate can use it
list the systemctl service ls /etc/systemd/system/
make a systemctl service for ffmpeg bash command touch /etc/systemd/system/myservice.service
In our case our script to run the bash command is called camcron
[Unit]
Description=Example systemd service.
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
Restart=on-failure
RestartSec=5s
Type=simple
ExecStart=/bin/bash /home/ubuntu/camcron
[Install]
WantedBy=multi-user.target
systemctl daemon-reload command
systemctl enable myservice
systemctl start myservice