frigate
frigate copied to clipboard
[Support]: High CPU usage simply adding second cam
Describe the problem you are having
Here again.... A strange problem is driving me crazy. I own a mini PC with Pentium J5040 al 16GB of ram, and i thought it would have been enough for 16 cams recording, but i have my CPU with very high usage just with second cam...
FIRST CONFIG: I have CAM 1 configured like attached file, and CPU stays, let's say, al 10% (i have also Home Assistant and some other things). If i add CAM 2 (same cam as cam 1), configured as attached, my CPU makes a jump of +25%.... Only for recording??? I thought that with detect enable set to "false" the only work would have been record direct stream and pass-thru RTMP stream, not so much.... And here the strange part (after many tries)....
SECOND CONFIG: Cam 1 configured same way. If i enable in CAM 2 the second stream (it was not enabled since i didnt't need it, ot at least this was what i thought...) and i: 1-put "detect" role on second low res stream and... 2-leave detect enabled "false" (like in first configuration).... CPU load is only 2-3% more!!!! What?
So my question is: why it seems that ffmpeg goes crazy (i see it with command "top -i") in first config, while adding second cam, and even third, with second config my CPU goes from 10 to 13%? What am i missing again? :-P Is always necessary an active low res sub stream with a detect role disabled? Thanks!!!
Version
0.11.1-2eada21
Frigate config file
mqtt:
host:
port:
topic_prefix: frigate
client_id: frigate
user:
password:
stats_interval: 120
detectors:
cpu:
type: cpu
num_threads: 1
ffmpeg:
hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
cameras:
# cam 1
cam1:
ffmpeg:
inputs:
- path: rtsp://admin:xxxxxxxx@xxxxxxxxxxxxx:554/cam/realmonitor?channel=1&subtype=0
roles:
- record
- rtmp
- path: rtsp://admin:xxxxxxxx@xxxxxxxxxxxxx:554/cam/realmonitor?channel=1&subtype=1
roles:
- detect
detect:
width: 854
height: 480
fps: 5
motion:
mask:
- 0,0,0,102,520,99,520,143,854,247,854,0
objects:
track:
- person
filters:
person:
threshold: 0.6
rtmp:
enabled: true
record:
enabled: true
expire_interval: 60
retain:
days: 10
mode: all
snapshots:
enabled: true
timestamp: false
bounding_box: true
retain:
default: 3
# cam 2
cam2:
ffmpeg:
inputs:
- path: rtsp://admin:xxxxxxxx@xxxxxxxxxxxx:554/cam/realmonitor?channel=1&subtype=0
roles:
- record
- rtmp
# - path: rtsp://admin:xxxxxxxxx@xxxxxxxxxxxx:554/cam/realmonitor?channel=1&subtype=1
# roles:
# - detect
detect:
enabled: false
# width: 854
# height: 480
# fps: 5
# objects:
# track:
# - person
# filters:
# person:
# threshold: 0.6
rtmp:
enabled: true
record:
enabled: true
expire_interval: 60
retain:
days: 10
mode: all
# snapshots:
# enabled: true
# timestamp: false
# bounding_box: true
# retain:
# default: 3
Relevant log output
.
FFprobe output from your camera
.
Frigate stats
No response
Operating system
HassOS
Install method
Docker CLI
Coral version
CPU (no coral)
Network connection
Wired
Camera make and model
Imou IPC-G22
Any other information that may be helpful
No response
whatever detect -> width / height
is set to, the detect stream will be resized to that. If you provide nothing this means that the default values of `720 / 1080 will be used.
Resizing the stream takes considerable CPU work, most likely you are setting the wrong size (or leaving it commented out) in which case the stream is being resized and using much more CPU
For example, I'd be surprised if 854x480 was the native resolution of the cam_1 substream
Ok, but my goal is to detect (and record and RTMP) only in CAM 1, and do only recordings and RTMP in all other CAMs.... How can i completely disable detect (and resize) for cam 2, 3....?
Question 2: i've set detect "width" in cam 1 in order to correct wrong aspect ratio of 640x480 stretched to 4:3 of the sub stream... But why now also cam 2 and 3 are 16:9? They are
detect:
enabled: false
# width: 854
# height: 480
# fps: 5
So they should be 4:3..... or is enough to set width in one cam to affect also others?
Setting width on one camera will not affect others. This will also use more cpu resources.
There is also no way to disable the detect feed (you can disable object detection, but not the detect feed itself) since this is used for the live view, motion detection, etc.
So detect role and object detection are not the same...... Ans a sub stream is always needed for less CPU usage.... Or not?
So detect role and object detection are not the same......
the detect role is used for object detection, but there is currently no way to turn it off (even if object detection is off)
Ans a sub stream is always needed for less CPU usage.... Or not?
sub streams are recommended for reducing CPU usage of motion detection (which is needed for object detection and for record retention depending on your configuration)
And this part of docs
detect: "#" Optional: width of the frame for the input with the detect role (default: shown below) width: 1280 "#" Optional: height of the frame for the input with the detect role (default: shown below) height: 720
is related to object detection or detect stream? I think the second....
If i have some cams with a main stream of 4MP and sub stream 640x480, what is best setting in order to:
- have object detection only on cam 1
- have RTMP and recording at max res in CAM1+2+3....?
With less CPU usage obviously?
Now, without modifications in config, i think Frigate is resizing sub streams of CAM 1+2+3 from 640x480 to 1280x720.... or not? This is good for aspect ratio (image is not stretched), but adding cams 4, 5, 6.... and so on perhaps will be too heavy for my CPU...
is related to object detection or detect stream? I think the second....
These are mutually inclusive. The width/height is for the detect stream which is used for object detection so really the answer is it is relevant for both.
Now, without modifications in config, i think Frigate is resizing sub streams of CAM 1+2+3 from 640x480 to 1280x720.... or not?
Set their native resolution in detect -> width / height since there's no reason to try to correct the aspect ratio.
I see similar behaviour here so thank you @NickM-27 for the explanations.
FWIW, I want to add more cameras as 'record only' (no detection thread, no ffmpeg resize thread, no birdseye, etc) as these cameras have their own motion/object detection. I simply want to integrate recordings into Frigate by taking motion/object signal from the cameras and start recording in Frigate via API (awaiting #1063). Basically I want to offload motion/object detection those cameras that provide this to reduce load on the host running Frigate.
Guess I'm too early giving this a go, but can we assume that 'record only' will be supported with #1063?
Guess I'm too early giving this a go, but can we assume that 'record only' will be supported with #1063?
No, the ability to trigger recordings / snapshots via API is completely unrelated to having the detect stream optional (as far as implementing the feature goes)
https://github.com/blakeblackshear/frigate/issues/1911 is what would bring the ability to only record and not have detect.
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.