Closed lukaszolek closed 3 years ago
Can you post your config?
When I comment out hwaccel_args everything works fine, except high CPU usage.
detectors:
coral:
type: edgetpu
device: usb
mqtt:
host: 192.168.0.200
user: frigate
password: 98gfk349dfk309w
ffmpeg:
hwaccel_args:
- -c:v
- h264_v4l2m2m
cameras:
garage:
ffmpeg:
inputs:
- path: rtsp://***:***@192.168.0.33:554/cam/realmonitor?channel=1&subtype=0&unicast=true
roles:
- detect
- clips
width: 1280
height: 720
fps: 5
clips:
enabled: True
pre_capture: 2
post_capture: 2
objects:
- person
- car
- cat
- dog
retain:
default: 30
garage_door:
ffmpeg:
inputs:
- path: rtsp://***:***@192.168.0.33:554/cam/realmonitor?channel=2&subtype=0&unicast=true
roles:
- detect
- clips
width: 1280
height: 720
fps: 5
clips:
enabled: True
pre_capture: 2
post_capture: 2
objects:
- person
- car
- cat
- dog
retain:
default: 30
garden_front:
ffmpeg:
inputs:
- path: rtsp://***:***@192.168.0.33:554/cam/realmonitor?channel=3&subtype=0&unicast=true
roles:
- detect
- clips
width: 1280
height: 720
fps: 5
clips:
enabled: True
pre_capture: 2
post_capture: 2
objects:
- person
- car
- cat
- dog
retain:
default: 30
tarrace_front:
ffmpeg:
inputs:
- path: rtsp://***:***@192.168.0.33:554/cam/realmonitor?channel=5&subtype=0&unicast=true
roles:
- detect
- clips
width: 1280
height: 720
fps: 5
clips:
enabled: True
pre_capture: 2
post_capture: 2
objects:
- person
- car
- cat
- dog
retain:
default: 30
tarrace_back:
ffmpeg:
inputs:
- path: rtsp://***:***@192.168.0.33:554/cam/realmonitor?channel=4&subtype=0&unicast=true
roles:
- detect
- clips
width: 1280
height: 720
fps: 5
clips:
enabled: True
pre_capture: 2
post_capture: 2
objects:
- person
- car
- cat
- dog
retain:
default: 30
garden_back:
ffmpeg:
inputs:
- path: rtsp://***:***@192.168.0.33:554/cam/realmonitor?channel=6&subtype=0&unicast=true
roles:
- detect
- clips
width: 1280
height: 720
fps: 5
clips:
enabled: True
pre_capture: 2
post_capture: 2
objects:
- person
- car
- cat
- dog
retain:
default: 30
clips:
max_seconds: 300
tmpfs_cache_size: 256m
retain:
default: 30
objects:
track:
- person
- car
- cat
- dog
filters:
person:
min_area: 200
max_area: 200000
min_score: 0.5
threshold: 0.7
car:
min_area: 200
max_area: 200000
min_score: 0.5
threshold: 0.7
cat:
min_area: 200
max_area: 200000
min_score: 0.5
threshold: 0.7
dog:
min_area: 200
max_area: 200000
min_score: 0.5
threshold: 0.7
motion:
threshold: 10
contour_area: 100
delta_alpha: 0.2
frame_alpha: 0.2
frame_height: 180
I don't know why it is requiring so much memory. Are using an RPi4 with the 64bit OS?
I saw the same thing with ffmpeg and hardware acceleration on a Pi4 when using a large resolution camera for the detect role. Changing the gpu_mem
parameter didn't have an effect, either. I had to use a lower resolution substream and that solved the issue.
Edit: The setup has 3 cams with detect roles at 640x480 and clips role at 4k. Seems like an ffmpeg issue more than a Frigate one.
@blakeblackshear Yes, RPi4, but I'm not sure how to check which wersion. However acceleration for 32bit raised errors always, and 64bit settings for hwaccel_args were working for 2 streams, and failing for more.
Glad I saw this, just set this up last night in my Pi4 kubernetes cluster using helm. I have node affinity enabled as a Coral TPU installed on this node. The node has 8gb of RAM, but keeping getting ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
errors.
width: 3072
height: 1728
fps: 5
I assume the camera's resolution is too high, and I should go off a lower resolution stream off the camera?
EDIT: Also I do believe it's seeing the TPU:
frigate.mqtt INFO : MQTT connected
detector.coral INFO : Starting detection process: 34
frigate.edgetpu INFO : Attempting to load TPU as usb
frigate.edgetpu INFO : TPU found
EDIT2: Nevermind didn't work, dropped the stream do the 640x480 substream and set the width/height, and still having the error and it terminating.
I am trying to use hardware acceleration on a Raspberry Pi 4 (it is a model B). I have put the following configuration parameters into the frigate.yml file as per the documentation: ``ffmpeg: hwaccel_args:
I have turned off protection mode. However, when I try and run Frigate my cameras no longer work. The Frigate log shows no errors but the HomeAssistant log says:
Logger: custom_components.frigate
Source: custom_components/frigate/api.py:90
Integration: Frigate (documentation, issues)
First occurred: 2:59:59 PM (4 occurrences)
Last logged: 3:00:14 PMError fetching information from http://ccab4aaf-frigate:5000/api/stats - Server disconnected Error fetching information from http://ccab4aaf-frigate:5000/api/stats - 502, message='Bad Gateway', url=URL('http://ccab4aaf-frigate:5000/api/stats')``
Any ideas?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I do not believe this issue is solved because like @lukaszolek and @mloebl I cannot get hwaccel to work on the Pi4 (64bit with 4GByte memory). However, I was able to get 7 cameras working with Frigate without hardware acceleration by dropping the frame rate on four of my cameras (which are configurable via a web interface - Sercomm iCamera2) to 5 fps. Their resolution is 1280x720 (which I did not change). My other 3 cameras are Wyze cameras with the RTSP firmware and there is no way to change their resolution or fps. Despite the fact that the Wyze cameras are working (I am able to detect people, record clips and see live streaming) I am getting errors from the 3 Wyze cameras (but not the Sercomm ones) as follows:
ffmpeg.Camera7_Wyze_2.detect ERROR : Guessed Channel Layout for Input Stream #0.1 : mono
ffmpeg.Camera7_Wyze_2.detect ERROR : [h264 @ 0x558d4809e0] cabac decode of qscale diff failed at 68 59
ffmpeg.Camera7_Wyze_2.detect ERROR : [h264 @ 0x558d4809e0] error while decoding MB 68 59, bytestream -4
ffmpeg.Camera7_Wyze_2.detect ERROR : rtsp://****:****@10.0.0.126/live: corrupt decoded frame in stream 0
ffmpeg.Camera7_Wyze_2.detect ERROR : [flv @ 0x558d4b39e0] Failed to update header with correct duration.
ffmpeg.Camera7_Wyze_2.detect ERROR : [flv @ 0x558d4b39e0] Failed to update header with correct filesize.
I would really love to solve this.
@lukaszolek can you try adding -fflags nobuffer
to your hwaccel args like this:
ffmpeg:
hwaccel_args:
- -c:v
- h264_v4l2m2m
- -fflags
- nobuffer
I am curious if that will reduce the gpu_mem usage for each camera.
I did figure out my problem was not frigate/ffmpeg related, but couldn't find this issue to update it when I searched for it. TLDR: Was a network issue causing my issues.
In my case I had my cameras behind a linux box acting as a quick and dirty router to access cameras behind it on a different subnet (it has 2 nics and was the nvr box for the cameras). A few years ago had initially wanted to isolate the cameras to their own subnet off the regular network, but as time evolved and issues with the nvr and it's api access, I wanted direct access to the cameras to work with HA. In the end it appears I had some sort of misconfiguration causing routing to flake a bit. I hadn't noticed this as "seemed to be working fine" until I did some basic pings and saw some redirect errors on responses. I moved the cameras to an unused port on my firewall so I could isolate them there, and my ffpmeg errors went away. It's been very stable and no errors at all in my frigate logs anymore. I'm still running it on a PI4 in k8s, but now a k3s cluster with a Google Coral USB TPU.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi,
I have now a successful setup of 2 cameras to my frigate. Needed to set /boot/config.txt gpu_mem to 512.
There are no issues in frigate log:
These are two streams of video: h264 (High), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 3 fps, 50 tbr, 90k tbn, 6 tbc
However, once I try to add third stream to my configuration (I have 6 cameras in total) frigate starts throwing errors:
I tried to raise gpu_mem higher, but then the Raspberry doesn't start properly (is stuck during boot).
Is there any way to use hwaccel_args to optimize the memory needed by ffmpeg?