Closed carlos-sarmiento closed 2 years ago
You're running detect on full 4k frames.
detect:
width: 3840
height: 2160
This is discouraged in the docs https://docs.frigate.video/guides/camera_setup#choosing-a-detect-resolution and 100% expected.
Running motion detection on 4K is computationally expensive and shown to not be helpful at all unless detecting very small objects (all regions are resized to 320x320 to do object detection, so resizing a higher resolution object means using a higher resolution is just a waste of CPU resources)
Thanks for the feedback. I updated my config to the following and the CPU problem improved but it is still pretty high. Would this be the correct configuration if I want to view and store the 4k footage but detect on a smaller resolution?
ffmpeg:
inputs:
- path: rtsp://4k_camera_url:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
roles:
- record
- rtmp
- path: rtsp://4k_camera_url:554/cam/realmonitor?channel=1&subtype=1&authbasic=64
roles:
- detect
detect: # this is the resolution of the second stream according to ffprobe
width: 704
height: 480
Yes that looks correct. A new htop would be helpful. What CPU do you have and have you verified hwaccel is working?
New HTOP:
How can I verify hwaccel
is working? Looked for instructions on the hw acceleration docs but couldn't find anything.
Also, my cameras are now being rendered on the UI using the lower resolution:
Before updating the config, it would show like this (screenshot taken using the old config)
The ffmpeg processes look better now actually so I don't think it's hwaccel related. You would verify with intel_gpu_top
if intel
As far as the UI goes, you'll want to adjust camera -> live -> height
to change that.
I'm not sure what more can be done to reduce CPU usage more, perhaps that number of cameras is taxing for the CPU. @blakeblackshear may have a better idea on the CPU usage
This is a screenshot of intel_gpu_top
. Since this computer has no UI installed, I assume the fact the GPU is seeing usage to mean frigate is using it.
Also, regarding the live view, the documentation says This must be less than or equal to the height of the detect stream.
which would mean frigate is using the lower resolution stream even though I've configured both record
and rtmp
to use the high resolution one. This intepretation seems right because both the stream on the frigate UI and on Home Assistant now show the lower resolution stream instead of the 4K. Am I understanding this behavior correctly?
The frigate live view uses the detect stream.
The home assistant camera.your_camera
entity uses the rtmp stream
I understand what you are saying, but it doesn't seem to be what I'm seeing in HA:
With the new config this is what I see on my dashboard:
This is how the same camera renders using the old config:
Should I file this as a separate issue?
Is this a live camera entity or the zone/object specific cameras that are a static image that updates? Snapshots including these would be from the detect stream.
The best way to understand what is driving CPU usage is to turn off features to see what is driving it up. You can disable detect for each camera to get a sense of the baseline CPU to just decode the stream and look for motion.
This is the live camera entity. Not the cameras that get created for detection (person, dog, etc.)
I tried disabling all my cameras and CPU usage went down, so I assume that the sheer number of cameras is what is driving the CPU.
I would suggest watching the debug view of each camera with the motion boxes overlays and seeing what is triggering motion and object detection. Your best bet is making sure you use motion masks to avoid running unnecessary detections from things like camera timestamps.
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.
Describe the problem you are having
I am running 8 cameras on Frigate on a computer with a coral module installed and I'm seeing my CPU pegged at 100% all the time. I haven't checked in a while, but I don't remember ever having the CPU usage so high when running frigate.
Here is a screenshot from HTOP running on the host
Version
0.10.1-83481AF
Frigate config file
Relevant log output
FFprobe output from your camera
Frigate stats
Operating system
Debian
Install method
Docker Compose
Coral version
USB
Network connection
Wired
Camera make and model
All Amcrest
Any other information that may be helpful
Docker container config (using Ansible)