Hi there for any reader,
as I have made a lot of tests and to give an other answer at the OP subject here is some informations about HA configuration to get reliable WebRTC with very small delay.
This is the setup I use at the moment and it may change in the futur depending on the progress of the differents projects, mainly RTSPToWeb and go2rtc.
In short :
RTSPToWeb as a server/service (easiest way is Docker)
RTSPToWebRTC intégration in HA configured with the RTSPToWeb ip/port and a public STUN server if you dont have one or dont want care.
Cards in HA : picture-glance or picture-entity
I have heavily tested this configuration and it give me reliable and nearly “no-delay” video even from a WAN access (test from mobile device/computer), but there are some settings that should be done if you dont want the Video player to fall back to HLS
1 - configure RTSPToWeb (config.json) :
a - You must set a range of UDP port to use, It seems to not use WebRTC and fallback to HLS if you do not set this two configuration keys.
ex config.json :
....
"webrtc_port_max": 41000,
"webrtc_port_min": 40000
....
b - Forward this range of UDP port (40000-41000) from your internet router/WAN access to your HA/RTSPToWeb device IP (if you have more than one router between your device and WAN access you may have to do it on each router)
2 - configure RTSPToWebRTC intégration in HA :
a - set the IP:port of your RTSPToWeb server
b - configure it with a STUN server, there are some public one :
You dont need to configure RTSPToWeb (config.json) streams, once the integration is working they will be automatically created on the fly.
You can verify that it is working by using the browser debugger (F12) and look at the video element, you should see that its parent is a “ha-web-rtc-player” :
If you see “ha-web-hls-player”, this mean that you miss something in the configuration somewhere.
On a computer client you can also use Wireshark to verify the Network traffic, you should see a lot of UPD packets using the range of UDP port you have configured while watching a video cam :
As this configuration works so well that I would recommend to :
- uncheck preload video (on HA camera entity)
- set “on_demand” to true in config.json for RTSPToWeb server
Doing that make all resources are released after few seconds when no one watch the cameras (CPU == 0/Network == 0) and camera still start in 4/5 seconds and display video with very low latency (often < 1s)
The only downside I found with RTSPtoWeb is that for some camera (not all) the sound is delayed
Note : you can easily access to RTSPtoWeb web interface with a browser by using the same URL you have configured in the RTSPToWebRTC HA integration, there you can see all auto registered streams, test them, and set “on_demand” setting on or off.
Hope it will help !