Description
Common config issues causing higher than expected CPU load:
We get this question pretty often. While object detection is a considerable load on Frigate, there are other loads as well:
- Decoding the video stream to run motion & object detection
- Other modifications like resizing or filtering the stream (which runs on the CPU)
- Calculating motion detection (which runs on the CPU)
Using hwaccel to decode the stream is always highly recommended:
As is explained in the docs decompressing video streams takes a significant amount of CPU power. Video compression uses key frames (also known as I-frames) to send a full frame in the video stream. The following frames only include the difference from the key frame, and the CPU has to compile each frame by merging the differences with the key frame. More detailed explanation. Higher resolutions and frame rates mean more processing power is needed to decode the video stream, so try and set them on the camera to avoid unnecessary decoding work.
Please see the hardware acceleration docs for how to setup hardware acceleration for your GPU.
Poorly configured camera detect config:
It is important to properly set your cameras detect config
Frigate will resize the frames from the decoded camera stream to whatever is set in detect -> width / height
unless it is the same size as the actual stream.
This means if you camera is 1280 x 960
and your detect config is:
detect:
width: 1080
height: 720
then frigate will resize the frames to 1080 x 720
which will use a non-negligible amount of CPU to do. This is why it is recommended to run detect on the actual size of your stream.
NOTE: The default detect config is 1080 x 720 so you always need to set it to exactly what it is.
Motion detection:
Motion detection is run on the CPU. The higher the resolution of the stream, the more work it is to detect motion frame to frame. This is one of the reasons why using high resolutions is discouraged.
It is also important to add motion masks to places likely to not have objects like trees, skylines, etc.
NOTE: Motion masks are not meant to block out actual objects, do not use them for this.