SECUREXSECURITY ENGINEERINGNVR 文档

go2rtc 转流与 Restream

go2rtc 让 Securex NVR 只建立少量稳定的上游摄像头连接,再把同一源流提供给 FFmpeg、WebRTC/MSE、Home Assistant 或其他客户端。对连接数有限、RTSP 不稳定或需要低延迟播放的摄像头尤其重要。

推荐拓扑

摄像头 → go2rtc → Securex FFmpeg / 浏览器。这样 detect、record 和 Live 可以复用同一个上游连接,而不是每个功能各自直接连接摄像头。

示例

go2rtc:
  streams:
    front:
      - rtsp://user:password@192.168.1.50:554/stream1
    front_sub:
      - rtsp://user:password@192.168.1.50:554/stream2

cameras:
  front:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_sub
          input_args: preset-rtsp-restream
          roles: [detect]
        - path: rtsp://127.0.0.1:8554/front
          input_args: preset-rtsp-restream
          roles: [record]

命名建议

  • 主码流与子码流使用明确后缀,如 front / front_sub。
  • 摄像头配置名称与 go2rtc stream 名称保持可读关系。
  • 密码包含 @、:、# 等字符时要正确 URL 编码,避免解析失败。

如何验证

  1. 先在 go2rtc 页面/接口确认 stream 可持续播放。
  2. 再让 FFmpeg 指向 127.0.0.1:8554 的 restream。
  3. 最后测试 Live 的 WebRTC/MSE;不要一开始同时修改摄像头、go2rtc 和 FFmpeg 三层。

常见问题

  • go2rtc 能看但 Securex 不录像:检查 camera.ffmpeg.inputs 与 roles。
  • 浏览器低延迟播放失败:检查 WebRTC 端口、候选地址、防火墙/NAT。
  • 摄像头经常掉线:先在 go2rtc 层确认是否是源设备问题。

go2rtc restreaming

go2rtc keeps a small number of stable upstream camera sessions and reuses them for FFmpeg, WebRTC/MSE, Home Assistant, or other consumers. This is valuable for cameras with connection limits or fragile RTSP implementations.

Recommended topology

Camera → go2rtc → Securex FFmpeg/browser. Detection, recording, and live playback can then reuse the same upstream source.

Example

go2rtc:
  streams:
    front:
      - rtsp://user:password@192.168.1.50:554/stream1
    front_sub:
      - rtsp://user:password@192.168.1.50:554/stream2

cameras:
  front:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_sub
          input_args: preset-rtsp-restream
          roles: [detect]
        - path: rtsp://127.0.0.1:8554/front
          input_args: preset-rtsp-restream
          roles: [record]

Naming

  • Use clear main/sub names such as front and front_sub.
  • Keep camera and go2rtc names easy to relate.
  • URL-encode reserved characters in credentials.

Verification order

  1. Verify continuous playback in go2rtc first.
  2. Point FFmpeg to the local restream next.
  3. Test WebRTC/MSE last; do not change all layers simultaneously.

Common issues

  • go2rtc plays but no recording: inspect FFmpeg inputs and roles.
  • Low-latency playback fails: inspect WebRTC ports, candidates, firewall/NAT.
  • Repeated disconnects: prove source stability at the go2rtc layer first.

Restream con go2rtc

go2rtc mantiene pocas conexiones hacia las cámaras y reutiliza los streams para FFmpeg, WebRTC/MSE, Home Assistant u otros clientes.

Topología recomendada

Cámara → go2rtc → FFmpeg/navegador. Así detección, grabación y Live comparten la fuente.

Ejemplo

go2rtc:
  streams:
    front:
      - rtsp://user:password@192.168.1.50:554/stream1
    front_sub:
      - rtsp://user:password@192.168.1.50:554/stream2

cameras:
  front:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_sub
          input_args: preset-rtsp-restream
          roles: [detect]
        - path: rtsp://127.0.0.1:8554/front
          input_args: preset-rtsp-restream
          roles: [record]

Nombres

  • Use nombres claros main/sub.
  • Relacione nombres de cámara y go2rtc.
  • Codifique caracteres reservados en credenciales.

Orden de prueba

  1. Compruebe go2rtc.
  2. Después configure FFmpeg con el restream local.
  3. Finalmente pruebe WebRTC/MSE.

Problemas

  • go2rtc funciona pero no graba: revise inputs/roles.
  • Falla baja latencia: revise puertos/candidates/firewall.
  • Desconexiones: compruebe primero la fuente.
输入关键词开始搜索