blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
17.66k stars 1.62k forks source link

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

Closed ThisIsLamer closed 7 months ago

ThisIsLamer commented 7 months ago

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/
ddonevski commented 4 months ago

Hi, I decided not to wait and installed the latest release of Ubuntu Rockchip. All of the necessary devices mentioned a few posts earlier are present. From the list of optional devices, I only have /dev/mpp-service. I'll reinstall Docker stuff tomorrow and then I guess I'll be ready for the -rk image. Thanks.

ddonevski commented 4 months ago

Hi, I installed everything as earlier, but tried -rk image. In the compose.yml, I added device mappings for all of the devices @MarcA711 listed as necessary in the previous post. However, with -rk image i'm back to around 17% CPU usage for ffmpeg for only 1 camera at 640x380 resolution. This is what I put in compose.yml:

    devices:
      - /dev/bus/usb:/dev/bus/usb  # Passes the USB Coral, needs to be modified for other versions
      - /dev/dri:/dev/dri  # For Orange Pi 3B
      - /dev/dma_heap:/dev/dma_heap  # For Orange Pi 3B
      - /dev/rga:/dev/rga  # For Orange Pi 3B
      - /dev/mpp_service:/dev/mpp_service # For Orange Pi 3B
#      - /dev/dri/renderD128:/dev/dri/renderD128 # For intel hwaccel, needs to be updated for your hardware

I tried with renderD128 commented and uncommented, no difference.

I also tried with

    group_add:
      - "110" # render

commented and uncommented, no difference.

As @spattinson suggested, I ran ps -ef which provided the following output:

ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 640x360 -i pipe: -f mpegts -s 12
ffmpeg -hide_banner -loglevel warning -threads 2 -c:v h264_rkmpp_decoder -user_a
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1280x720 -i pipe: -f mpegts -s 1
ffmpeg -hide_banner -loglevel warning -threads 2 -user_agent FFmpeg Frigate/0.13

So I tried a few things, but the problem persists.

MarcA711 commented 4 months ago

Hi, you are using the stable image of rockchip. This currently includes an old ffmpeg version. The newer FFmpeg version is currently only merged in the dev branch of frigate.

I have a fork where I merged the newer FFmpeg version to the stable frigate branch. You can build it using

git clone -b 13.2 https://github.com/MarcA711/frigate-rockchip/
cd frigate-rockchip
make local-rk

Afterwards, you can use it by changing the image of your docker-compose.yml to frigate:latest-rk.

If you don't want to build the image yourself, I pushed it to docker hub marca711/frigate:latest-rk.

However, you are using just one Camera with a low resolution. If you add more cameras and increase the resolution to 2k or higher, you will notice a much bigger difference between software and hardware trancoding.

ddonevski commented 4 months ago

Hi, thanks a lot for all the help. I'll test as soon as I can and let you know how it went. And I'll be interested in enabling board's NPU because I ordered Pi 5B board. I'll see the docs and previous threads on that topic. Thanks.

ddonevski commented 4 months ago

Hi, I pulled marca711/frigate:latest-rk image and everything works great. I used the "Detectors" section of the documenation from Frigate Rockchip GitHub repo to fill in ymls properly. The ffmpeg CPU usage went below 6% and Frigate seems to handle 3 cams at 640x380 resolution without problems. I also enabled NPU, but Orange Pi 3B board only has 0.8 TOPS so it reports inference speed around 85 ms and CPU usage up to 40%. I also have Coral enbled and for Corlad, Frigate reports inference speeds varying from 25 ms up to 120 ms. So it's nowhere near those 5 ms speeds obtained on Coral's image database test. For some reason, parts of Frigate's UI turned gray after I added 2 more cams to the one connected before, as shown in the image below. image Ubuntu's System monitor reports overall CPU usage around 60% for all four cores most of the time, with occasional peaks up to about 90%. If I understood correctly, inference speed of 100 ms means that the detector can keep up with 10 images per second. So 3 cams x 5 fps should be too much for a detector if it kept the inference speed at 100 ms. However, inference speeds reported by Friagate are quite variable so I'm not sure how this reflects on detecton. For example, at some moment Coral is reported to run at 120 ms speed. If it were the only detector covering 3 cams at 5 fps, it'd have to skip frames. Or maybe those instantaneous speeds don't matter, maybe the average is what counts. I haven't figured this out yet. However, back to the actual thread topic, hardware accelerations works great with @MarcA711 's image. Thanks everyone for help.

simon511000 commented 4 months ago

By using the marca711/frigate:latest-rk image, I went from 11-16% CPU usage to less than 3%. It's impressive!

ddonevski commented 4 months ago

@simon511000 yeah, I suppose you have 5B board (8 cores at 2.4 GHz) so you get around 3%, while I have 3B board (4 cores at 1.8 GHz) so I get around 6% which is great! I'm very happy with this image.

flyzet-prog commented 3 months ago

Hi , you are using the stable image of rockchip. This currently includes an old ffmpeg version. The newer FFmpeg version is currently only merged in the dev branch of frigate.

I have a fork where I merged the newer FFmpeg version to the stable frigate branch. You can build it using

git clone -b 13.2 https://github.com/MarcA711/frigate-rockchip/
cd frigate-rockchip
make local-rk

Afterwards, you can use it by changing the image of your docker-compose.yml to frigate:latest-rk.

If you don't want to build the image yourself, I pushed it to docker hub marca711/frigate:latest-rk.

However, you are using just one Camera with a low resolution. If you add more cameras and increase the resolution to 2k or higher, you will notice a much bigger difference between software and hardware trancoding.

Hello @MarcA711 . I have Joshua Ubuntu 22.04 with Kernel 5.1 installed(Orange Pi 5 plus 16gb ram). I have connected 3 cameras with 2.5k resolution, they all works well. But when i try to chose in config of Frigate 6 streams instead of 3. One stream for record, another sub stream for detection for each cameras, i have green records and frigate doesn't recognise correctly detection after that. When i try to restart frigate or System itself, the system freezing. Seems like some decoding issue related to ffmpeg? Would be much appreciated for any help. 328454723-23decdec-7b22-4d97-abe8-3c52422fc756

MarcA711 commented 3 months ago

@flyzet-prog Sorry for the late reply! Are you using the marca711/frigate:latest-rk image? I have the same setup (OPi5+ 16gb, Joshua riek 22.04 and 3 cams with two streams each) and don't experience these issues. Maybe you could describe your problem in nyanmisaka's repo https://github.com/nyanmisaka/ffmpeg-rockchip

nyanmisaka commented 3 months ago

Check error logs with sudo dmesg. I've never seen this before. I guess it is a similar issue to the IOVA 4GB limit.

flyzet-prog commented 3 months ago

@flyzet-prog Sorry for the late reply! Are you using the marca711/frigate:latest-rk image? I have the same setup (OPi5+ 16gb, Joshua riek 22.04 and 3 cams with two streams each) and don't experience these issues. Maybe you could describe your problem in nyanmisaka's repo https://github.com/nyanmisaka/ffmpeg-rockchip

No worries. I am tried to use your fork, it started with newer interface and then restarts. I use official 0.13.2-6476f8a one, and this glitch appears only here. I wanted to try yours image, but can’t run it properly. Also opened an issue at Joshua repo, but i think it’s not related to OS. Thank you for your reply

flyzet-prog commented 3 months ago

Check error logs with sudo dmesg. I've never seen this before. I guess it is a similar issue to the IOVA 4GB limit.

Let me please change it again to 6 streams, and waiting for that issue. As soon as it appears, i will update with log. Thank you for your reply

MarcA711 commented 3 months ago

No worries. I am tried to use your fork, it started with newer interface and then restarts. I use official 0.13.2-6476f8a one, and this glitch appears only here. I wanted to try yours image, but can’t run it properly. Also opened an issue at Joshua repo, but i think it’s not related to OS. Thank you for your reply

So you are using the frigate:stable-rk? This uses the fork from hbiyik. I think I saw this issue before with this FFmpeg version.

Try to build from my repo. You need to switch to the 13.2 branch. Try this:

git clone -b 13.2 https://github.com/MarcA711/frigate-rockchip
cd frigate-rockchip
sudo make local-rk

afterwards use image: frigate:local-rk in your docker compose file.

Alternatively, there is also a prebuild image available using docker pull marca711/frigate:latest-rk

flyzet-prog commented 3 months ago

image: frigate:local-rk I got an error while build an image

`419.9 Stored in directory: /root/.cache/pip/wheels/d4/2a/06/11202ea86be0f51f34e9411d691e25b991d188d93ab4d3e551 419.9 Building wheel for h5py (pyproject.toml): started 420.5 Building wheel for h5py (pyproject.toml): finished with status 'error' 420.5 error: subprocess-exited-with-error 420.5
420.5 × Building wheel for h5py (pyproject.toml) did not run successfully. 420.5 │ exit code: 1 420.5 ╰─> [73 lines of output] 420.5 running bdist_wheel 420.5 running build 420.5 running build_py 420.5 creating build 420.5 creating build/lib.linux-aarch64-cpython-39 420.5 creating build/lib.linux-aarch64-cpython-39/h5py 420.5 copying h5py/init.py -> build/lib.linux-aarch64-cpython-39/h5py 420.5 copying h5py/ipy_completer.py -> build/lib.linux-aarch64-cpython-39/h5py 420.5 copying h5py/h5py_warnings.py -> build/lib.linux-aarch64-cpython-39/h5py 420.5 copying h5py/version.py -> build/lib.linux-aarch64-cpython-39/h5py 420.5 creating build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/vds.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/dataset.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/init.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/filters.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/selections.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/datatype.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/group.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/selections2.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/compat.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/base.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/dims.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/files.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 copying h5py/_hl/attrs.py -> build/lib.linux-aarch64-cpython-39/h5py/_hl 420.5 creating build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_ros3.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_slicing.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_dataset_swmr.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/conftest.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_datatype.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_dataset.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_big_endian_file.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_attribute_create.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/init.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_dtype.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_file_image.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_file_alignment.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_selections.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_attrs.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_group.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/common.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5t.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_file.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5z.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_dimension_scales.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_base.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5o.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_file2.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_objects.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_attrs_data.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_dims_dimensionproxy.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_errors.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_filters.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_completions.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5d_direct_chunk.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_dataset_getitem.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5p.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5pl.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 copying h5py/tests/test_h5f.py -> build/lib.linux-aarch64-cpython-39/h5py/tests 420.5 creating build/lib.linux-aarch64-cpython-39/h5py/tests/data_files 420.5 copying h5py/tests/data_files/init.py -> build/lib.linux-aarch64-cpython-39/h5py/tests/data_files 420.5 creating build/lib.linux-aarch64-cpython-39/h5py/tests/test_vds 420.5 copying h5py/tests/test_vds/init.py -> build/lib.linux-aarch64-cpython-39/h5py/tests/test_vds 420.5 copying h5py/tests/test_vds/test_lowlevel_vds.py -> build/lib.linux-aarch64-cpython-39/h5py/tests/test_vds 420.5 copying h5py/tests/test_vds/test_virtual_source.py -> build/lib.linux-aarch64-cpython-39/h5py/tests/test_vds 420.5 copying h5py/tests/test_vds/test_highlevel_vds.py -> build/lib.linux-aarch64-cpython-39/h5py/tests/test_vds 420.5 copying h5py/tests/data_files/vlen_string_s390x.h5 -> build/lib.linux-aarch64-cpython-39/h5py/tests/data_files 420.5 copying h5py/tests/data_files/vlen_string_dset.h5 -> build/lib.linux-aarch64-cpython-39/h5py/tests/data_files 420.5 copying h5py/tests/data_files/vlen_string_dset_utc.h5 -> build/lib.linux-aarch64-cpython-39/h5py/tests/data_files 420.5 running build_ext 420.5 Building h5py requires pkg-config unless the HDF5 path is explicitly specified using the environment variable HDF5_DIR. For more information and details, see https://docs.h5py.org/en/stable/build.html#custom-installation 420.5 error: pkg-config probably not installed: FileNotFoundError(2, 'No such file or directory') 420.5 [end of output] 420.5
420.5 note: This error originates from a subprocess, and is likely not a problem with pip. 420.5 ERROR: Failed building wheel for h5py 420.5 Successfully built jstyleson 420.5 Failed to build h5py 420.5 ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects

Dockerfile:53

52 | COPY docker/main/requirements-ov.txt /requirements-ov.txt 53 | >>> RUN apt-get -qq update \ 54 | >>> && apt-get -qq install -y wget python3 python3-distutils \ 55 | >>> && wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ 56 | >>> && python3 get-pip.py "pip" \ 57 | >>> && pip install -r /requirements-ov.txt 58 |

ERROR: failed to solve: process "/bin/sh -c apt-get -qq update && apt-get -qq install -y wget python3 python3-distutils && wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py && python3 get-pip.py \"pip\" && pip install -r /requirements-ov.txt" did not complete successfully: exit code: 1 make: *** [docker/rockchip/rk.mk:4: local-rk] Error 1`

flyzet-prog commented 3 months ago

No worries. I am tried to use your fork, it started with newer interface and then restarts. I use official 0.13.2-6476f8a one, and this glitch appears only here. I wanted to try yours image, but can’t run it properly. Also opened an issue at Joshua repo, but i think it’s not related to OS. Thank you for your reply

So you are using the frigate:stable-rk? This uses the fork from hbiyik. I think I saw this issue before with this FFmpeg version.

Try to build from my repo. You need to switch to the 13.2 branch. Try this:

git clone -b 13.2 https://github.com/MarcA711/frigate-rockchip
cd frigate-rockchip
sudo make local-rk

afterwards use image: frigate:local-rk in your docker compose file.

Alternatively, there is also a prebuild image available using docker pull marca711/frigate:latest-rk

I use this one

ghcr.io/blakeblackshear/frigate:0.13.2-rk

MarcA711 commented 3 months ago

I applied a fix, could you try this again:

git clone -b 13.2 https://github.com/MarcA711/frigate-rockchip
cd frigate-rockchip
sudo make local-rk

I use this one ghcr.io/blakeblackshear/frigate:0.13.2-rk

This means you are using the older hbiyik fork. I guess I saw this problem there. Try to use the newer image.

flyzet-prog commented 3 months ago

ghcr.io/blakeblackshear/

Sure, i will try again Sorry, but i don't see any newer images there. Where i can find any newer?

Screenshot 2024-05-10 at 13 11 52
MarcA711 commented 3 months ago

It is no official release. The last official release 13.2 included an old ffmpeg version. Since then I merged some changes to the dev branch with some fixes and improvements. However, some code had to be removed due to a copyright complaint... That's why I backported some important changes to the 13.2 branch of my repo mentioned above. So everyone should use this branch for now.

Currently, I work on reimplementing everything and hopefully the official 14.0 image, will work out of the box.

flyzet-prog commented 3 months ago

It is no official release. The last official release 13.2 included an old ffmpeg version. Since then I merged some changes to the dev branch with some fixes and improvements. However, some code had to be removed due to a copyright complaint... That's why I backported some important changes to the 13.2 branch of my repo mentioned above. So everyone should use this branch for now.

Currently, I work on reimplementing everything and hopefully the official 14.0 image, will work out of the box.

So the main reason of my problem is old ffmpeg. May i see frigate config and docker-compose.yml for your fork? Mine looks like bellow

` mqtt: enabled: true host: 192.168.8.163 port: 1883 user: mqtt password: Abcd1234 topic_prefix: frigate detectors: armnn: type: rknn core_mask: 0b111 # 0b111 3 cores model:

name of yolov8 model or path to your own .rknn model file

possible values are:

- default-yolov8n

- default-yolov8s

- default-yolov8m

- default-yolov8x

- default-yolov8l

- /config/model_cache/rknn/your_custom_model.rknn

path: default-yolov8m width: 320 height: 320 input_pixel_format: bgr input_tensor: nhwc

ffmpeg: hwaccel_args: preset-rk-h264

hwaccel_args: preset-rk-h264 # or preset-rk-h265

output_args: record: preset-record-generic-audio-aac detect: -f rawvideo rtmp: -c copy -f flv -flvflags no_duration_filesize

ui:

Optional: Set the default live mode for cameras in the UI (default: shown below)

live_mode: mse timezone: Etc/GMT-3 use_experimental: true time_format: 24hour date_style: full time_style: medium strftime_fmt: "%a, %H:%M (%d.%m.%Y)"

Re-stream

go2rtc: streams: camera_ptz:

birdseye: enabled: true mode: continuous

database: path: /media/frigate/frigate.db

objects: track:

motion: threshold: 25 contour_area: 15 delta_alpha: 0.2 frame_alpha: 0.2 frame_height: 50 improve_contrast: true mqtt_off_delay: 30

record: enabled: true retain: days: 2 mode: all

events:

max_seconds: 300

pre_capture: 5 # sec
post_capture: 15 # sec
objects:
  - person
  #- car
  - dog
  - cat
  - bird

retain:
  default: 7
  mode: active_objects
  objects:
    person: 10
    #car: 3
    dog: 1
    cat: 1
    bird: 7

snapshots: enabled: true clean_copy: false timestamp: true bounding_box: true crop: false height: 1920 retain: default: 15 objects: person: 15

car: 3

  dog: 2
  cat: 2
  bird: 7

rtmp: enabled: false

live: height: 1080 quality: 1

timestamp_style: position: "br" format: "%d.%m.%Y %H:%M:%S" color: red: 255 green: 255 blue: 255 thickness: 2 effect: "solid"

detect: enabled: true fps: 5 max_disappeared: 25 stationary: interval: 100 threshold: 50

cameras: camera_ptz: ffmpeg: inputs:

and docker compose file

` GNU nano 6.2 docker-compose.yml
version: "3.9" services: frigate: container_name: frigate image: ghcr.io/blakeblackshear/frigate:0.13.2-rk privileged: true # this may not be necessary for all setups restart: unless-stopped shm_size: "300mb" # update for your cameras based on calculation above devices:

Thank you

MarcA711 commented 3 months ago

The config and docker compose should be the same. You only need to modify the image in the docker compose file to image: frigate:local-rk

flyzet-prog commented 3 months ago

The config and docker compose should be the same. You only need to modify the image in the docker compose file to image: frigate:local-rk

It not allow me to run docker-compose, after i changed image to frigate: latest-rk, it's started but cameras not appeared after coupe of minutes system freezed and also here is the log:

https://pastebin.com/d0H6NvVG

i am really want to try your fork, but couldn't run it properly(

Screenshot 2024-05-10 at 14 36 17
MarcA711 commented 3 months ago

Could you please post again your your config, your docker-compose and the frigate log output and enclose it with 3 backticks (```) at the beginning and end?

flyzet-prog commented 3 months ago

Could you please post again your your config, your docker-compose and the frigate log output and enclose it with 3 backticks (```) at the beginning and end?

The image is image: frigate:local-rk in docker-compose.yml Here is the log frigate


2024-05-10 14:41:30.355475455  [INFO] Starting Frigate...
2024-05-10 14:41:33.464716226  [2024-05-10 14:41:33] frigate.app                    INFO    : Starting Frigate (0.13.2-1f8ac4c1)
2024-05-10 14:41:33.541713900  [2024-05-10 14:41:33] peewee_migrate.logs            INFO    : Starting migrations
2024-05-10 14:41:33.551930693  [2024-05-10 14:41:33] peewee_migrate.logs            INFO    : There is nothing to migrate
2024-05-10 14:41:33.566602986  [2024-05-10 14:41:33] frigate.app                    INFO    : Recording process started: 454
2024-05-10 14:41:33.569765820  [2024-05-10 14:41:33] frigate.app                    INFO    : go2rtc process pid: 90
2024-05-10 14:41:33.604222448  [2024-05-10 14:41:33] detector.armnn                 INFO    : Starting detection process: 464
2024-05-10 14:41:33.609484699  [2024-05-10 14:41:33] frigate.app                    INFO    : Output process started: 466
2024-05-10 14:41:33.958804567  I RKNN: [14:41:33.958] RKNN Runtime Information, librknnrt version: 1.6.0 (9a7b5d24c@2023-12-13T17:31:11)
2024-05-10 14:41:33.959097984  I RKNN: [14:41:33.959] RKNN Driver Information, version: 0.9.2
2024-05-10 14:41:33.960447234  E RKNN: [14:41:33.960] parseRKNN: exportDataSize large then model size: 55727936 vs 36904960!
2024-05-10 14:41:33.960450442  E RKNN: [14:41:33.960] parseRKNN from buffer: Invalid RKNN format!
2024-05-10 14:41:33.960457151  E RKNN: [14:41:33.960] rknn_init, load model failed!
2024-05-10 14:41:33.960719067  E Catch exception when init runtime!
2024-05-10 14:41:33.961580359  E Traceback (most recent call last):
2024-05-10 14:41:33.961583859    File "/usr/local/lib/python3.9/dist-packages/rknnlite/api/rknn_lite.py", line 148, in init_runtime
2024-05-10 14:41:33.961585318      self.rknn_runtime.build_graph(self.rknn_data, self.load_model_in_npu)
2024-05-10 14:41:33.961586484    File "rknnlite/api/rknn_runtime.py", line 919, in rknnlite.api.rknn_runtime.RKNNRuntime.build_graph
2024-05-10 14:41:33.961619734  Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
2024-05-10 14:41:33.961620901  
2024-05-10 14:41:33.962499984  [2024-05-10 14:41:33] frigate.detectors.plugins.rknn E       : Error initializing rknn runtime. Do you run docker in privileged mode?
2024-05-10 14:41:34.141235377  [2024-05-10 14:41:34] frigate.app                    INFO    : Camera processor started for camera_ptz: 491
2024-05-10 14:41:34.155035879  [2024-05-10 14:41:34] frigate.app                    INFO    : Camera processor started for camera_backyard: 492
2024-05-10 14:41:34.168274338  [2024-05-10 14:41:34] frigate.app                    INFO    : Camera processor started for camera_terrace: 493
2024-05-10 14:41:34.182405006  [2024-05-10 14:41:34] frigate.app                    INFO    : Capture process started for camera_ptz: 495
2024-05-10 14:41:34.195974508  [2024-05-10 14:41:34] frigate.app                    INFO    : Capture process started for camera_backyard: 496
2024-05-10 14:41:34.212470884  [2024-05-10 14:41:34] frigate.app                    INFO    : Capture process started for camera_terrace: 501
2024-05-10 14:41:39.263652142  [2024-05-10 14:41:39] frigate.video                  ERROR   : camera_ptz: Unable to read frames from ffmpeg process.
2024-05-10 14:41:39.267517601  [2024-05-10 14:41:39] frigate.video                  ERROR   : camera_ptz: ffmpeg process is not running. exiting capture thread...
2024-05-10 14:41:39.322085523  [2024-05-10 14:41:39] frigate.video                  ERROR   : camera_backyard: Unable to read frames from ffmpeg process.
2024-05-10 14:41:39.323862648  [2024-05-10 14:41:39] frigate.video                  ERROR   : camera_terrace: Unable to read frames from ffmpeg process.
2024-05-10 14:41:39.323887731  [2024-05-10 14:41:39] frigate.video                  ERROR   : camera_terrace: ffmpeg process is not running. exiting capture thread...
2024-05-10 14:41:39.323892106  [2024-05-10 14:41:39] frigate.video                  ERROR   : camera_backyard: ffmpeg process is not running. exiting capture thread...
2024-05-10 14:41:54.248599148  [2024-05-10 14:41:54] watchdog.camera_ptz            ERROR   : Ffmpeg process crashed unexpectedly for camera_ptz.
2024-05-10 14:41:54.250408648  [2024-05-10 14:41:54] watchdog.camera_ptz            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-05-10 14:41:54.252627648  [2024-05-10 14:41:54] ffmpeg.camera_ptz.detect       ERROR   : [tcp @ 0xaaaafa70efa0] Connection to tcp://192.168.8.163:8554?timeout=5000000 failed: Connection timed out
2024-05-10 14:41:54.252639606  [2024-05-10 14:41:54] ffmpeg.camera_ptz.detect       ERROR   : [in#0 @ 0xaaaafa70eac0] Error opening input: Connection timed out
2024-05-10 14:41:54.252644273  [2024-05-10 14:41:54] ffmpeg.camera_ptz.detect       ERROR   : Error opening input file rtsp://*:*@192.168.8.163:8554/camera.move.
2024-05-10 14:41:54.252648065  [2024-05-10 14:41:54] ffmpeg.camera_ptz.detect       ERROR   : Error opening input files: Connection timed out
2024-05-10 14:41:54.271491192  [2024-05-10 14:41:54] watchdog.camera_backyard       ERROR   : Ffmpeg process crashed unexpectedly for camera_backyard.
2024-05-10 14:41:54.272236108  [2024-05-10 14:41:54] watchdog.camera_backyard       ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-05-10 14:41:54.273337442  [2024-05-10 14:41:54] ffmpeg.camera_backyard.detect  ERROR   : [tcp @ 0xaaab0987dfa0] Connection to tcp://192.168.8.163:8554?timeout=5000000 failed: Connection timed out
2024-05-10 14:41:54.274201650  [2024-05-10 14:41:54] ffmpeg.camera_backyard.detect  ERROR   : [in#0 @ 0xaaab0987dac0] Error opening input: Connection timed out
2024-05-10 14:41:54.275095025  [2024-05-10 14:41:54] ffmpeg.camera_backyard.detect  ERROR   : Error opening input file rtsp://*:*@192.168.8.163:8554/camera.terrace_main?video=all&audio=all.
2024-05-10 14:41:54.275628484  [2024-05-10 14:41:54] ffmpeg.camera_backyard.detect  ERROR   : Error opening input files: Connection timed out
2024-05-10 14:41:54.282561401  [2024-05-10 14:41:54] watchdog.camera_terrace        ERROR   : Ffmpeg process crashed unexpectedly for camera_terrace.
2024-05-10 14:41:54.283866026  [2024-05-10 14:41:54] watchdog.camera_terrace        ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-05-10 14:41:54.285205068  [2024-05-10 14:41:54] ffmpeg.camera_terrace.detect   ERROR   : [tcp @ 0xaaaac7bc5fa0] Connection to tcp://192.168.8.163:8554?timeout=5000000 failed: Connection timed out
2024-05-10 14:41:54.286238151  [2024-05-10 14:41:54] ffmpeg.camera_terrace.detect   ERROR   : [in#0 @ 0xaaaac7bc5ac0] Error opening input: Connection timed out
2024-05-10 14:41:54.287038485  [2024-05-10 14:41:54] ffmpeg.camera_terrace.detect   ERROR   : Error opening input file rtsp://*:*@192.168.8.163:8554/camera.cam_1?video=all&audio=all.
2024-05-10 14:41:54.287713401  [2024-05-10 14:41:54] ffmpeg.camera_terrace.detect   ERROR   : Error opening input files: Connection timed out
2024-05-10 14:41:56.488361956  E Catch exception when setting inputs.
2024-05-10 14:41:56.488677539  E Traceback (most recent call last):
2024-05-10 14:41:56.488681039    File "/usr/local/lib/python3.9/dist-packages/rknnlite/api/rknn_lite.py", line 200, in inference
2024-05-10 14:41:56.488682789      self.rknn_runtime.set_inputs(inputs, data_type, data_format, inputs_pass_through=inputs_pass_through)
2024-05-10 14:41:56.488684248    File "rknnlite/api/rknn_runtime.py", line 983, in rknnlite.api.rknn_runtime.RKNNRuntime.set_inputs
2024-05-10 14:41:56.488685998    File "rknnlite/api/rknn_runtime.py", line 1207, in rknnlite.api.rknn_runtime.RKNNRuntime.get_in_out_num
2024-05-10 14:41:56.488687164  ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
2024-05-10 14:41:56.488688039  
2024-05-10 14:41:56.489209248  Process detector:armnn:
2024-05-10 14:41:56.490452039  Traceback (most recent call last):
2024-05-10 14:41:56.490468081    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2024-05-10 14:41:56.490469248      self.run()
2024-05-10 14:41:56.490470414    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2024-05-10 14:41:56.490471289      self._target(*self._args, **self._kwargs)
2024-05-10 14:41:56.490484706    File "/opt/frigate/frigate/object_detection.py", line 125, in run_detector
2024-05-10 14:41:56.490485873      detections = object_detector.detect_raw(input_frame)
2024-05-10 14:41:56.490487039    File "/opt/frigate/frigate/object_detection.py", line 75, in detect_raw
2024-05-10 14:41:56.490488206      return self.detect_api.detect_raw(tensor_input=tensor_input)
2024-05-10 14:41:56.490489373    File "/opt/frigate/frigate/detectors/plugins/rknn.py", line 192, in detect_raw
2024-05-10 14:41:56.490490248      return self.postprocess(np.array(output))
2024-05-10 14:41:56.490491414    File "/opt/frigate/frigate/detectors/plugins/rknn.py", line 145, in postprocess
2024-05-10 14:41:56.490492581      results = np.transpose(results[0, 0, :, :])  # array shape (2100, 84)
2024-05-10 14:41:56.490501914  IndexError: too many indices for array: array is 0-dimensional, but 4 were indexed ```

And docker-compose.yml 

``` version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:0.13.2-rk
    shm_size: "300mb" # 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/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
      - /dev/dri/renderD129
      - /dev/dri/card0
      - /dev/dri/card1
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/flyzet/frigate/config:/config/
      - /home/flyzet/media/frigate:/media/frigate
      - /home/flyzet/media/frigate/clips:/media/frigate/clips
      - /home/flyzet/media/frigate/recordings:/media/frigate/recordings
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "8553:8553" # RTSP feeds
      - "8556:8556/tcp" # WebRTC over tcp
      - "8556:8556/udp" # WebRTC over udp
    environment:
      FRIGATE_RTSP_PASSWORD: "password"
      FFMPEG_RKMPP_PIXFMT: "YUV420P" ```
MarcA711 commented 3 months ago

Could you try to remove the config/model_cache/rknn folder? If this won't help, try to use path: default-yolov8n in your config.

flyzet-prog commented 3 months ago

Could you try to remove the config/model_cache/rknn folder? If this won't help, try to use path: default-yolov8n in your config.

Tried both ways without luck, it's started and showing green cameras after couple minutes system freezing.

MarcA711 commented 3 months ago

What does sudo dmesg say after the green recordings?

flyzet-prog commented 3 months ago

What does sudo dmesg say after the green recordings?

i pasted dmesg output here, because it's too long

https://pastecode.io/s/kwnt3wf1

MarcA711 commented 3 months ago

I can't find anything useful in the logs and have no more idea.