[Frigate & RPi4] High CPU usage for FFmpeg

I am running Frigate on Raspberry Pi 4 with CPU detector.
The stats show that FFmpeg even uses more CPU than the detection.
Is it normal? I remember that hardware acceleration can be used for FFmpeg?

Setup

  • Add-on: Frigate (Full Access)
  • Camera: WebRTC camera via source type Hass
  • Frigate config (with bundled go2rtc):
mqtt:
  enabled: True

birdseye:
  enabled: False

ffmpeg:
  hwaccel_args:
    - -c:v:1
    - h264_v4l2m2m
  output_args:
    record: -f segment -segment_time 10 -segment_format mp4 -use_wallclock_as_timestamps 1 -strftime 1 -c:v copy -c:a copy
    rtmp: -c:v copy -c:a copy -f flv

rtmp:
  enabled: False

detect:
  width: 1920
  height: 1080
  fps: 5

objects:
  track:
    - person

record:
  enabled: True
  retain:
    days: 0
  events:
    pre_capture: 5
    post_capture: 5
    objects:
      - person
    required_zones:
      - driveway

snapshots:
  enabled: True
  timestamp: True
  required_zones:
    - driveway

go2rtc:
  streams:
    camera.garage_camera:
      - hass://supervisor?entity_id=camera.garage_camera
      - "ffmpeg:camera.garage_camera#audio=aac"

cameras:
  garage_camera:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/camera.garage_camera?video=copy&audio=aac
          roles:
            - detect
            - record
            - rtmp
    zones:
      driveway:
        coordinates: ...

This is normal for CPU detector

No amount of hardware acceleration will help on a RasPi. You need to get Google Coral to lower cpu usage.

It uses ffmpeg as part of detect when cpu only. If you use gpu work is offloaded to that. If Coral TPU, coral will be used.

You will struggle with frigate on an old pi, Probably even the new PI.

especially the new Pi because the new Pi does not even have h264 decoder in hardware

Wrong, negative…

The Coral can only be used for inference, means to detect object in jpeg pictures, made using ffmpeg prior from the video stream.
The ffmpeg uses the GPU, and it’s really not great and takes anyway 30% cpu at least, as it has to save pictures in a ram tempfs, even 5fps as default.
I coulnd’t get better.

Even 30fps, will be the same cpu.
Anyway even from 720p or 2180p, there is not much more cpu used.

to be clear that really depends on the GPU and CPU. If we are talking about an RPi then sure, but the GPU in the RPi 4 is very unpowered and the RPi 5 does not have an h264 hardware decoder.

Any modern Intel based platform like N100 will use < 5% CPU for ffmpeg when the GPU is setup correctly