Realtime camera streaming without any delay - WebRTC

I am still trying to sort this issue out with two of my amcrest cameras. The native resolution is 2560X1440 and in the default card they display as 16:9, on Frigate they display as 16:9, in WebRTC card they display as 4:3

@AlexxIT Hi Alexey, your add-on go2rtc is providing lag free and immediate starting video streams. An unbelievable improvement to what it was before with the integrated stream capabilities. :grinning:
Thank you so much!!

1 Like

The latest beta 6 release will let you use your nest camera by transcoding the audio. Fixed my audio since you can now reference that nest stream .

That’s amazing, just tested it after adding the camera entity_id to the go2rtc.yaml as per the updated instructions and indeed it works! I must say, the speed with which this project is maturing is truly astounding. Keep up the great work @AlexxIT!

I actually had also just gotten the iframes to work on the local network, but not yet remotely as I’m having trouble getting the nginx settings correctly. @calisro, I was just about to ask you for some help in the dedicated go2rtc thread, so I may do that as it looks like the conversation is changing to there. I’ll post there shortly.

1 Like

I’m really interested in the iframes config, even if it’s just for local network. Mind sharing (maybe a preview :wink: )?

Sure thing. I use a picture-elements card, as I also include the PTZ controls for my Foscam. Here’s my card setup. Don’t forget to define a custom location in your nginx setup if you want to use this remotely, and add the custom nginx settings as described by @calisro here.

Also, the card below assumes you’ve setup browser-mod already.

type: picture-elements
camera_image: camera.baby_cam_1
camera_view: live
elements:
  - type: image
    entity: camera.baby_cam_1
    camera_image: camera.baby_cam_1
    camera_view: live
    style:
      top: 50%
      left: 50%
      width: 100%
      opacity: 0%
    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          title: Baby Cam 1
          size: wide
          content:
            type: iframe
            url: >-
              https://yourdomain.duckdns.org/go2rtc/webrtc.html?src=camera.baby_cam_1
            aspect_ratio: 75%
  - type: icon
    icon: mdi:arrow-up
    style:
      color: rgba(255, 255, 255, 0.5)
      background: rgba(255, 255, 255, 0)
      right: 15px
      bottom: 40px
    tap_action:
      action: call-service
      service: foscam.ptz
      service_data:
        entity_id: camera.baby_cam_1
        movement: up
  - type: icon
    icon: mdi:arrow-down
    style:
      color: rgba(255, 255, 255, 0.5)
      background: rgba(255, 255, 255, 0)
      right: 15px
      bottom: '-10px'
    tap_action:
      action: call-service
      service: foscam.ptz
      service_data:
        entity_id: camera.baby_cam_1
        movement: down
  - type: icon
    icon: mdi:arrow-left
    style:
      color: rgba(255, 255, 255, 0.5)
      background: rgba(255, 255, 255, 0)
      right: 40px
      bottom: 15px
    tap_action:
      action: call-service
      service: foscam.ptz
      service_data:
        entity_id: camera.baby_cam_1
        movement: left
  - type: icon
    icon: mdi:arrow-right
    style:
      color: rgba(255, 255, 255, 0.5)
      background: rgba(255, 255, 255, 0)
      right: '-10px'
      bottom: 15px
    tap_action:
      action: call-service
      service: foscam.ptz
      service_data:
        entity_id: camera.baby_cam_1
        movement: right

If you want to use a picture-glance card you can also use this code.

2 Likes

Hey All,

I have webrtc setup on my supervisor Home assistant setup. And I am using a Cloudflare tunnel (aka Argo tunnel) to remote access the HA instance.

I was wondering if anyone else is having issue on the iOS mobile app this streaming Webrtc when connected to mobile LTE. I have T-Mobile so I know their network is behind a CGNat.
When I connect to my home wifi network I am able to effectively see all of my cameras, through my remote domain.

It is only when I use LTE, do I see these errors in webrtc home assistant logging.

2022-09-22 15:30:17.192 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:17 Stream Exit On Demand No Viewer
2022-09-22 15:30:17.383 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:17 Stream Exit On Demand No Viewer
2022-09-22 15:30:17.384 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:17 Stream Exit On Demand No Viewer
2022-09-22 15:30:23.529 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:23 Set ICEServers [stun:stun.l.google.com:19302]
2022-09-22 15:30:23.544 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:23 Set ICEServers [stun:stun.l.google.com:19302]
2022-09-22 15:30:23.626 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:23 websocket.JSON.Send write tcp 127.0.0.1:8084->127.0.0.1:39144: i/o timeout
2022-09-22 15:30:23.686 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:23 websocket.JSON.Send write tcp 127.0.0.1:8084->127.0.0.1:39142: i/o timeout
2022-09-22 15:30:23.753 DEBUG (webrtc) [custom_components.webrtc.utils] 2022/09/22 15:30:23 Set ICEServers [stun:stun.l.google.com:19302]

Does anyone have any other tips as to troubleshooting this? Wireshark possibly?
I’ve been trying to read up on NAT documentation, but I cant effectively troubleshoot what is going wrong when I try to remotely stream through a LTE connection.

Has anyone had any luck finding a way to get the nest camera RTSP stream in WebRTC?

Thanks for the link - it works!

I installed a docker image of go2rtc, then added RTSPtoWebRTC to Home Assistant.
The nest camera was automatically changed to WebRTC on my RTSPtoWeb card without any further changes.

Hi @AlexxIT thanks for this custom component.

I am getting a handful of dns request (coming from my HA IP) for stun.l.google.com whenever I go to the stream in HA. I can see this url has been mentioned a few times but I didn’t really get what it is for.
This is just on my local network so I don’t understand why it is necessary to connect to the internet for this purpose? : )
I am connecting to a Wyze Cam v3 with rtsp enabled by wz_mini_hacks using a very basic config like this

          - type: custom:webrtc-camera
            url: rtsp://login:password@IP_ADDRESS:8554/unicast

Just google what is STUN for WebRTC connection

1 Like

Yes I have read the guides. I can understand that for streaming from HA to somewhere external the STUN setup or port forwarding is needed. But I am only streaming from HA (or rather the camera) 5 feet away to my laptop and everything is on the same local network. Is it also required in that situation?

The component does not know if you are in your network or not. That is why the STUN server is used. Your video data doesn’t go through Google’s servers. It doesn’t matter if you are on a local network or not. It is only a request for a your public IP address and opening a UDP hole.

You can set your STUN settings (empty I guess) for custom card.

1 Like

Hello! I facing the constantly restarting connection it’s normal?

Sometimes it stabilizes but if you refresh the page the problem comes back…

I’m using 2 cameras from tapo c210. Any configuration I have to do on the cameras or in this integration?

No, not normal.
Maybe camera sending unstable video feed.

This is “normal” for MSE technology. The icon at the top right tells you what technology you have now.

Sorry i don’t understand where put “go2rtc.yaml” configuration file,… in hass.io

your config directory. Same directory as your configuration.yaml

After weeks of frustration because of very unstable connections of my Tapo cams, with ‘no connection/no video’ messages which occurred very randomly but often,; I finally seem to have found a solution for this!

There is an option called ‘rtsp passthrough’ which you can find at WAN > nat passthrough. (Asus router) Since I Disabled (!) this option, all connection seems to wake up and stream seamlessly.

Maybe this is common knowledge, (because tbh I don’t know what it in fact should be doing) but I always thought it sounds like it should be enabled because you want your rtsp streams to pass through right?? :sweat_smile:

Anyway Hopefully this will help some of you guys - with an Asus router (?)