go2rtc
go2rtc 用于统一接入 RTSP、WebRTC / MSE、转流与双向音频。
基础示例
go2rtc:
streams:
front_main:
- rtsp://user:password@192.168.1.10:554/main
front_sub:
- rtsp://user:password@192.168.1.10:554/sub
WebRTC 示例
go2rtc:
webrtc:
candidates:
- 192.168.1.100:8555
- stun:stun.l.google.com:19302
port_min: 8555
port_max: 8559
验证
先在 go2rtc 管理页确认视频可播放,再把 rtsp://127.0.0.1:8554/STREAM_NAME 交给摄像头输入。这样可减少摄像头并发连接数量。
常见问题
- RTSP 账号密码包含特殊字符时注意 URL 编码。
- WebRTC 不通时检查 8555/UDP、NAT 与候选地址。
- 双向音频依赖摄像头音频编码、协议与 go2rtc 支持情况。
go2rtc
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
- Verify continuous playback in go2rtc first.
- Point FFmpeg to the local restream next.
- 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.
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
- Compruebe go2rtc.
- Después configure FFmpeg con el restream local.
- 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.
