Home Assistant Green 性能释放

ha-green-armbian1

Green 出厂的 HAOS 其实并没有把它的 CPU RK3566 的能力完全利用起来。Rockchip官网可以看到 RK3566 其实有如下两个好东西

  • NPU

    支持 1Tops 算力

  • VPU

    硬解码 4K 60fps H.265/H.264/VP9

    硬编码 1080P 60fps H.265/H.264

为了让 Green 发挥出最佳性能,我编译了支持 NPU 和 VPU 的 Armbian

刷机

刷机教程我在之前 Green 评测文章里有,系统下载也在那

应用

首先要感谢大佬 @MarcA711@nyanmisaka 为 RK35xx 系列 CPU 适配了 Friagte 和 Jellyfin 等

以下应用是朋友 @紫易辰 和 @r-MT 推荐的,更多用法可以自己摸索,我只是为了验证 CPU 性能,顺便写下教程

Frigate

Frigate 可以利用 RK3566 的 NPU 来识别监控 RTSP 流中人等事物,VPU 的解码器则用来处理视频流,可以实时转换视频流码率大小等

  • docker-compose.yml

    services:
      frigate:
        image: ghcr.io/blakeblackshear/frigate:stable-rk
        container_name: frigate
        volumes:
          - /etc/localtime:/etc/localtime:ro
          - /opt/frigate/conf:/config
          - /mnt/da/frigate/data:/media/frigate
          - /mnt/da/frigate/data/db/frigate.db:/db/frigate.db
          - type: tmpfs
            target: /tmp/cache
            tmpfs:
              size: 1gb
        shm_size: 512mb
        environment:
          - TZ=Asia/Shanghai
          - FRIGATE_RTSP_PASSWORD=frigate
          - HTTPS_PROXY=http://192.168.2.12:99 # 根据实际网络境按需添加http代理下载模型用
        network_mode: host
        restart: always
        privileged: true
        devices:
          - /dev/dri
          - /dev/dma_heap
          - /dev/rga
          - /dev/mpp_service
    
  • frigate 配置

    config.yml

    version: 0.14
    
    mqtt:
      enabled: false
    
    database:
      path: /db/frigate.db
    
    record:
      enabled: true
      retain:
        days: 0
        mode: all
      events:
        retain:
          default: 7
          mode: motion
    
    audio:
      enabled: true
      listen:
        - bark
        - fire_alarm
        - scream
        - speech
        - yell
    
    review:
      alerts:
        labels:
          - person
      detections:
        labels:
          - face
          - license plate
          - dog
          - cat
          - car
    
    ffmpeg:
      hwaccel_args: preset-rk-h264
      output_args:
        record: preset-record-generic-audio-copy
    
    detectors:
      rknn:
        type: rknn
        num_cores: 3
    
    model:
      path: deci-fp16-yolonas_s
      width: 320
      height: 320
      input_pixel_format: bgr
      input_tensor: nhwc
      labelmap_path: /labelmap/coco-80.txt
    
    go2rtc:
      rtsp:
        username: admin
        password: xxx
      streams:
        home_west_up:
          - rtsp://admin:xxx@192.168.2.29:554/h264/ch1/main/av_stream
          - ffmpeg:home_west_up#video=h264#hardware#audio=opus
        home_west_down:
          - rtsp://admin:xxx@192.168.2.29:554/h264/ch2/main/av_stream
          - ffmpeg:home_west_down#video=h264#hardware#audio=opus
        home_north_up:
          - rtsp://admin:xxx@192.168.2.30:554/h264/ch1/main/av_stream
          - ffmpeg:home_north_up#video=h264#hardware#audio=opus
        home_north_down:
          - rtsp://admin:xxx@192.168.2.30:554/h264/ch2/main/av_stream
          - ffmpeg:home_north_down#video=h264#hardware#audio=opus
    
    cameras:
      home_west_up:
        enabled: true
        detect:
          enabled: true
          width: 1280
          height: 720
          fps: 5
        ffmpeg:
          inputs:
            - path: rtsp://admin:xxx9@127.0.0.1:8554/home_west_up
              roles:
                - detect
                - record
                - audio
        motion:
          mask:
            - 0.706,0.928,0.956,0.923,0.955,0.974,0.706,0.977
      home_west_down:
        enabled: true
        detect:
          enabled: true
          width: 1280
          height: 720
          fps: 5
        ffmpeg:
          inputs:
            - path: rtsp://admin:xxx@127.0.0.1:8554/home_west_down
              roles:
                - detect
                - record
                - audio
        motion:
          mask:
            - 0.706,0.928,0.956,0.923,0.955,0.974,0.706,0.977
      home_north_up:
        enabled: true
        detect:
          enabled: true
          width: 1280
          height: 720
          fps: 5
        ffmpeg:
          inputs:
            - path: rtsp://admin:xxx@127.0.0.1:8554/home_north_up
              roles:
                - detect
                - record
                - audio
        motion:
          mask:
            - 0.427,0,0.441,0.393,0.479,0.404,0.518,0.415,0.576,0.43,0.658,0.462,0.841,0.585,1,0.691,1,0.442,1,0
            - 0.706,0.928,0.956,0.923,0.955,0.974,0.706,0.977
        zones:
          home_north_up_zone:
            coordinates: 0,0,0.413,0,0.431,0.41,0.576,0.446,0.679,0.491,1,0.712,1,0.84,1,1,0,1
            loitering_time: 0
            inertia: 3
      home_north_down:
        enabled: true
        detect:
          enabled: true
          width: 1280
          height: 720
          fps: 5
        ffmpeg:
          inputs:
            - path: rtsp://admin:xxx@127.0.0.1:8554/home_north_down
              roles:
                - detect
                - record
                - audio
        motion:
          mask: 0.706,0.928,0.956,0.923,0.955,0.974,0.706,0.977
    

Jellyfin

Jellyfin 不多做介绍了,不怎么会玩,实时转码不要超过 1080P 的视频就行,配置中记得开启 RKMPP

ha-green-armbian4

  • docker-compose.yml

    services:
      jellyfin:
        image: jellyfin/jellyfin:10.9.11
        container_name: jellyfin
        volumes:
          - /etc/localtime:/etc/localtime:ro
          - /opt/jellyfin/conf:/config
          - /opt/jellyfin/cache:/cache
          - /mnt/da/jellyfin:/media
        environment:
          - TZ=Asia/Shanghai
        network_mode: host
        restart: always
        privileged: true
        command:
          - for dev in dri dma_heap mali0 rga mpp_service iep mpp-service vpu_service vpu-service hevc_service hevc-service rkvdec rkvenc vepu h265e ; do [ -e "/dev/$dev" ] && echo " --device /dev/$dev"; done