Realtime camera streaming without any delay - WebRTC

what dashboard do u use? something like dwan’s dashboard? or HKI?
I made a script wich is called when clikcing on the camera image on my dasboard (hki and dwain’s) you can also make a glance picture thing and call a script. mine looks like:

garage_cam_popup:
  sequence:
    - service: browser_mod.popup
      data:
        title: Live View...
        large: true
        hide_header: true
        # auto_close: false
        card:
          type: 'custom:webrtc-camera'
          url: 'rtsp://40.40.40.220:554/media/stream1'
2 Likes

I use neither dwan nor HKU’s card, just the brand new default WebRTC lovelace card.

Thanks for the tip ! I will have a look at that.

I have the same issue with my Dahua camera as well. For some reason the stream plays in 4:3.

Nice. 2 way audio works? What are you using for sip to WebRTC gateway?

I have 2 way audio working using sip between the doorbell and a softphone installed on the receiving tablet so far and I currently have 1 way audio and video using Alexxit’s component in WebRTC. I am using freepbx (asterisk) that is running as a virtual machine on my network the only thing currently blocking 2 way audio is I can’t work out how to create a CA authority certificate that has a hostname that resolves to the virtual machine on my local network, but I think that once that’s working the 2 way audio will work and the Alexxit’s component proves that it’s worth doing using webrtc!

1 Like

The latest version has changed the default setting of the UDP port range. If you have changed it before - set two zeros in the integration settings and disable UDP port forwarding on the router.

This should work fine for most users.

Use port forwarding only if you’re having trouble connecting.

A small number of ports with a large number of cameras on a page works very badly. There should be many more ports than cameras.

1 Like

Good day.
Im getting this error on the card “Opera doesn’t supported”
tried adding manually to resources with this:

  # - url: /custom_components/webrtc/local/webrtc-camera.js
  #   type: module   

and then i get “Custom element doesn’t exist: webrtc-camera.”

any guidance is much appreciated

I keep getting this error from one camera that is connected via repeater:

Can't start stream: rtsp://192.168.XXX.XXX/ch0_0.h264, because: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('http://localhost:8083/stream')

Stream from this camera works in traditional way in HA…Any idea?

You may enable debug and check something interesting there

1 Like

I’m curious, is there any way to configure the default action of the card to pause the stream rather than play it?

Looked promising, but…

HassOS is running in a VM. Tried to add a Sonoff Camera but while it sometimes seems to work it stays forever on ‘init connection’, then ‘trying to start stream’. Sometimes it shows the stream, sometimes it don’t. When showing the stream you can the stream hanging (seconds don’t update) and eventually stops and tries to reconnect.

image

VM is running on a new i3 NUC and MotionEye run2 three rtsp stream easily (in a different VM). Also tried to stop the MotionEye container, but that doesn’t help.

Unfortunate…

Trying to start stream means problem between home assistant server and camera. It’s strange because Sonoff camera works well in my case

And the rtsp streams work perfectly in MotionEye as well. Tried both accessing the HA instance through local IP (no SSL) and external domain through NGINX + SSL.

OK. This is what I’ve got:

2021-04-22 13:51:19 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 13:51:19 Stream Try Connect rtsp://192.168.1.7/ch0_0.h264
2021-04-22 13:51:22 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 13:51:22 dial tcp 192.168.1.7:554: i/o timeout
2021-04-22 13:51:22 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 13:51:22 Stream Exit On Demand No Viewer
2021-04-22 13:51:24 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 13:51:24 Stream Codec Not Found
2021-04-22 13:51:24 DEBUG (webrtc) [custom_components.webrtc.utils] [GIN] 2021/04/22 - 13:51:24 | 200 |  5.032313842s |       127.0.0.1 | POST     "/stream"
2021-04-22 13:51:24 ERROR (MainThread) [custom_components.webrtc] Can't start stream: rtsp://192.168.1.7/ch0_0.h264, because: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('http://localhost:8083/stream')
2021-04-22 13:51:25 ERROR (MainThread) [custom_components.webrtc] Can't start stream: None, because: 'camera'
2021-04-22 13:51:27 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 13:51:27 Set ICEServers [stun:stun.l.google.com:19302]
2021-04-22 13:51:27 DEBUG (webrtc) [custom_components.webrtc.utils] [GIN] 2021/04/22 - 13:51:27 | 200 |  147.851143ms |       127.0.0.1 | POST     "/stream"

habe the same issue since today :frowning: Opera not supported. i use chrome not opera and i have all cams running well . i ununstalled and added the component again but no success … any solutions here? logs:

2021-04-22 14:46:25 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 14:46:25 terminated
2021-04-22 14:46:25 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 14:46:25 Exiting
2021-04-22 14:46:25 DEBUG (webrtc) [custom_components.webrtc.utils] 2021/04/22 14:46:25 Server Start Awaiting Signal

that’s all i see

EDIT: Works with latest version.

Is there any way to hardcode that it opens in fullscreen was watchng the code but didn’t find the right part of the code i fear :frowning: Maybe it’s possible to have a config opetion to start stream in fullscreen?

Thank you @AlexxIT. I have had a Grandstream GDS3710 door station and the lag on video made it very unfriendly. With you project it is working well. Thank you so much.
I am finding since the last update that the card seems to be takign a long time to start.

The card is saying Init connection and if I hit f12. I see the following. The logs seem normal.
‘Uncaught DOMException: Failed to execute ‘define’ on ‘CustomElementRegistry’: the name “webrtc-camera” has already been used with this registry’
Do you have any suggestions.
Thank you again for this amazing project.

Try to find a version when all works fine (reinstall from HACS).

I’m getting the same issue with 1.3: Chrome reports same DOME exception.
Strangely it works for me on android (either in HomeAssistant app or in Chrome for android)

The debug log reports:

2021-04-23 13:46:30 DEBUG (webrtc) [custom_components.webrtc.utils] [GIN] 
2021/04/23 - 13:46:30 | 200 | 63.28649ms | 127.0.0.1 | POST "/stream"

2021-04-23 13:46:30 DEBUG (MainThread) [custom_components.webrtc] New stream to url: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

2021-04-23 13:46:34 DEBUG (webrtc) [custom_components.webrtc.utils] 
2021/04/23 13:46:34 Client Not Send ACK (probably the browser is minimized) or tab not active Close client

2021-04-23 13:46:34 DEBUG (webrtc) [custom_components.webrtc.utils] 
2021/04/23 13:46:34 Stream Not Send Video Close

2021-04-23 13:46:34 DEBUG (webrtc) [custom_components.webrtc.utils] 
2021/04/23 13:46:34 WritePacket WebRTC Client Offline

Welcome any thoughts on how to solve this!

This is great! Got it working with the Eufy Indoor 1080 and the 2k; but sadly no sound since they both us AAC for audio.

I haven’t tried rolling back to different versions, but I just tired Edge and the card loads in a few seconds, yet with Chrome it takes around 40 seconds and shows init connection during that time. I would prefer chrome. Any suggestions why Edge works so much faster than Chrome?