WebRTC
WebRTC Client
This source type supports four connection formats.
Creality
Creality 3D printer camera. Read more here.
streams:
creality_k2p: webrtc:http://192.168.1.123:8000/call/webrtc_local#format=crealitygo2rtc
This format is only supported in go2rtc. Unlike WHEP, it supports asynchronous WebRTC connections and two-way audio.
streams:
webrtc-go2rtc: webrtc:ws://192.168.1.123:1984/api/ws?src=camera1Kinesis
Supports Amazon Kinesis Video Streams, using WebRTC protocol. You need to specify the signaling WebSocket URL with all credentials in query params, client_id and ice_servers list in JSON format.
streams:
webrtc-kinesis: webrtc:wss://...amazonaws.com/?...#format=kinesis#client_id=...#ice_servers=[{...},{...}]PS. For kinesis sources, you can use echo to get connection params using bash, python or any other script language.
OpenIPC
Cameras on open-source OpenIPC firmware.
streams:
webrtc-openipc: webrtc:ws://192.168.1.123/webrtc_ws#format=openipc#ice_servers=[{"urls":"stun:stun.kinesisvideo.eu-north-1.amazonaws.com:443"}]SwitchBot
Support connection to SwitchBot cameras that are based on Kinesis Video Streams. Specifically, this includes Pan/Tilt Cam Plus 2K and Pan/Tilt Cam Plus 3K and Smart Video Doorbell. Outdoor Spotlight Cam 1080P, Outdoor Spotlight Cam 2K, Pan/Tilt Cam, Pan/Tilt Cam 2K, Indoor Cam are based on Tuya, so this feature is not available.
streams:
webrtc-switchbot: webrtc:wss://...amazonaws.com/?...#format=switchbot#resolution=hd#play_type=0#client_id=...#ice_servers=[{...},{...}]WHEP
WebRTC/WHEP is replaced by WebRTC/WISH standard for WebRTC video/audio viewers. But it may already be supported in some third-party software. It is supported in go2rtc.
streams:
webrtc-whep: webrtc:http://192.168.1.123:1984/api/webrtc?src=camera1Wyze
Legacy method to connect to Wyze cameras using WebRTC protocol via docker-wyze-bridge. For native P2P support without docker-wyze-bridge, see Source: Wyze.
streams:
webrtc-wyze: webrtc:http://192.168.1.123:5000/signaling/camera1?kvs#format=wyzeWebRTC Server
What you should know about WebRTC:
- It's almost always a direct peer-to-peer connection from your browser to the go2rtc app
- When you use Home Assistant, Frigate, Nginx, Nabu Casa, Cloudflare, and other software, they are only involved in establishing the connection; they are not involved in transferring media data
- WebRTC media cannot be transferred inside an HTTP connection
- Usually, WebRTC uses random UDP ports on the client and server to establish a connection
- Usually, WebRTC uses public STUN servers to establish a connection outside the LAN; these servers are only needed to establish a connection and are not involved in data transfer
- Usually, WebRTC will automatically discover all of your local and public addresses and try to establish a connection
If an external connection via STUN is used:
- Uses UDP hole punching technology to bypass NAT even if you haven't opened your server to the world
- For about 20% of users, the technology will not work because of the Symmetric NAT
- UDP is not suitable for transmitting 2K and 4K high bit rate video over open networks because of the high loss rate:
Configuration suggestions
- by default, WebRTC uses both TCP and UDP on port 8555 for connections
- you can use this port for external access
- you can change the port in YAML config:
webrtc:
listen: ":8555" # address of your local server and port (TCP/UDP)Static public IP
- forward the port 8555 on your router (you can use the same 8555 port or any other as external port)
- add your external IP address and external port to the YAML config
webrtc:
candidates:
- 216.58.210.174:8555 # if you have a static public IP addressDynamic public IP
- forward the port 8555 on your router (you can use the same 8555 port or any other as the external port)
- add
stunword and external port to YAML config- go2rtc automatically detects your external address with STUN server
webrtc:
candidates:
- stun:8555 # if you have a dynamic public IP addressHard tech way 1. Own TCP-tunnel
If you have a personal VPS, you can create a TCP tunnel and setup in the same way as "Static public IP". But use your VPS IP address in the YAML config.
Hard tech way 2. Using TURN-server
If you have personal VPS, you can install TURN server (e.g. coturn, config example).
webrtc:
ice_servers:
- urls: [stun:stun.l.google.com:19302]
- urls: [turn:123.123.123.123:3478]
username: your_user
credential: your_passFull configuration
Important! This example is not for copy/pasting!
webrtc:
# fix local TCP or UDP or both ports for WebRTC media
listen: ":8555" # address of your local server
# add additional host candidates manually
# order is important, the first will have a higher priority
candidates:
- 216.58.210.174:8555 # if you have static public IP-address
- stun:8555 # if you have dynamic public IP-address
- home.duckdns.org:8555 # if you have domain
# add custom STUN and TURN servers
# use `ice_servers: []` to remove defaults and leave it empty
ice_servers:
- urls: [ stun:stun1.l.google.com:19302 ]
- urls: [ turn:123.123.123.123:3478 ]
username: your_user
credential: your_pass
# optional filter list for auto-discovery logic
# some settings only make sense if you don't specify a fixed UDP port
filters:
# list of host candidates from auto-discovery to be sent
# includes candidates from the `listen` option
# use `candidates: []` to remove all auto-discovery candidates
candidates: [ 192.168.1.123 ]
# enable localhost candidates
loopback: true
# list of network types to be used for the connection
# includes candidates from the `listen` option
networks: [ udp4, udp6, tcp4, tcp6 ]
# list of interfaces to be used for the connection
# includes interfaces from unspecified `listen` option (empty host)
interfaces: [ eno1 ]
# list of host IP addresses to be used for the connection
# includes IPs from unspecified `listen` option (empty host)
ips: [ 192.168.1.123 ]
# range for random UDP ports [min, max] to be used for connection
# not related to the `listen` option
udp_ports: [ 50000, 50100 ]By default, go2rtc uses a fixed TCP port and fixed UDP ports for each direct WebRTC connection: listen: ":8555".
You can set a fixed TCP port and a random UDP port for all connections: listen: ":8555/tcp".
You can also disable the TCP port and leave only random UDP ports: listen: "".
Configuration filters
Important! By default, go2rtc excludes all Docker-like candidates (172.16.0.0/12). This cannot be disabled.
Filters allow you to exclude unnecessary candidates. Extra candidates don't make your connection worse or better. But the wrong filter settings can break everything. Skip this setting if you don't understand it.
For example, go2rtc is installed on the host system. And there are unnecessary interfaces. You can keep only the relevant via interfaces or ips options. You can also exclude IPv6 candidates if your server supports them but your home network does not.
webrtc:
listen: ":8555/tcp" # use fixed TCP port and random UDP ports
filters:
ips: [ 192.168.1.2 ] # IP-address of your server
networks: [ udp4, tcp4 ] # skip IPv6, if it's not supported for youFor example, go2rtc is inside a closed Docker container (e.g. Frigate). You shouldn't filter Docker interfaces; otherwise, go2rtc won't be able to connect anywhere. But you can filter the Docker candidates because no one can connect to them.
webrtc:
listen: ":8555" # use fixed TCP and UDP ports
candidates: [ 192.168.1.2:8555 ] # add manual host candidate (use docker port forwarding)Streaming ingest
Ingest: Browser
You can turn the browser of any PC or mobile into an IP camera with support for video and two-way audio. Or even broadcast your PC screen:
- Create empty stream in the
go2rtc.yaml - Go to go2rtc WebUI
- Open
linkspage for your stream - Select
camera+microphoneordisplay+speakeroption - Open
webrtclocal page (your go2rtc should work over HTTPS!) orshare linkvia WebTorrent technology (work over HTTPS by default)
Ingest: WHIP
You can use OBS Studio or any other broadcast software with WHIP protocol support. This standard has not yet been approved. But you can download OBS Studio dev version:
- Settings > Stream > Service: WHIP >
http://192.168.1.123:1984/api/webrtc?dst=camera1
Useful links
- https://www.ietf.org/archive/id/draft-ietf-wish-whip-01.html
- https://www.ietf.org/id/draft-murillo-whep-01.html
- https://github.com/Glimesh/broadcast-box/
- https://github.com/obsproject/obs-studio/pull/7926
- https://misi.github.io/webrtc-c0d3l4b/
- https://github.com/webtorrent/webtorrent/blob/master/docs/faq.md