Add on: RTSPtoWeb and RTSPtoWebRTC

Deprecated

Update Nov 2024: Home Assistant now uses go2rtc - Home Assistant by default for all RTSP streams. The RTSPtoWebRTC Add-on is no longer active.

The original post is 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

https://www.youtube.com/watch?v=6hJXenSZJ5M

### 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.

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

## 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.

Open your Home Assistant instance and show your integrations.

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.

11 Likes

Hello!
Does this integration have anything in common with THIS integration from AlexIT ? Should we remove Alex’s plugin after update HA to 2022.2 or it’s just that these are two different integrations (with maybe different functions)?

2 Likes

Ah cool, this will generate an camera entity? Because the one from Alex is a custom card, right that’s means we can now also stream camera to google hub devices?

Hi, this is a re-package of some of the parts of Alex’s custom component. There are definitely differences, but also a lot of similarities.

If you are already using the custom component, and are happy with it, i’m not sure there is necessarily a big reason for you to upgrade.

Alex’s custom component downloads the go binary RTSPtoWebRTC on the fly, uses custom lovelace cards I believe, and has a bunch of great compatibility with more network setups using MSE.

The integration rtsp_to_webrtc is a core integration so its less likely to break on new releases. It “overrides” your existing camera entity and stream, and replaces the it with the home assistant standard WebRTC stream card that is native in home assistant. This is the same webrtc mechanism used for other integrations like Nest. The RTSPtoWeb server is a bit better supported than RTSPtoWeb, however the integration supports both of them.

3 Likes

OK, thanks a lot for explanation. Yes, Alex’s camera works perfectly (for now). A quick look into this new integration currently just confues me… when i wanted to add integration HA asks me for a server address… :question::flushed:
So, i guess it needs some homework to figure it out how it works…

I think that’s because you needed this addon first, then the integration after that.

1 Like

On the page below , there is no mentioning of the addon, both links in the head section are pointing to the same GitHub page… Is that a type error?

Hm…the only addon available is RTSPtoWebRTC (the one which requires server address)…

My impression is that it is pretty rare for integration pages to link to add-ons as far as I understand. That’s why I made this post?

The link above has an addon for RTSPtoWeb and RTSPtoWebRTC. Not sure I follow.

Let me say it this way … follow the instructions in this post under Installation above, and make sure to note the differences between add-ons and integrations. I’ve attempted to update some of the original post above to simplify the instructions. Good luck. Just to be clear, no urls are needed if you are using the Add-on.

Aha… so, first some installation from github sources is needed… I thought that it’s all included in this new integration, so i went directly to configuration - devices - add integration, and there it’s only RTSPtoWebRTC. Now i’m closer to understand… sorry for my ignorance, but i still don’t quite understand many things in HA, even after a good year of using it… there’s just too much to learn and memorize… years and experience will (hopefully) bring more knowledge.

Many thanks!

1 Like

Sorry, but I already have a problem… addon won’t start, supposely port 8083 is occupied… ? In addon’s log there’s an error:


time="2022-02-03T09:42:17+01:00" level=fatal msg="listen tcp :8083: bind: address already in use" call=ServerHTTPPort func=HTTPAPIServer module=http_router

In terminal command netstat -nlp | grep 8083 indeed gives me back:


tcp        0      0 127.0.0.1:8083          0.0.0.0:*               LISTEN      -

if i change port to, say, 8084 nothing changes - same error, because in log there’s still port 8083 (doesnt’ change to 8084).
I have no clue what i could have on this port…any ideas?

EDIT: i think that it’s leftover from influxdb (not sure, though…), which IS uninstalled, btw… i just didn’t find yet how to stop this port from listening…

EDIT2: it’s Alex’s WebRTC integration who’s conflicting with this addon (which kinda makes sense…). After removing it new addon starts. But, since manual for these new addon is still pretty much non-existent i don’t know how to add or view a camera, so i guess i’ll stick with Alex’s addon for now…

1 Like

wow, migrated to this now, removed alex
nice to see now finally LIVE view without a delay on the camera entities!!! much appreciated! much better now then the custom card before

thnx again!!

3 Likes

Crap, seems if i use mobile connection on my android, the feed is gone
when i turn on wifi again, (local network) feed is back…

Does the camera only works locally??? is this a limitation?
with Alex custom card it worked on wifi and mobile

thnx

EDIT: ok, i think why, we also need 8083 to be open in firewall?
ok, then i can see the dasbboard now, externally, what is the default username/password anyway?

But it still doesnt work, i use nabucasa url, so my guesst it doesnt find the camera on my nabucasaurl on port 8083 ? can this be configured somewhere so it uses my public ip/dns instead?

1 Like

I also removed alex custom integration but still get these error 8083 in use :frowning: can’t figure out what application / addon uses this port.Netstat gave me same result

LOL i still had alex addon running… stupid me … back in my hole …

3 Likes

How will i get the sound running?

And it is not clear for the moment how to add this cameras to ha. have frigate also setup but only cameras from frigate are there?..a bit confusing :stuck_out_tongue:

1 Like

See RTSPtoWebRTC - Home Assistant (home-assistant.io), you should be using the RTSPtoWebRTC-addon (for the sake of clarity: not the RTSPtoWeb-addon) and keep this in mind: “Audio Codecs Supported: pcm alaw and pcm mulaw”.

  1. Add your camera to the configuration.yaml
    Generic Camera - Home Assistant (home-assistant.io)
  2. Add the picture entity card to your dashboard
    Picture Entity Card - Home Assistant (home-assistant.io)
  3. The stream is automatically using WebRTC instead of HLS. (see “Technical Details” in the first post)

I am experiencing the same issue. The custom webrtc component had some instructions on how to setup external access, so maybe that’s something that isn’t yet implemented in the add-ons of @allenporter ?