go2rtc 直連小米攝影機 RTSP:接入 NVR、HomeKit、Frigate

記錄使用 go2rtc 直接取得小米攝影機 RTSP 流,並接入 NVR、HomeKit、Frigate 的配置方式。

這篇整理如何用 go2rtc 直接拉取小米攝影機串流,並同時供 NVR、HomeKit、Frigate 使用。

Docker 部署範例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
services:
  go2rtc:
    container_name: go2rtc
    image: alexxit/go2rtc:master-hardware
    restart: always
    network_mode: host
    privileged: true
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - /vol1/1000/docker/go2rtc:/config

go2rtc 後台位址:

1
http://192.168.3.217:1984/

串流設定範例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
streams:
    micam1:
     - xiaomi://xxx
    #H265转H264,Homekit预览会用到
    #micam1_h264:
     #- ffmpeg:micam1#video=h264#width=1280#height=720#hardware#raw=-r 15
    micam2:
     - xiaomi://xxx
    micam3:
     - xiaomi://xxx

RTSP 串流位址格式:

1
rtsp://192.168.3.217:8554/micam1

畫質與參數

畫質可用 05 指定:

  • 0 通常代表自動
  • 1 代表 sd
  • 2 代表 hd(go2rtc 預設)

部分新款攝影機的 HD 可能對應 3。舊款在 3 可能出現編解碼異常,因此不建議所有設備都用同一數值。

可用 subtype=hd/sd/auto/0-5 指定畫質:

1
2
streams:
  xiaomi1: xiaomi://***&subtype=sd

雙鏡頭可使用第二通道 channel=2

1
2
streams:
  xiaomi1: xiaomi://***&channel=2

小結

把 go2rtc 放在前面統一拉流後,一路 RTSP 就能同時服務 NVR 錄影、Frigate 分析、HomeKit 預覽,管理會更簡單。

參考連結

  • 攝影機支援列表:https://github.com/AlexxIT/go2rtc/issues/1982
  • 官方說明出處:https://github.com/AlexxIT/go2rtc/blob/master/internal/xiaomi/README.md
  • Docker 映像:https://hub.docker.com/r/alexxit/go2rtc
记录并分享
使用 Hugo 建立
主題 StackJimmy 設計