frigate: [HW Accel Support]: High CPU Usage and Low FPS in Frigate on Orange Pi 5 Plus with RK3588

Describe the problem you are having

I am using an Orange Pi 5 Plus with 16GB RAM and running Armbian with kernel 5.10. In my Frigate configuration, I deliberately set ffmpeg to decode at 10 fps to reduce CPU load, even though my camera can transmit at 25 fps in 2K resolution. Despite this reduced frame rate, I am still encountering a substantial CPU overload, averaging around 50%. I suspect that the integrated NPU in the RK3588 is not being effectively utilized or might not be supported. As a novice in GNU Linux systems and a user of Frigate, I am looking for assistance to optimize my setup.

I’m afraid that when connecting 4 or more cameras, my mini PC may not cope image

Version

dev-8e41913-rk

Frigate config file

detectors:
  cpu1:
    type: cpu
    num_threads: 1

logger:
  default: debug
  logs:
    frigate.mqtt: error
    ffmpeg.my_camera: debug

mqtt:
  host: mosquitto
  user: user
  password: password

cameras:
  my_camera:
    ffmpeg:
      inputs:
        - path: rtsp://admin:admin@10.7.8.131/Streaming/Channels/101
          roles:
            - detect
    detect:
      fps: 10

record:
  enabled: True
  retain:
    days: 7
    mode: all
  events:
    retain:
      default: 14

docker-compose file or Docker CLI command

version: "3.9"

services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    stop_grace_period: 1s
#    image: sha256:359a8ae17ac7c6660007e7e790ce3772a7fc88d58e089cbfd67817231cc3f133
    image: ghcr.io/blakeblackshear/frigate:dev-8e41913-rk
#    image: ghcr.io/blakeblackshear/frigate:stable
    shm_size: "256mb" # update for your cameras based on calculation above
    devices:
      - /dev/mpp_service:/dev/mpp_service
      - /dev/dma_heap:/dev/dma_heap
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./config:/config
      - ./storage:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp
    environment:
      FRIGATE_RTSP_PASSWORD: "password"
    networks:
      - global

networks:
  global:
    external: true

Relevant log output

root@orangepi5-plus:~/docker/frigate# docker compose up
[+] Running 1/0
 ✔ Container frigate  Created                                                                                                                                                                               0.0s
Attaching to frigate
frigate  | s6-rc: info: service s6rc-fdholder: starting
frigate  | s6-rc: info: service s6rc-oneshot-runner: starting
frigate  | s6-rc: info: service s6rc-oneshot-runner successfully started
frigate  | s6-rc: info: service fix-attrs: starting
frigate  | s6-rc: info: service s6rc-fdholder successfully started
frigate  | s6-rc: info: service fix-attrs successfully started
frigate  | s6-rc: info: service legacy-cont-init: starting
frigate  | s6-rc: info: service legacy-cont-init successfully started
frigate  | s6-rc: info: service log-prepare: starting
frigate  | s6-rc: info: service log-prepare successfully started
frigate  | s6-rc: info: service nginx-log: starting
frigate  | s6-rc: info: service go2rtc-log: starting
frigate  | s6-rc: info: service frigate-log: starting
frigate  | s6-rc: info: service nginx-log successfully started
frigate  | s6-rc: info: service go2rtc-log successfully started
frigate  | s6-rc: info: service go2rtc: starting
frigate  | s6-rc: info: service frigate-log successfully started
frigate  | s6-rc: info: service go2rtc successfully started
frigate  | s6-rc: info: service go2rtc-healthcheck: starting
frigate  | s6-rc: info: service frigate: starting
frigate  | s6-rc: info: service go2rtc-healthcheck successfully started
frigate  | s6-rc: info: service frigate successfully started
frigate  | s6-rc: info: service nginx: starting
frigate  | 2024-01-04 09:08:55.720538888  [INFO] Preparing Frigate...
frigate  | 2024-01-04 09:08:55.721214673  [INFO] Preparing new go2rtc config...
frigate  | s6-rc: info: service nginx successfully started
frigate  | s6-rc: info: service legacy-services: starting
frigate  | 2024-01-04 09:08:55.728206434  [INFO] Starting NGINX...
frigate  | 2024-01-04 09:08:55.735362985  [INFO] Starting Frigate...
frigate  | s6-rc: info: service legacy-services successfully started
frigate  | 2024-01-04 09:08:56.198107784  [INFO] Starting go2rtc...
frigate  | 2024-01-04 09:08:56.289806837  09:08:56.289 INF go2rtc version 1.8.4 linux/arm64
frigate  | 2024-01-04 09:08:56.290847784  09:08:56.290 INF [api] listen addr=:1984
frigate  | 2024-01-04 09:08:56.290856826  09:08:56.290 INF [rtsp] listen addr=:8554
frigate  | 2024-01-04 09:08:56.291480986  09:08:56.291 INF [webrtc] listen addr=:8555
frigate  | 2024-01-04 09:08:57.318909073  2024/01/04 09:08:57 [error] 146#146: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.7.8.240, server: , request: "GET /ws HTTP/1.1", upstream: "http://127.0.0.1:5002/", host: "10.7.8.250:5000"
frigate  | 2024-01-04 09:08:57.318981989  10.7.8.240 - - [04/Jan/2024:09:08:57 +0000] "GET /ws HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" "-"
frigate  | 2024-01-04 09:08:57.344583350  [2024-01-04 09:08:57] frigate.app                    INFO    : Starting Frigate (0.13.0-8e41913)
frigate  | 2024-01-04 09:08:58.415885525  [2024-01-04 09:08:58] peewee_migrate.logs            INFO    : Starting migrations
frigate  | 2024-01-04 09:08:58.415924025  [2024-01-04 09:08:58] peewee                         DEBUG   : ('CREATE TABLE IF NOT EXISTS "migratehistory" ("id" INTEGER NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "migrated_at" DATETIME NOT NULL)', [])
frigate  | 2024-01-04 09:08:58.420920807  [2024-01-04 09:08:58] peewee                         DEBUG   : ('SELECT "t1"."id", "t1"."name", "t1"."migrated_at" FROM "migratehistory" AS "t1" ORDER BY "t1"."id"', [])
frigate  | 2024-01-04 09:08:58.428700935  [2024-01-04 09:08:58] peewee_migrate.logs            INFO    : There is nothing to migrate
frigate  | 2024-01-04 09:08:58.524643401  [2024-01-04 09:08:58] frigate.app                    INFO    : Recording process started: 461
frigate  | 2024-01-04 09:08:58.534327509  [2024-01-04 09:08:58] frigate.app                    INFO    : go2rtc process pid: 95
frigate  | 2024-01-04 09:08:58.535523330  [2024-01-04 09:08:58] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:08:58.562377969  [2024-01-04 09:08:58] frigate.comms.mqtt             DEBUG   : MQTT connected
frigate  | 2024-01-04 09:08:58.577152483  [2024-01-04 09:08:58] detector.cpu1                  INFO    : Starting detection process: 472
frigate  | 2024-01-04 09:08:58.585560855  [2024-01-04 09:08:58] frigate.app                    INFO    : Output process started: 474
frigate  | 2024-01-04 09:08:58.588083454  [2024-01-04 09:08:58] frigate.detectors              WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
frigate  | 2024-01-04 09:08:58.588647239  [2024-01-04 09:08:58] peewee.sqliteq                 DEBUG   : received query DELETE FROM "regions" WHERE NOT ("regions"."camera" IN (?))
frigate  | 2024-01-04 09:08:58.588908278  [2024-01-04 09:08:58] peewee                         DEBUG   : ('DELETE FROM "regions" WHERE NOT ("regions"."camera" IN (?))', ['my_camera'])
frigate  | 2024-01-04 09:08:58.589132276  [2024-01-04 09:08:58] peewee                         DEBUG   : ('SELECT "t1"."camera", "t1"."grid", "t1"."last_update" FROM "regions" AS "t1" WHERE ("t1"."camera" = ?) LIMIT ? OFFSET ?', ['my_camera', 1, 0])
frigate  | 2024-01-04 09:08:58.589348982  [2024-01-04 09:08:58] peewee                         DEBUG   : ('SELECT "t1"."id" FROM "event" AS "t1" WHERE ((("t1"."camera" = ?) AND (("t1"."false_positive" IS ?) OR ("t1"."false_positive" = ?))) AND ("t1"."start_time" > ?))', ['my_camera', None, False, 1704356260.122052])
frigate  | 2024-01-04 09:08:58.589640354  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : Found 2 new events for my_camera
frigate  | 2024-01-04 09:08:58.589724645  [2024-01-04 09:08:58] peewee                         DEBUG   : ('SELECT "t1"."camera", "t1"."source", "t1"."data" FROM "timeline" AS "t1" WHERE ("t1"."source_id" IN (?, ?)) LIMIT ?', ['1704356374.09081-j17n99', '1704356569.390252-2br3hj', 10000])
frigate  | 2024-01-04 09:08:58.593448315  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : Found 4 new entries for my_camera
frigate  | 2024-01-04 09:08:58.593543397  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.014880952380952384 mean: 0.33035714285714285
frigate  | 2024-01-04 09:08:58.593602313  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.0 mean: 0.37202380952380953
frigate  | 2024-01-04 09:08:58.593733270  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.15354726595116686 mean: 0.46329365079365076
frigate  | 2024-01-04 09:08:58.593740853  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.0 mean: 0.5520833333333334
frigate  | 2024-01-04 09:08:58.593931310  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.0342630136052924 mean: 0.3067956349206349
frigate  | 2024-01-04 09:08:58.594118850  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.0 mean: 0.49404761904761907
frigate  | 2024-01-04 09:08:58.594192057  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.0 mean: 0.43601190476190477
frigate  | 2024-01-04 09:08:58.594417513  [2024-01-04 09:08:58] frigate.util.object            DEBUG   : std dev: 0.0 mean: 0.3556547619047619
frigate  | 2024-01-04 09:08:58.594425388  [2024-01-04 09:08:58] peewee.sqliteq                 DEBUG   : received query INSERT INTO "regions" ("camera", "grid", "last_update") VALUES (?, json(?), ?) ON CONFLICT ("camera") DO UPDATE SET "camera" = ?, "grid" = json(?), "last_update" = ?
frigate  | 2024-01-04 09:08:58.594536220  [2024-01-04 09:08:58] peewee                         DEBUG   : ('INSERT INTO "regions" ("camera", "grid", "last_update") VALUES (?, json(?), ?) ON CONFLICT ("camera") DO UPDATE SET "camera" = ?, "grid" = json(?), "last_update" = ?', ['my_camera', '[[{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": [0.34523809523809523, 0.31547619047619047], "x": 3, "y": 4, "std_dev": 0.014880952380952384, "mean": 0.33035714285714285}, {"sizes": []}, {"sizes": [0.37202380952380953], "x": 3, "y": 6, "std_dev": 0.0, "mean": 0.37202380952380953}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": [0.6800595238095238, 0.36607142857142855, 0.34375], "x": 4, "y": 4, "std_dev": 0.15354726595116686, "mean": 0.46329365079365076}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": [0.5520833333333334], "x": 5, "y": 2, "std_dev": 0.0, "mean": 0.5520833333333334}, {"sizes": []}, {"sizes": [0.34077380952380953, 0.3020833333333333, 0.36160714285714285, 0.27529761904761907, 0.2961309523809524, 0.2648809523809524], "x": 5, "y": 4, "std_dev": 0.0342630136052924, "mean": 0.3067956349206349}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": [0.49404761904761907], "x": 6, "y": 1, "std_dev": 0.0, "mean": 0.49404761904761907}, {"sizes": []}, {"sizes": []}, {"sizes": [0.43601190476190477], "x": 6, "y": 4, "std_dev": 0.0, "mean": 0.43601190476190477}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": [0.3556547619047619], "x": 7, "y": 4, "std_dev": 0.0, "mean": 0.3556547619047619}, {"sizes": []}, {"sizes": []}, {"sizes": []}]]', 1704359338.588694, 'my_camera', '[[{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": [0.34523809523809523, 0.31547619047619047], "x": 3, "y": 4, "std_dev": 0.014880952380952384, "mean": 0.33035714285714285}, {"sizes": []}, {"sizes": [0.37202380952380953], "x": 3, "y": 6, "std_dev": 0.0, "mean": 0.37202380952380953}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": [0.6800595238095238, 0.36607142857142855, 0.34375], "x": 4, "y": 4, "std_dev": 0.15354726595116686, "mean": 0.46329365079365076}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": [0.5520833333333334], "x": 5, "y": 2, "std_dev": 0.0, "mean": 0.5520833333333334}, {"sizes": []}, {"sizes": [0.34077380952380953, 0.3020833333333333, 0.36160714285714285, 0.27529761904761907, 0.2961309523809524, 0.2648809523809524], "x": 5, "y": 4, "std_dev": 0.0342630136052924, "mean": 0.3067956349206349}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": [0.49404761904761907], "x": 6, "y": 1, "std_dev": 0.0, "mean": 0.49404761904761907}, {"sizes": []}, {"sizes": []}, {"sizes": [0.43601190476190477], "x": 6, "y": 4, "std_dev": 0.0, "mean": 0.43601190476190477}, {"sizes": []}, {"sizes": []}, {"sizes": []}], [{"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": []}, {"sizes": [0.3556547619047619], "x": 7, "y": 4, "std_dev": 0.0, "mean": 0.3556547619047619}, {"sizes": []}, {"sizes": []}, {"sizes": []}]]', 1704359338.588694])
frigate  | 2024-01-04 09:08:58.615504503  [2024-01-04 09:08:58] frigate.app                    INFO    : Camera processor started for my_camera: 480
frigate  | 2024-01-04 09:08:58.624478702  [2024-01-04 09:08:58] frigate.app                    INFO    : Capture process started for my_camera: 481
frigate  | 2024-01-04 09:08:58.630688222  [2024-01-04 09:08:58] peewee                         DEBUG   : ('SELECT COUNT(?) FROM "recordings" AS "t1" WHERE (("t1"."camera" = ?) AND ("t1"."segment_size" > ?))', ['*', 'my_camera', 0.0])
frigate  | 2024-01-04 09:08:58.634762179  [2024-01-04 09:08:58] urllib3.connectionpool         DEBUG   : Starting new HTTPS connection (1): api.github.com:443
frigate  | 2024-01-04 09:08:58.637532984  [2024-01-04 09:08:58] peewee                         DEBUG   : ('SELECT AVG("t1"."segment_size" / ("t1"."end_time" - "t1"."start_time")) FROM "recordings" AS "t1" WHERE (("t1"."camera" = ?) AND ("t1"."segment_size" > ?)) LIMIT ?', ['my_camera', 0.0, 100])
frigate  | 2024-01-04 09:08:58.639212092  [2024-01-04 09:08:58] frigate.storage                DEBUG   : my_camera has a bandwidth of 2735.48 MiB/hr.
frigate  | 2024-01-04 09:08:58.661341780  [2024-01-04 09:08:58] tzlocal                        DEBUG   : /etc/timezone found, contents:
frigate  | 2024-01-04 09:08:58.661345863   Etc/UTC
frigate  | 2024-01-04 09:08:58.661346738
frigate  | 2024-01-04 09:08:58.662273937  [2024-01-04 09:08:58] tzlocal                        DEBUG   : /etc/localtime found
frigate  | 2024-01-04 09:08:58.663663714  [2024-01-04 09:08:58] tzlocal                        DEBUG   : 2 found:
frigate  | 2024-01-04 09:08:58.663667797   {'/etc/timezone': 'Etc/UTC', '/etc/localtime is a symlink to': 'Etc/UTC'}
frigate  | 2024-01-04 09:08:58.976077193  [2024-01-04 09:08:58] urllib3.connectionpool         DEBUG   : https://api.github.com:443 "GET /repos/blakeblackshear/frigate/releases/latest HTTP/1.1" 200 1767
frigate  | 2024-01-04 09:08:59.056163948  [2024-01-04 09:08:59] peewee.sqliteq                 DEBUG   : received query UPDATE "event" SET "end_time" = ("event"."start_time" + ?) WHERE ("event"."end_time" IS ?)
frigate  | 2024-01-04 09:08:59.056424404  [2024-01-04 09:08:59] peewee                         DEBUG   : ('UPDATE "event" SET "end_time" = ("event"."start_time" + ?) WHERE ("event"."end_time" IS ?)', [30, None])
frigate  | 2024-01-04 09:09:03.535812141  [2024-01-04 09:09:03] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:05.718379662  [INFO] Starting go2rtc healthcheck service...
frigate  | 2024-01-04 09:09:08.535551874  [2024-01-04 09:09:08] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:13.536280055  [2024-01-04 09:09:13] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:13.646334375  [2024-01-04 09:09:13] frigate.record.maintainer      DEBUG   : Copied /media/frigate/recordings/2024-01-04/09/my_camera/08.59.mp4 in 0.06823396682739258 seconds.
frigate  | 2024-01-04 09:09:13.656682893  [2024-01-04 09:09:13] peewee.sqliteq                 DEBUG   : received query INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
frigate  | 2024-01-04 09:09:13.657312595  [2024-01-04 09:09:13] peewee                         DEBUG   : ('INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', ['1704359339.0-kbqdjf', 'my_camera', '/media/frigate/recordings/2024-01-04/09/my_camera/08.59.mp4', 1704359339.0, 1704359350.884766, 11.884765625, 87131464, 0, 0, 11.4])
frigate  | 2024-01-04 09:09:18.536122745  [2024-01-04 09:09:18] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:23.536810676  [2024-01-04 09:09:23] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:23.661632803  [2024-01-04 09:09:23] frigate.record.maintainer      DEBUG   : Copied /media/frigate/recordings/2024-01-04/09/my_camera/09.10.mp4 in 0.09705996513366699 seconds.
frigate  | 2024-01-04 09:09:23.672582148  [2024-01-04 09:09:23] peewee.sqliteq                 DEBUG   : received query INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
frigate  | 2024-01-04 09:09:23.672696771  [2024-01-04 09:09:23] peewee                         DEBUG   : ('INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', ['1704359350.0-lb9hco', 'my_camera', '/media/frigate/recordings/2024-01-04/09/my_camera/09.10.mp4', 1704359350.0, 1704359359.974844, 9.97484375, 50085873, 0, 0, 9.1])
frigate  | 2024-01-04 09:09:28.537433567  [2024-01-04 09:09:28] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:33.540068645  [2024-01-04 09:09:33] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:33.633132682  [2024-01-04 09:09:33] frigate.record.maintainer      DEBUG   : Copied /media/frigate/recordings/2024-01-04/09/my_camera/09.20.mp4 in 0.06589794158935547 seconds.
frigate  | 2024-01-04 09:09:33.641895717  [2024-01-04 09:09:33] peewee.sqliteq                 DEBUG   : received query INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
frigate  | 2024-01-04 09:09:33.642196130  [2024-01-04 09:09:33] peewee                         DEBUG   : ('INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', ['1704359360.0-mdtoat', 'my_camera', '/media/frigate/recordings/2024-01-04/09/my_camera/09.20.mp4', 1704359360.0, 1704359369.970078, 9.970078125, 10268645, 0, 0, 9.0])
frigate  | 2024-01-04 09:09:38.539618504  [2024-01-04 09:09:38] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:43.539784358  [2024-01-04 09:09:43] asyncio                        DEBUG   : Using selector: EpollSelector
frigate  | 2024-01-04 09:09:43.636906604  [2024-01-04 09:09:43] frigate.record.maintainer      DEBUG   : Copied /media/frigate/recordings/2024-01-04/09/my_camera/09.30.mp4 in 0.06844520568847656 seconds.
frigate  | 2024-01-04 09:09:43.646111800  [2024-01-04 09:09:43] peewee.sqliteq                 DEBUG   : received query INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
frigate  | 2024-01-04 09:09:43.646420672  [2024-01-04 09:09:43] peewee                         DEBUG   : ('INSERT INTO "recordings" ("id", "camera", "path", "start_time", "end_time", "duration", "motion", "objects", "dBFS", "segment_size") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', ['1704359370.0-tlyrvf', 'my_camera', '/media/frigate/recordings/2024-01-04/09/my_camera/09.30.mp4', 1704359370.0, 1704359379.974141, 9.974140624999999, 154845, 0, 0, 9.2])
frigate  | 2024-01-04 09:09:48.540381582  [2024-01-04 09:09:48] asyncio                        DEBUG   : Using selector: EpollSelector

FFprobe output from your camera

root@53bc8f4a3951:/opt/frigate# ffprobe rtsp://admin:QazWsx123@10.7.8.131/Streaming/Channels/101
ffprobe version e243e8d001-20231113 Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=aarch64-ffbuild-linux-gnu- --arch=aarch64 --target-os=linux --enable-nonfree --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-openssl --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --disable-libdavs2 --enable-libdrm --enable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --disable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --disable-libvpx --enable-libwebp --enable-lv2 --enable-rkmpp --disable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --disable-libplacebo --enable-libx264 --enable-libx265 --disable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags=-pie --extra-libs='-ldl -lstdc++ -lgomp' --extra-version=20231113
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, rtsp, from 'rtsp://admin:QazWsx123@10.7.8.131/Streaming/Channels/101':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.040000, bitrate: N/A
  Stream #0:0: Video: hevc (Main), yuvj420p(pc), 2688x1520 [SAR 1:1 DAR 168:95], 25 fps, 25 tbr, 90k tbn
[hevc_rkmpp_decoder @ 0xaaab14a9ae80] Picture format is yuv420p.

Operating system

Debian

Install method

Docker Compose

Network connection

Wired

Camera make and model

Hikvision DS-2CD2043G2-I

Any other information that may be helpful

Previously, I used the stable image from Docker Hub, but for some reason, the publication of current versions there stopped. Since there was no image with RK support on Docker Hub, I had to compile FFmpeg in the Docker image myself, then transfer it through layers to the stable Frigate image. I also had to replace some arguments because they were not present in the new versions of ffmpeg (stimeout). However, after all the work, Frigate on the stable version functioned just as it does now on the dev version with RK support.

here is my Dockerfile for compiling ffmpeg

FROM debian:bullseye as rk-ffmpeg

RUN mkdir /root/ffmpeg
WORKDIR /root/ffmpeg

RUN apt update && apt upgrade -y && apt install wget -y

# build packages
RUN apt install -y autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev
# ffmpeg dependencies
RUN apt install -y libx264-dev libx265-dev libnuma-dev libvpx-dev libopus-dev libdrm-dev libaom-dev libdav1d-dev libunistring-dev
# to build .deb
RUN apt install -y devscripts debhelper

RUN wget http://ftp.de.debian.org/debian/pool/main/liby/libyuv/libyuv0_0.0~git20230123.b2528b0-1_arm64.deb
RUN wget http://ftp.de.debian.org/debian/pool/main/liby/libyuv/libyuv-dev_0.0~git20230123.b2528b0-1_arm64.deb

RUN apt install -y ./libyuv0_0.0~git20230123.b2528b0-1_arm64.deb
RUN apt install -y ./libyuv-dev_0.0~git20230123.b2528b0-1_arm64.deb

RUN git clone https://github.com/rockchip-linux/mpp.git -b develop
WORKDIR /root/ffmpeg/mpp
RUN cmake CMakeLists.txt
RUN make -j8
RUN make install

WORKDIR /root/ffmpeg
RUN git clone https://github.com/tsukumijima/librga-rockchip.git
WORKDIR /root/ffmpeg/librga-rockchip
RUN debuild -us -uc -b && cp -a ../*.deb ./
RUN dpkg -i librga*.deb

WORKDIR /root/ffmpeg

RUN git clone https://github.com/hbiyik/FFmpeg.git
WORKDIR /root/ffmpeg/FFmpeg
RUN ./configure --pkg-config-flags="--static" \
    --enable-rkmpp --enable-version3 --enable-libdrm \
    --disable-doc --disable-shared --enable-static
RUN make -j8

WORKDIR /root/ffmpeg

FROM blakeblackshear/frigate:stable
#COPY --from=rk-ffmpeg /root/ffmpeg/FFmpeg/ffmpeg_g /usr/lib/btbn-ffmpeg
COPY --from=rk-ffmpeg /root/ffmpeg/FFmpeg/ffmpeg /usr/bin/ffmpeg
COPY --from=rk-ffmpeg /root/ffmpeg/FFmpeg/ffprobe /usr/bin/ffprobe
COPY --from=rk-ffmpeg /root/ffmpeg/FFmpeg/ffplay /usr/bin/ffplay
COPY --from=rk-ffmpeg /usr/local/lib/librockchip_mpp.so.1 /usr/local/lib/
COPY --from=rk-ffmpeg /usr/local/lib/librockchip_mpp.so.1 /usr/lib/
COPY --from=rk-ffmpeg /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 36 (9 by maintainers)

Most upvoted comments

The biggest difference between our forks is whether each component - decoder/filter/encoder is modular. hbiyik’s fork bundles RGA and MPP decoder and encoder together.

The advantage of this is that when external applications do not use libavfilter, RGA can also be easily used by browsers like Firefox. The disadvantage is that the flexible and customizable filter pipeline is lost, and the libavcodec code is complex and difficult to read and maintain.

hbiyik and I agree on this, so he also moved to ffmpeg-rockchip and kept his fork as is. How to use ffmpeg-rockchip in various applications can be found in this Wiki. https://github.com/hbiyik/ffmpeg-rockchip/wiki/Rendering

Our use case Jellyfin obviously required flexible hardware filters, so we decided to rewrite the filters.

@nyanmisaka yes, I want to create static *.a libs instead of dynamic *.so.

I have a mpp fork that allows static building, but as you say it breaks some things. However, I plan to create new patches that will not break any stuff. I will try to get them merged upstream, but I am not sure if they will merge it. I already requested this feature but no response so far (rockchip-linux/mpp#525).

Rkrga needs one line changed to allow static build on build time.

We have a use case for this as well, so I’ll keep an eye on that.

The Chinese New Year holiday has just started, so they may get back to you after next Monday.

@nyanmisaka yes, I want to create static *.a libs instead of dynamic *.so.

I have a mpp fork that allows static building, but as you say it breaks some things. However, I plan to create new patches that will not break any stuff. I will try to get them merged upstream, but I am not sure if they will merge it. I already requested this feature but no response so far (https://github.com/rockchip-linux/mpp/issues/525).

Rkrga needs one line changed to allow static build on build time.

a general statement:

use https://github.com/nyanmisaka/ffmpeg-rockchip

https://github.com/hbiyik/FFmpeg is obselete now, propably i should archive this repo and give a link to new ffmpeg-rockchip to prevent future splits

Recency: hbiyik update FFmpeg a month ago, then cloned nyanmisaka ffmpeg-rockchip two weeks ago and nyanmisaka/ffmpeg-rockchip is updated last week. Community: Jellyfin accepted nyanmisaka’s Rockchip support recently https://github.com/jellyfin/jellyfin-ffmpeg/pull/318.

Yeah, Software scaling explains the increased CPU usage. I plan to provide a new FFmpeg version that supports hardware scaling. If you would like to, you can try out if this helps decreasing your CPU usage.