[Config Support]: Restreaming causing jump in CPU #16102
-
Describe the problem you are havingI am running Frigate in a Docker container on a Synology DS 1522+. I'm running 3 Hikvision cameras with 2 motion detection Zones on one camera. I am also using a USB Coral dongle. I am running detect at 6fps, 640x480, which is the native resolution of the low-res stream. I am using the high-res stream for the record role only. I understand that my CPU (Ryzen R1600) is incompatible with hwaccel settings, so I have come to accept roughly 15% CPU usage and a handful of errors when playing back video (such as [h264 @ 0x7f2d240f0780] error while decoding MB 57 69, bytestream -11). I have successfully set up go2rtc section in my config file, but when I do that my CPU usage goes to 50-60% and my recorded videos get extremely glitchy. Everything seems to work otherwise, but it's very slow. If I am only restreaming the high- and low-res streams from each camera, can someone help me to understand why my CPU usage triples? Keep in mind I am already using those streams in the record and detect roles already. Basically I'm trying to understand if this is expected go2rtc behavior so that I know if I should continue to pursue troubleshooting, or just keep my settings as-is. Version0.14.1-f4f3cfa Frigate config filemqtt:
enabled: true
host: 192.168.1.110
port: 1883
user: [USER]
password: [PASSWORD]
topic_prefix: frigate
ffmpeg:
# hwaccel_args: preset-vaapi
input_args:
- -rtsp_transport
- tcp
detectors: # <---- add detectors
coral:
type: edgetpu
device: usb
logger:
default: info
logs:
frigate.event: debug
#go2rtc:
# streams:
# front_porch:
# - rtsp://[USER]:[PASSWORD]@192.168.1.21:554/Streaming/channels/101
# front_porch_sub:
# - rtsp://[USER]:[PASSWORD]@192.168.1.21:554/Streaming/channels/102
# driveway:
# - rtsp://[USER]:[PASSWORD]@192.168.1.22:554/Streaming/channels/101
# driveway_sub:
# - rtsp://[USER]:[PASSWORD]@192.168.1.22:554/Streaming/channels/102
# back_porch:
# - rtsp://[USER]:[PASSWORD]@192.168.1.23:554/Streaming/channels/101
# back_porch_sub:
# - rtsp://[USER]:[PASSWORD]@192.168.1.23:554/Streaming/channels/102
detect:
width: 640
height: 480
fps: 6
objects:
track:
- person
- bicycle
- car
- bus
- motorcycle
- cat
- dog
- bird
filters:
person:
min_score: 0.6
threshold: 0.7
record:
enabled: true
retain:
days: 7
mode: motion
events:
retain:
default: 30
mode: active_objects
cameras:
front_porch: # <------ Name the camera
enabled: true
ffmpeg:
inputs:
- path: rtsp://[USER]:[PASSWORD]@192.168.1.21:554/Streaming/Channels/2 # <----- The stream you want to use for detection
#input_args: preset-rtsp-restream
roles:
- detect
- path: rtsp://[USER]:[PASSWORD]@192.168.1.21:554/Streaming/Channels/1
#input_args: preset-rtsp-restream
roles:
- record
detect:
enabled: true # <---- disable detection until you have a working camera feed
record:
enabled: true
motion:
mask:
- 0.035,0.02,0.702,0.024,0.702,0.101,0.034,0.098
- 1,0.341,0.889,0.331,0.811,0.576,0.795,0.759,0.853,1,1,1
review:
alerts:
labels:
- person
detections:
labels:
- cat
- dog
- bird
back_porch: # <------ Name the camera
enabled: true
ffmpeg:
inputs:
- path: rtsp://[USER]:[PASSWORD]@192.168.1.23:554/Streaming/Channels/2 # <----- The stream you want to use for detection
#input_args: preset-rtsp-restream
roles:
- detect
- path: rtsp://[USER]:[PASSWORD]@192.168.1.23:554/Streaming/Channels/1
#input_args: preset-rtsp-restream
roles:
- record
detect:
enabled: true # <---- disable detection until you have a working camera feed
record:
enabled: true
motion:
mask:
- 0.037,0.029,0.705,0.028,0.704,0.098,0.035,0.096
- 0.64,0.228,0.693,0.411,0.787,0.516,0.888,0.616,1,0.709,1,0.118,0.959,0.11,0.788,0.088,0.68,0.138
- 0.369,0.02,0.446,0,0.432,0.289,0.362,0.336
threshold: 30
contour_area: 15
improve_contrast: 'true'
review:
alerts:
labels:
- person
detections:
labels:
- cat
- dog
- bird
objects:
filters:
person:
mask: 0.933,0.672,0.93,0.54,1,0.547,1,0.726
driveway: # <------ Name the camera
enabled: true
ffmpeg:
inputs:
- path: rtsp://[USER]:[PASSWORD]@192.168.1.22:554/Streaming/Channels/2 # <----- The stream you want to use for detection
#input_args: preset-rtsp-restream
roles:
- detect
- path: rtsp://[USER]:[PASSWORD]@192.168.1.22:554/Streaming/Channels/1
#input_args: preset-rtsp-restream
roles:
- record
detect:
enabled: true # <---- disable detection until you have a working camera feed
record:
enabled: true
motion:
mask: 0.035,0.024,0.712,0.028,0.709,0.096,0.032,0.092
threshold: 40
contour_area: 25
improve_contrast: 'true'
zones:
street:
coordinates: 0.228,0.472,0.571,0.422,1,0.414,1,0.156,0,0.155,0,0.508
loitering_time: 0
inertia: 3
objects:
- car
- person
- bus
- bicycle
- motorcycle
drive:
coordinates: 0,1,0,0.513,0.229,0.475,0.57,0.426,0.694,0.422,1,0.416,1,1
loitering_time: 0
inertia: 3
objects:
- car
- person
review:
alerts:
required_zones: drive
version: 0.14 Relevant Frigate log output
Relevant go2rtc log outputn/a Frigate stats{"cameras":{"back_porch":{"audio_dBFS":0.0,"audio_rms":0.0,"camera_fps":6.0,"capture_pid":431,"detection_enabled":true,"detection_fps":0.1,"ffmpeg_pid":30022,"pid":428,"process_fps":6.0,"skipped_fps":0.0},"driveway":{"audio_dBFS":0.0,"audio_rms":0.0,"camera_fps":6.1,"capture_pid":433,"detection_enabled":true,"detection_fps":0.3,"ffmpeg_pid":449,"pid":429,"process_fps":6.1,"skipped_fps":0.0},"front_porch":{"audio_dBFS":0.0,"audio_rms":0.0,"camera_fps":6.0,"capture_pid":430,"detection_enabled":true,"detection_fps":0.0,"ffmpeg_pid":443,"pid":427,"process_fps":6.0,"skipped_fps":0.0}},"cpu_usages":{"1":{"cmdline":"/package/admin/s6/command/s6-svscan -d4 -- /run/service","cpu":"0.0","cpu_average":"0","mem":"0.0"},"110":{"cmdline":"/usr/local/go2rtc/bin/go2rtc -config=/dev/shm/go2rtc.yaml","cpu":"0.0","cpu_average":"0","mem":"0.1"},"119":{"cmdline":"bash ./run.user go2rtc-healthcheck","cpu":"0.0","cpu_average":"0","mem":"0.0"},"125":{"cmdline":"python3 -u -m frigate","cpu":"5.7","cpu_average":"3","mem":"5.2"},"135":{"cmdline":"nginx: master process nginx","cpu":"0.0","cpu_average":"0","mem":"0.1"},"15":{"cmdline":"s6-supervise s6-linux-init-shutdownd","cpu":"0.0","cpu_average":"0","mem":"0.0"},"162":{"cmdline":"nginx: worker process","cpu":"0.1","cpu_average":"0","mem":"0.1"},"163":{"cmdline":"nginx: worker process","cpu":"0.0","cpu_average":"0","mem":"0.1"},"164":{"cmdline":"nginx: worker process","cpu":"0.0","cpu_average":"0","mem":"0.1"},"165":{"cmdline":"nginx: worker process","cpu":"0.1","cpu_average":"0","mem":"0.1"},"166":{"cmdline":"nginx: cache manager process","cpu":"0.0","cpu_average":"0","mem":"0.0"},"21":{"cmdline":"/package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B","cpu":"0.0","cpu_average":"0","mem":"0.0"},"23622":{"cmdline":"sleep 60","cpu":"0.0","cpu_average":"0","mem":"0.0"},"23742":{"cmdline":"sleep 30s","cpu":"0.0","cpu_average":"0","mem":"0.0"},"24":{"cmdline":"s6-supervise s6rc-oneshot-runner","cpu":"0.0","cpu_average":"0","mem":"0.0"},"25":{"cmdline":"s6-supervise s6rc-fdholder","cpu":"0.0","cpu_average":"0","mem":"0.0"},"26":{"cmdline":"s6-supervise certsync","cpu":"0.0","cpu_average":"0","mem":"0.0"},"27":{"cmdline":"s6-supervise certsync-log","cpu":"0.0","cpu_average":"0","mem":"0.0"},"28":{"cmdline":"s6-supervise frigate","cpu":"0.0","cpu_average":"0","mem":"0.0"},"29":{"cmdline":"s6-supervise frigate-log","cpu":"0.0","cpu_average":"0","mem":"0.0"},"29483":{"cmdline":"/usr/bin/python3 -c from multiprocessing.resource_tracker import main;main(50)","cpu":"0.0","cpu_average":"0","mem":"0.0"},"299":{"cmdline":"bash ./run.user certsync","cpu":"0.0","cpu_average":"0","mem":"0.0"},"30":{"cmdline":"s6-supervise go2rtc","cpu":"0.0","cpu_average":"0","mem":"0.0"},"30022":{"cmdline":"ffmpeg -hide_banner -loglevel warning -threads 2 -rtsp_transport tcp -i rtsp://*:*@192.168.1.23:554/Streaming/Channels/2 -r 6 -vf fps=6,scale=640:480 -threads 2 -f rawvideo -pix_fmt yuv420p pipe:","cpu":"3.5","cpu_average":"3","mem":"0.1"},"31":{"cmdline":"s6-supervise go2rtc-healthcheck","cpu":"0.0","cpu_average":"0","mem":"0.0"},"32":{"cmdline":"s6-supervise go2rtc-log","cpu":"0.0","cpu_average":"0","mem":"0.0"},"33":{"cmdline":"s6-supervise nginx","cpu":"0.0","cpu_average":"0","mem":"0.0"},"34":{"cmdline":"s6-supervise nginx-log","cpu":"0.0","cpu_average":"0","mem":"0.0"},"358":{"cmdline":"frigate.logger ","cpu":"0.0","cpu_average":"0","mem":"0.8"},"365":{"cmdline":"frigate.recording_manager","cpu":"7.0","cpu_average":"4","mem":"1.7"},"366":{"cmdline":"frigate.review_segment_manager","cpu":"0.5","cpu_average":"0","mem":"0.9"},"393":{"cmdline":"/usr/bin/python3 -c from multiprocessing.resource_tracker import main;main(61)","cpu":"0.3","cpu_average":"0","mem":"0.0"},"394":{"cmdline":"frigate.detector.coral","cpu":"0.1","cpu_average":"0","mem":"1.0"},"395":{"cmdline":"frigate.output ","cpu":"1.2","cpu_average":"1","mem":"1.1"},"401":{"cmdline":"ffmpeg -threads 1 -f rawvideo -pix_fmt yuv420p -video_size 640x480 -i pipe: -threads 1 -f mpegts -s 960x720 -codec:v mpeg1video -q 8 -bf 0 pipe:","cpu":"0.0","cpu_average":"0","mem":"0.0"},"406":{"cmdline":"ffmpeg -threads 1 -f rawvideo -pix_fmt yuv420p -video_size 640x480 -i pipe: -threads 1 -f mpegts -s 960x720 -codec:v mpeg1video -q 8 -bf 0 pipe:","cpu":"0.0","cpu_average":"0","mem":"0.2"},"411":{"cmdline":"ffmpeg -threads 1 -f rawvideo -pix_fmt yuv420p -video_size 640x480 -i pipe: -threads 1 -f mpegts -s 960x720 -codec:v mpeg1video -q 8 -bf 0 pipe:","cpu":"0.0","cpu_average":"0","mem":"0.1"},"423":{"cmdline":"ffmpeg -threads 1 -f rawvideo -pix_fmt yuv420p -video_size 1280x720 -i pipe: -threads 1 -f mpegts -s 1280x720 -codec:v mpeg1video -q 8 -bf 0 pipe:","cpu":"0.0","cpu_average":"0","mem":"0.0"},"427":{"cmdline":"frigate.process:front_porch","cpu":"1.4","cpu_average":"1","mem":"1.0"},"428":{"cmdline":"frigate.process:back_porch","cpu":"1.5","cpu_average":"1","mem":"1.0"},"429":{"cmdline":"frigate.process:driveway","cpu":"2.1","cpu_average":"2","mem":"1.1"},"430":{"cmdline":"frigate.capture:front_porch","cpu":"0.7","cpu_average":"0","mem":"0.9"},"431":{"cmdline":"frigate.capture:back_porch","cpu":"0.6","cpu_average":"0","mem":"0.9"},"433":{"cmdline":"frigate.capture:driveway","cpu":"0.6","cpu_average":"0","mem":"0.9"},"443":{"cmdline":"ffmpeg -hide_banner -loglevel warning -threads 2 -rtsp_transport tcp -i rtsp://*:*@192.168.1.21:554/Streaming/Channels/2 -r 6 -vf fps=6,scale=640:480 -threads 2 -f rawvideo -pix_fmt yuv420p pipe:","cpu":"2.5","cpu_average":"3","mem":"0.1"},"449":{"cmdline":"ffmpeg -hide_banner -loglevel warning -threads 2 -rtsp_transport tcp -i rtsp://*:*@192.168.1.22:554/Streaming/Channels/2 -r 6 -vf fps=6,scale=640:480 -threads 2 -f rawvideo -pix_fmt yuv420p pipe:","cpu":"5.5","cpu_average":"6","mem":"0.1"},"45":{"cmdline":"/package/admin/s6-2.11.3.2/command/s6-fdholderd -1 -i data/rules","cpu":"0.0","cpu_average":"0","mem":"0.0"},"451":{"cmdline":"ffmpeg -hide_banner -loglevel warning -threads 2 -rtsp_transport tcp -i rtsp://*:*@192.168.1.21:554/Streaming/Channels/1 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/front_porch@%Y%m%d%H%M%S%z.mp4","cpu":"1.9","cpu_average":"1","mem":"0.1"},"452":{"cmdline":"ffmpeg -hide_banner -loglevel warning -threads 2 -rtsp_transport tcp -i rtsp://*:*@192.168.1.23:554/Streaming/Channels/1 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/back_porch@%Y%m%d%H%M%S%z.mp4","cpu":"1.7","cpu_average":"1","mem":"0.1"},"455":{"cmdline":"ffmpeg -hide_banner -loglevel warning -threads 2 -rtsp_transport tcp -i rtsp://*:*@192.168.1.22:554/Streaming/Channels/1 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/driveway@%Y%m%d%H%M%S%z.mp4","cpu":"1.6","cpu_average":"1","mem":"0.1"},"46":{"cmdline":"/package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/command/s6-sudod -t 30000 -- /package/admin/s6-rc/command/s6-rc-oneshot-run -l ../.. --","cpu":"0.0","cpu_average":"0","mem":"0.0"},"84":{"cmdline":"s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/nginx","cpu":"0.0","cpu_average":"0","mem":"0.0"},"86":{"cmdline":"s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/go2rtc","cpu":"0.0","cpu_average":"0","mem":"0.0"},"88":{"cmdline":"s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/frigate","cpu":"0.0","cpu_average":"0","mem":"0.0"},"92":{"cmdline":"s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/certsync","cpu":"0.0","cpu_average":"0","mem":"0.0"},"frigate.full_system":{"cpu":"18.4","mem":"48.7"}},"detection_fps":0.4,"detectors":{"coral":{"detection_start":0.0,"inference_speed":8.37,"pid":394}},"processes":{"go2rtc":{"pid":110},"logger":{"pid":358},"recording":{"pid":365},"review_segment":{"pid":366}},"service":{"last_updated":1737659130,"latest_version":"0.14.1","storage":{"/dev/shm":{"free":55.2,"mount_type":"tmpfs","total":64.0,"used":8.8},"/media/frigate/clips":{"free":7932905.8,"mount_type":"btrfs","total":8162181.1,"used":229275.4},"/media/frigate/recordings":{"free":7932905.8,"mount_type":"btrfs","total":8162181.1,"used":229275.4},"/tmp/cache":{"free":923.9,"mount_type":"tmpfs","total":953.7,"used":29.8}},"temperatures":{},"uptime":302263,"version":"0.14.1-f4f3cfa"}} Operating systemOther Linux Install methodDocker Compose docker-compose file or Docker CLI commandversion: "3"
services:
#frigate [8121]
frigate:
container_name: frigate
privileged: true # this may not be necessary for all setups
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable
shm_size: "64mb" # update for your cameras based on calculation above
devices:
- /dev/bus/usb:/dev/bus/usb # Passes the USB Coral, needs to be modified for other versions
# #- /dev/apex_0:/dev/apex_0 # Passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
# #- /dev/video11:/dev/video11 # For Raspberry Pi 4B
# #- /dev/dri/renderD128:/dev/dri/renderD128 # For intel hwaccel, needs to be updated for your hardware
volumes:
- '/etc/localtime:/etc/localtime:ro'
- './frigate:/config'
- '/volume3/surveillance/frigate:/media/frigate'
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "8121:8971"
- "5000:5000" # Internal unauthenticated access. Expose carefully.
- "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp
- "8555:8555/udp" # WebRTC over udp
environment:
FRIGATE_RTSP_PASSWORD: "[PASSWORD]" Object DetectorCoral Screenshots of the Frigate UI's System metrics pagesAny other information that may be helpfulI am showing configs from my non-rtsp setup (15-20% CPU). If needed I can change the config and show what happens when I uncomment the rtsp settings. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
what resolution are your cameras? restreaming high resolution uses a decent amount of CPU, if you are only using them inside of frigate then there is no reason to restream both |
Beta Was this translation helpful? Give feedback.
Restreaming will always use additional CPU because it is additional work. The main advantage of restreaming is to reduce the load on the camera