Realtime camera streaming without any delay - WebRTC

Just upgrade to HA 2021.12 and WebRTC Camera stop working. Any one with the same issue? Any solution for that?

My impression is that the developer has already fixed the issue and the latest version / master branch of the custom component needs to be used. Check out issues reported in the github repo like Error during setup of component (core-2021.12.0) · Issue #156 · AlexxIT/WebRTC · GitHub for context

Thanks, that is

isn’t WebRTC now direcetly integrated into hass with 2021.11?

or won’t this replace the custom component?

Native WebRTC implementation relies on devices to support as some devices have built-in support, this custom integration converts rtsp stream into webrtc, they are totally different.

Not quite (yet?).

  • The release notes say “initial support” which means that basic plumbing to support webrtc in the frontend and core was added in the release. (as stated, this doesn’t do anything unless an integration starts using it)
  • nest cameras were updated to support webrtc natively (e.g. new generation 2 camera models and doorbells). The nest cameras themselves support webrtc so they can use the plumbing added in the previous step.
  • The WebRTC custom component developed by @AlexxIT has a unique capability in that it converts an RTSP stream to WebRTC using an external server RTSPtoWebRTC – home assistant core doesn’t do that yet.
  • AlexxIT and I have been chatting about how we could start using that generic core support in the custom compoment in Integrate with standard Home Assistant WebRTC card · Issue #138 · AlexxIT/WebRTC · GitHub – you can see from the discussion there may be corner cases that we might not be able to support in home assistant core, so it may never be a replacement entirely for the custom component
  • I’ve started working on pulling similar functionality into core in Add `rtsptowebrtc` integration by allenporter · Pull Request #59660 · home-assistant/core · GitHub – My thought is that we’ll be able to make the very basic setup case easier to get working with an add-on, which could benefit more users broadly with simple setups, and help with test coverage to avoid breaking changes in future release.
6 Likes

I have the camera in my cottage and the HA server in my house. How can I access the camera stream(add to the HA) from a different LAN?

macOS companion app 2021.11.1 cards show as unsupported browser?

I was able to get WebRTC working but I am having issues streaming the same source on multiple mediums (ie. Web & iPhone) simultaneously.

Does anyone else have this issue or is this a limitation of WebRTC?

I too ran into this issue with symmetric NAT and WebRTC. I am running pfSense as my firewall. WebRTC would work internally but not externally. I had to create the following NAT rule to allow for WebRTC to function. I have the port range 60000-60100 configured in my WebRTC integration.

1 Like

I want to try PTZ with this, but from the example code used I get an error saying : unable to find service rest_command.camera.ptz.start

Do I have to add this service manually ?

Yes. This service will be different for many cameras.
I use the onvif integration for my camera for example and use the “onvif.ptz” service which is created when adding the camera entity,

you mean that the service is automatically added when you add the camera ? One onvif.ptz service per camera ?

Hi There
Can this be used on the portable HA version on Windows?

thats great. thanks for your effort. @allenporter & @AlexxIT

one last question since i dont know how webRTC works in detail: will it somehow be possible to view the stream over remote access since webRTC atm only works when you access Home Assistant locally, right?

Does anyone else have issues with WebRTC v2.1.0 and Firefox 0.98 on Windows 10 ? If I use Chrome on Windows 10 or the Companion App on IOS I do not see any issues. However, on Firefox under Windows 10, the stream will start and play (MSE?), once WebRTC kicks in it will continue play for about 5-10 seconds then pause, resume, pause. Sometimes it just stays paused/frozen, I use the date/time stamp of my camera to watch the progress. Any ideas? workarounds?

Edit: Added some more details.
Edit 2: For anyone else with this issue, I found that MSE works fine. If you go into about:config on firefox and set media.peerconnection.enabled to false, WebRTC wont load.
Edit 3: I can block the outbound ports on my firewall and WebRTC does not kick in. Setting media.peerconnection.enabled to false causes the plugin to fail on next browser load.

I get in Firefox console the following error:

Loading module from “https://<<REDACTED>>/webrtc/webrtc-camera.js?v2.0.2” was blocked because of a disallowed MIME type (“text/plain”).

Strange thing is that the version installed is not 2.0.2 but 2.1.0, the latest available from HACS. Did someone also experienced the problem ?

I also have Frigate Card installed, which, if I’m not wrong, also uses WebRTC js.

This is a big GitHub bug. Lost the latest 2.2.0 release. You can install the master version for now. It has the latest code version

6 Likes

@AlexxIT

are you the maintainer?

the integration doesnt work anymore, i cant set it up under integrations, it says only : “not loaded”

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 228, in _async_setup_component
    result = await task
  File "/config/custom_components/webrtc/__init__.py", line 75, in async_setup
    utils.register_static_path(hass.http.app, url_path, path)
  File "/config/custom_components/webrtc/utils.py", line 74, in register_static_path
    app['allow_cors'](route)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 186, in __getitem__
    return self._state[key]
KeyError: 'allow_cors'

there are issues on github opend

Answer in my post above

1 Like