Frigate High CPU

I’ve had frigate for a while now and recently just chaged my config to use go2rtc but I’m getting constant high CPU usage between 80%-99%.
I have 4 cameras with average CPU usage like below:
ffmpeg: 17%
capture: 6%
detect: 3%

Hardware

  • RPI4 8GB
  • Coral USB
  • Samsung T7 1TB SSD
  • Dahua cameras

I am using Home Assistant OS and my sub stream is set to the correct resolution with AAC audio.

Can anyone help figure out what may be causing this?

mqtt:
  host: 192.168.1.118
  user: mqtt-user
  password: password

ffmpeg:
  hwaccel_args: preset-rpi-64-h264
    
go2rtc:
  streams:
    WALKWAY_SUB: # <- for RTSP streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
    WALKWAY: # <- for RTSP streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
    FRONT_DOOR_SUB: # <- for other streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
    FRONT_DOOR: # <- for other streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
    DRIVEWAY_LEFT_SUB: # <- for RTSP streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
    DRIVEWAY_LEFT: # <- for RTSP streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
    DRIVEWAY_RIGHT_SUB: # <- for other streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
    DRIVEWAY_RIGHT: # <- for other streams
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0

cameras:
  WALKWAY:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://192.168.1.118:8554/WALKWAY_SUB
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://192.168.1.118:8554/WALKWAY
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 0,0,640,0,640,92,0,252
    objects:
      track:
        - person
        - dog
        - bicycle
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 

  FRONT_DOOR:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://192.168.1.118:8554/FRONT_DOOR_SUB
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://192.168.1.118:8554/FRONT_DOOR
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 117,57,255,236,401,123,521,200,640,170,640,0,136,0,0,0,46,120
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - bicycle
    snapshots:
      enabled: True
      timestamp: false
      bounding_box: True
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 

  DRIVEWAY_LEFT:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://192.168.1.118:8554/DRIVEWAY_LEFT_SUB
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://192.168.1.118:8554/DRIVEWAY_LEFT
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 640,242,497,197,503,79,430,67,116,115,0,166,0,0,341,0,640,0
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - bicycle
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: True
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 

  DRIVEWAY_RIGHT:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://192.168.1.118:8554/DRIVEWAY_RIGHT_SUB
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://192.168.1.118:8554/DRIVEWAY_RIGHT
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 0,0,640,0,640,139,438,71,243,133,0,156
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - bicycle
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 


detectors:
  coral:
    type: edgetpu
    device: usb

I would suggest only restreaming the streams that you are going to use elsewhere, restreaming still uses CPU and there is no point if it is not going to be used elsewhere.

So should I be removing all go2rtc code

go2rtc:
streams:
WALKWAY_SUB: # ← for RTSP streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
WALKWAY: # ← for RTSP streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
FRONT_DOOR_SUB: # ← for other streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
FRONT_DOOR: # ← for other streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
DRIVEWAY_LEFT_SUB: # ← for RTSP streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
DRIVEWAY_LEFT: # ← for RTSP streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
DRIVEWAY_RIGHT_SUB: # ← for other streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
DRIVEWAY_RIGHT: # ← for other streams
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0

I removed

input_args: preset-rtsp-restream

from all cameras but nothing has changed.

Edit:
I have tried removing all go2rtc code and the cpu usage was the same.
The only thing that made a difference is when I remove full stream recording the cpu sits at around 30%

mqtt:
  host: 192.168.1.118
  user: mqtt-user
  password: password

ffmpeg:
  hwaccel_args: preset-rpi-64-h264

cameras:
  WALKWAY:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 0,0,640,0,640,92,0,252
    objects:
      track:
        - person
        - dog
        - bicycle
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 

  FRONT_DOOR:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 117,57,255,236,401,123,521,200,640,170,640,0,136,0,0,0,46,120
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - bicycle
    snapshots:
      enabled: True
      timestamp: false
      bounding_box: True
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 

  DRIVEWAY_LEFT:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 640,242,497,197,503,79,430,67,116,115,0,166,0,0,341,0,640,0
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - bicycle
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: True
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 

  DRIVEWAY_RIGHT:
    ffmpeg:
      hwaccel_args: preset-rpi-64-h264
      inputs:
        - path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 0,0,640,0,640,139,438,71,243,133,0,156
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - bicycle
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      crop: False
      retain:
        default: 120
    record:
      enabled: true
      events:
        pre_capture: 3
        post_capture: 3
        retain:
          default: 120
          mode: active_objects 


detectors:
  coral:
    type: edgetpu
    device: usb

I would suggest using different streams for recording and detect Getting started | Frigate

I did that prior to this last code. CPU still sat in the 70% range.

recording uses very little CPU usage so something must’ve not been correct

That’s what I’m trying to figure out with no success. Do you know if there is a way I can see exactly what is using up the CPU with HAOS on a RPi?

you can run htop

htop returns “command not found” on terminal in HA

Can I get any help on this?