Add on: RTSPtoWeb and RTSPtoWebRTC

Yeah i don’t want to trivialize what it would take to make it “official”. Additionally, I think what is needed is to figure out how to plumb through the RTSP server address, etc likely involving changing the camera apis, etc.

The work for getting WebRTC a proposal like this for nest: https://github.com/home-assistant/architecture/discussions/640 and https://github.com/home-assistant/architecture/discussions/658 for getting this component to work. Something similar would be needed to make MSE official.

I think maybe what is interesting is to follow https://github.com/deepch/RTSPtoWebRTC/issues/148 – my impression is the existing recipe for the custom component involves port forward when not using MSE.

Edit: Also here is some context on a previous discussion about add-on vs custom component: https://github.com/AlexxIT/WebRTC/issues/138 and the pros and cons.

I’m running Raspbian OS with HA in Docker. While setting up the integration I have to fill some server. Which server should I run? Could you please give more information about it?

Hi, this forum post is about the Home Assistant OS Add-on that packages an existing project(s). You can use either https://github.com/deepch/RTSPtoWeb or https://github.com/deepch/RTSPtoWebrtc as described in the integration page

2 Likes

Hello anyone got it working with Eufy Cameras?

3 Likes

Thanks for putting this together, really is a huge improvement to the stream experience. Couple of things I’ve noticed.

  • It only works with the insecure from the UniFi Protect integration. Trying to access the secure feeds gives the error:

    Failed to start WebRTC stream: RTSPtoWeb server failure: stream channel codec not ready, possible stream offline: Internal Server Error
    1
    

    In the front end and:

    time="2022-02-05T11:19:31Z" level=info msg="Run stream" call=Run channel=0 func=StreamServerRunStreamDo module=core stream=camera.g4_doorbell_high
    time="2022-02-05T11:19:31Z" level=error msg="Stream error restart stream x509: certificate is valid for 127.0.0.1, fe80::1, not <PROTECT_SERVER_IP>" call=Restart
    

    In the add on logs

    - I get a connection_refused error when trying to open the web UI, I’m guessing this is a https issue or similar? ok needed a port forward, worth adding to the docs?

Let me know if you want me to spin either of these out into GitHub issues or if I’m missing something obvious

Thanks again, the is really such a huge improvement!

For anyone wondering how to run this with HA Docker installation:

  1. Get addon from allenporter (Allen Porter) / Packages (github.com) and run it with docker beside HA container

ie.

docker pull ghcr.io/allenporter/aarch64-rtsp-to-web:latest
  1. Configure HA Integration with URL to http://<your_ip>:8083
  2. Add Picture card with your camera as described at post #19

BTW great work, it really improved experience.

2 Likes

Hi Tom, @AngellusMortis also mentioned that RTSPS url for unifi protect is not working. @AngellusMortis was suggestion that perhaps we need to disable certificate validation to make this work.

Yes, I think it would make sense to file an issue in the upstream project e.g. RTSPtoWeb to start? (I follow issues there fwiw)

For background, I have RTSPS working for nest (as of https://github.com/deepch/vdk/pull/41). I think this would need to be an option, since I wouldn’t want certificate validation disabled for nest, for example. I have to admit I am less familiar with the security implications of using RTSPS with an invalid certificate.

As for the port forward, are you talking about something like this? https://github.com/alexxit/webrtc#webrtc-external-access – yeah lots of folks are having trouble figuring this out, so improving documentation there would be great. Maybe sharing notes on https://github.com/allenporter/stream-addons/issues/25 would be a good start since i think its similar to what you’re talking about.

Certificate validation exist so you as the client can tell whether or not you should “trust” the secure connection. For things like Websites where you are entering personal and/or payment information, this is very important. What if someone replaced the connection (MITM attack)?

However, for cameras, you are simply receiving data. Sure, if someone replaced the connection, they should send a malicious payload to your RTSPS client, but the same could be said if you were using RTSP without any kind of encryption. So, a certificate validation for RTSPS does not provide much benefit. Especially if the RTSPS connection is over LAN 9as is the case with UniFi Protect for sure).

Thanks, i was assuming something like that (e.g. i’m not entering a username and password, and just getting back a feed), but didn’t feel confident.

Does using RTSPS on unifi protect offer additional value? I don’t have much experience using SSL with invalid certificates, but naively it seems like equivalent security to RTSP.

(In the nest case i have to pass in an authentication token in the URL, and I wouldn’t want to pass that to a malicious server, for example, so i feel like we can’t change the default to disable this. One option is to make it an option that you can disable, though making it seamless also would be nice (e.g. either automatically enable this option, or always send an RTSP url to rtsp-to-webrtc from unifi protect)

On UniFi Protect, there is an “RTSP alias” that is essentially the password (but it is only like 8 characters). The alias is the URI path since all of the camera feeds are aggregated onto the NVR.

Also, UniFi Protect no longer tells you the RTSP URL (non-secure), so it can be assume it is deprecated and may be removed in the future. So, the RTSPS is the preferred URL to use.

OK, it seems like allowing invalid certs as a configuration option may be the way to go? @TomBrien perhaps we start by filing an issue in the upstream server, then we can figure out the best way to plumb through as an option in the add-on.

1 Like

@allenporter sounds good, I’ll put in an upstream issue (and link to this discussion) this evening. Thanks for the insights @AngellusMortis :slight_smile:

Sorry I meant the port forward to the webUI (I missed this isn’t using Ingress). Since my production instance is only accessible via HTTPS and the appropriate (external) domain, I needed to add a forwarding rule.

On the upstream GitHub issue, opened here.

Would like to know how to make it work externally as well. Currently revert back to Alex’s custom component.

Hi, I have installed RTSPtoWeb, which was not working in picture-glance. Then I installed RTSPtoWebRTC, this is on is working. I’m using HA core on ubuntu. I have little problem with this ingergration, sometimes, when I switch between cards, the video become black, or white and doesn’t load until I refresh the site. Maybe an option to disable on_demand for RTSPtoWeb would help. Or an option to load videos stored in config.json (where I have on_demand disabled for selected streams) of RTSPtoWeb server. Thanks (sorry for my bad english)

First of all Thank you for creating this option!
I love this working local as I no longer have the 10 to 30 second delay in the camera stream when I am local. Real time is more important local than it is remote. Would it be possible to use WebRTC when local and RTSP when remote?
I would be fine with having different lovelace views.

You may prefer to just use HLS which was updated to use Low Latency HLS by default. You should no longer see a 10-30 second delay, but something more like 3-5 seconds.

Great video from Chris on this add-on, and a deep dive into Low Latency HLS

1 Like

Hello everybody. As I am new to the Home-Assistand Community, I just wanted to have my Eufy-cams work on my Dashboard. After installing the RTSPtoWeb Integration I have to enter the URL for RTSPtoWeb Server. I thought I have to enter the IP of my Eufy Homebase in this way https://192.168.xxx.xxx but after doing this, HA is telling me, that the communication is not possible. Is it really the Eufy Homebase-IP? or what is meant here?

thank you all in advance

just watched Chris’ vid. Trying to type in the URL from the web-UI when back home. I’ll get back if this doesn’t work. Thank you