Deprecated
The RTSPtoWebRTC Add-on is no longer active. You are recommended to use the go2rtc Add-on which is actively maintained.
The original post has been preserved below.
About
The RTSPtoWeb add-on lets you convert your RTSP streams to WebRTC, HLS, LL HLS, or even mirror as a RTSP stream. The RTSPtoWeb add-on is a packaging of the existing project GitHub - deepch/RTSPtoWeb: RTSP Stream to WebBrowser which is an improved version of GitHub - deepch/RTSPtoWebRTC: RTSP to WebRTC use Pion WebRTC project.
This add-on can use the integration RTSPtoWebRTC - Home Assistant to automatically convert home assistant RTSP cameras to use the WebRTC frontend player native in Home Assistant.
Installation
1. Configure your camera
Before starting, you should already have a camera configured with a Camera integration, e.g. any of these Integrations - Home Assistant and have it working in Home Assistant e.g. with a Picture glance card - Home Assistant card set to live
, etc.
By the way, LL-HLS
is enabled by default in stream
as of 2022.02 which may give you low enough latency that you can stop here.
2. Configure Add-on Repo
You first need to configure the add-on repository GitHub - allenporter/stream-addons: Stream related Add-ons for Home Assistant OS in Home Assistant.
3. Install and Start RTSPtoWeb Add-on
Next, you then can install the RTSPtoWeb Add-On, and start it. Make sure to check out the documentation, and caveats. RTSPtoWeb is preferred over RTSPtoWebRTC though there are add-ons for both.
4. Configure RTSPtoWebRTC integration
Lastly, the RTSPtoWebRTC integration should be automatically discovered. Navigate to the integrations dashboard in Home Assistant.
Note: If you aren’t using Home Assistant OS or and are using this integration with an external RTSPtoWeb server or RTSPtoWebRTC server you’ll config a url instead, which isn’t discussed here.
5. Configure Remote Access
The integration also supports using a STUN server for accessing your camera remotely over WebRTC. Click the Configure button on the integration you set up in the previous step, and enter a stun server such as stun.l.google.com:19302
. The Home Assistant frontend WebRTC player will use this when talking to RTSPtoWeb.
Troubleshooting
The integration may not work for your particular setup, and Home Assistant core team cannot support and troubleshoot user problems that are unrelated to the actual integration in Home Assistant.
The WebRTC stream negotiation process and streaming can very a lot depending on your network setup and camera setup. See the specific audio and video codecs supported at RTSPtoWeb Limitations and RTSPtoWebRTC Limitations.
Technical Details
RTSPtoWebRTC registers with the camera integration to override the existing camera stream, instructing it to use WebRTC instead of HLS.
See WebRTC for more technical details on the open standard for real-time communication. Here is a short summary of how it works:
- The Home Assistant Frontend is a WebRTC client. This just means there is some javascript for initiating a WebRTC stream which creates an offer.
- The
webrtc
integration is responsible for signaling, passing the offer and an RTSP URL to the RTSPtoWebRTC server. - The RTSPtoWeb{RTC} server opens the RTSP URL, and returns back an answer.
- The Frontend accepts the answer and then establishes a peer connection to the RTSPtoWebRTC server.
- Establishing a peer connection may be a direct connection on the local network, or using a variety of techniques to communicate through a NAT (e.g. with a STUN server).
- The Frontend then communicates directly with the RTSPtoWeb{RTC} proxy server to view the stream.
See Getting started with peer connections for more on the technical details.