Go2rtc project - help thread

You probably already have go2rtc on your server. It could be:

  • WebRTC Camera integration
  • go2rtc addon
  • Frigate 12 addon

In last few days telegram notification that get pushed from go2rtc are not working anymore.
Don’t know if due to latest version of go2rtc or latest supervisor or Hass update…

Anyone else?

Thanks

Bye
Marco

Hello,

What if I only want certain cameras to use webrtc and not all of them? How can I achieve this? If I have undestood correctly RTSPtoWebrtc changes every camera stream to webrtc.

Thanks.

Then you should use the WebRTC Camera integration, which you can get through HACS. It uses go2rtc now.

1 Like

Thank you for the info. Although I am trying to wrap my head around this. Isn’t this very insecure, since it requires exposing the go2rtc http port to the internet (1984)? Am I missing something? Any help would be appreciated so I can get this implemented in a secure manner.

Side question/comment, I wish there was a way to use HA tokens, similar to how addons work in the sidebar, to access go2rtc by using HA auth tokens.

I’m running into some issues and hopefully someone is able to help.

I’m running version 1.1.1 of Go2RTC in a docker container. I’m running HA 2023.2.2, have RTSPtoWebRTC installed and connected to the docker instance. Got my Ring camera’s and Imou camera working just fine.

I now have bought a Reolink 811a to replace one of my Ring cameras, but for some reason I can’t get the main stream to work inside of HA.

I have tried a bunch of scenario’s and hopefully you guys can help figuring out what’s wrong.

I added the RTSP stream to the config file of Go2RTC:

  fietsen_reolink264: rtsp://user:[email protected]:554/h264Preview_01_main
  fietsen_reolink265: rtsp://user:[email protected]:554/h265Preview_01_main

Both run fine through the web gui of Go2RTC. I can start both and have both image and sound.

I added both to HA. But can’t start the streams. Both have different errors:

H264:

11:17:52.132 DBG [rtsp] disconnect stream=fietsen_reolink264
11:17:52.188 DBG [rtsp] new consumer stream=fietsen_reolink264
11:17:52.188 DBG [streams] probe producer url=rtsp://user:[email protected]:554/h264Preview_01_main
11:17:52.244 DBG [streams] start producer url=rtsp://user:[email protected]:554/h264Preview_01_main
11:18:13.981 DBG [rtsp] new consumer stream=fietsen_reolink264
11:18:14.158 WRN github.com/AlexxIT/go2rtc/cmd/webrtc/webrtc.go:198 > stream.AddConsumer error="codecs not match: H265,AAC"
11:18:14.159 ERR [api.hass] exchange SDP error="codecs not match: H265,AAC"

H265:

11:13:45.130 DBG [rtsp] new consumer stream=fietsen_reolink265
11:13:47.259 DBG [rtsp] handle=read tcp 192.168.20.79:8554->192.168.21.92:42484: read: connection reset by peer
11:13:47.260 DBG [rtsp] disconnect stream=fietsen_reolink265
11:13:47.315 DBG [rtsp] new consumer stream=fietsen_reolink265
11:14:00.808 DBG [rtsp] new consumer stream=fietsen_reolink265
11:14:00.972 DBG [streams] probe producer url=rtsp://user:[email protected]:554/h264Preview_01_main
11:14:01.014 DBG [streams] stop producer url=rtsp://user:[email protected]:554/h264Preview_01_main
11:14:01.015 WRN github.com/AlexxIT/go2rtc/cmd/webrtc/webrtc.go:198 > stream.AddConsumer error="codecs not match: H265,AAC"
11:14:01.015 ERR [api.hass] exchange SDP error="codecs not match: H265,AAC"

Another approach is through the official Reolink addin. Which is configured to use the RTSP stream within the configuration of the integration. I can start the sub stream without issues, the main stream results in a error message:

Failed to start WebRTC stream: Timeout handling WebRTC offer

No errros in the Go2RTC logs neither in the HA logs apart from:

Error from stream worker: Stream has no video

Which doesn’t say much.

Now my best bet would be it has something to do with the audio codecs since in most cases it references to AAC.

I can’t find any method to change the source audio protocol. But I don’t even know if this is the right path.

When removing the RTSPtothewebRTC component and only run plain HA and thus won’t use WebRTC, the main stream results in an error too as can be seen on Reolink RLC-811a video feed timeout - thumbnail works?, there have been a number of reports like this, but none are conclusive.

edit:

The sub stream works, it’s just the main stream which doesn’t. I’m wondering what this can be.

Guys i need some help…

I have Sricam PTZ cameras and i had setup go2rtc to connect with ONVIF correctly with them and i have Image and Audio.

I dont know how to implement the PTZ control. I added the Picture Elements card that some people suggest here and i see the arrows but most of them call a service like foscam that my cameras dont support.
Are there any other PTZ services that i can try or anyone knows a way to do it?
thx
chris

Hi,
I have a Galayou Y4 camera with onvif. Got it working with go2rtc - almost no lag, perfect. This camera offers two streams, one SD and one HD (2K). SD works fine (see above), but when I try to view the HD stream in the web api, I get from debug this message:

DBG [webrtc] add consumer error=“codecs not match: H265,AAC”

With VLC I can view both streams without problems.
I have already added #backchannel=0 to both streams. The camera offers two way audio, but I am not interested in audio and have disabled it in the app of the camera (WansviewCloud).

Any idea how to get the HD stream rolling ?
Thanks a lot in advance

Check codecs section in go2rtc docs. H265 and AAC both not supported by WebRTC. Only MSE

Thank you for the quick reply, but when I open the HD stream with MSE I only get a still picture.
Is it possible to force the use of a codec ?

I’m trying to get my Lorex cameras to work with this and having no luck getting 2 way audio working. My cameras are E892AB connected to the NVR which is a N842A8. I’ve been able to access them in the browser and on my iPhone with full quality and can receive audio, but am unable to send audio to the cameras. Anyone had any luck with these cameras?

{
  "producers": [
    {
      "type": "RTSP source",
      "url": "rtsp://192.168.10.15:554/cam/realmonitor?channel=2\u0026subtype=0\u0026unicast=true\u0026proto=Onvif/",
      "remote_addr": "192.168.10.15:554",
      "user_agent": "go2rtc/1.1.2",
      "medias": [
        "video, sendonly, 96 H264/90000",
        "audio, sendonly, 97 MPEG4-GENERIC/16000",
        "application, sendonly, 107 VND.ONVIF.METADATA/90000",
        "audio, recvonly, 97 L16/8000"
      ],
      "tracks": [
        "96 H264/90000, sinks=1"
      ],
      "recv": 2889058
    },
    {
      "type": "RTSP source",
      "url": "rtsp://localhost:8554/05dee3d3c1d3d63f8da7fe854a463820",
      "remote_addr": "[::1]:35674",
      "user_agent": "ffmpeg/go2rtc",
      "medias": [
        "audio, sendonly, 96 OPUS/48000/2"
      ],
      "tracks": [
        "96 OPUS/48000/2, sinks=1"
      ],
      "recv": 60795
    }
  ],
  "consumers": [
    {
      "type": "WebRTC client",
      "remote_addr": "udp4 prflx 192.168.21.97:63106 related :0",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
      "send": 2942638
    }
  ]
}

I also have one of their doorbell cameras, model B451AJ that I’ve been messing around with as well with limited success. FYI for anyone else looking at the Lorex doorbell, the standard web UI is unavailable, but the TCP version of the API is available and you can actually mess with otherwise hidden settings using it.

I can stream WebRTC perfectly using the WebRTC Camera card on Android or Windows (with port 8555 forwarded). On iOS, WebRTC also works great, but only to a local HASS.

If I try to stream via WebRTC Camera card on iOS, it will only show 1 frame, stuck on MSE. It will not use RTC unless I modify the card to use Mode: webrtc and then it will only display a blank page with an error “3”.

I just don’t understand why WebRTC fails over a properly forwarded remote connection to iOS (Chrome or Safari) that otherwise works just fine on a local connection.

Is the only way (currently) that iPhone/iPad can stream WebRTC remotely in HASS is via an iFrame card using go2rtc web UI?

Are you sure you have public IP? As I can understand, WebRTC works remotely for your Android and doesn’t works for your iOS.

Hi Alexey, thanks for taking the time to assist. Yes, both remote and local sites have a dynamic public IP (with DuckDNS domain for HASS). TCP/UDP 8555 forwarded to HASS.

Android/Windows(Chrome/Firefox) - WebRTC works perfectly via local HASS or remote HASS.

iOS(Chrome/Safari) - WebRTC only works with local HASS. On a remote connection, WebRTC card is stuck with a static image (MSE). Same problem duplicated on different remote ISP connections. iOS (iPhone and iPad) and browsers are fully up to date.

If I force WebRTC mode, Error 3 and a blank screen results. I have full debugging enabled and am not seeing any clarification of what this error means.

HLS-LL streaming does work for iOS remotely but in a mixed Android/iOS family like mine, it really complicates things to manage separate views (WebRTC vs HLS) for each camera. So I’m really hoping there is a solution to standardize on WebRTC for both.

Maybe you have some errors in the Hass logs? I think there should be some Safari browser errors.

I have set all 7 components in the go2rtc config to debug, as well as HASS logger custom_components.webrtc: debug.

homeassistant.log

2023-02-13 12:49:24.243 DEBUG (webrtc) [custom_components.webrtc.utils]  go2rtc version 1.1.1 linux/arm
2023-02-13 12:49:24.243 DEBUG (webrtc) [custom_components.webrtc.utils] [api] listen :1984
...  <results from access remotely via iPad Chrome browser - no errors>. ..
2023-02-13 13:08:25.571 DEBUG (MainThread) [custom_components.webrtc] New client: {'authSig': 'xxx', 'entity': 'camera.frontdrive'}
2023-02-13 13:08:25.661 DEBUG (webrtc) [custom_components.webrtc.utils]
 [streams] probe producer url=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
 [webrtc]  new consumer camera.frontdrive
 [streams] start producer url=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
 [streams] stop producer url=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0

 ...  <access remotely from iOS iPad Safari browser - an error noted:>
[streams] probe producer url=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
[webrtc]  new consumer camera.frontdrive
[streams] start producer url=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
[streams] can't get track url=rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0

I’m not sure if I need this in the go2rtc config:

candidates:
  - stun:8555

But I’ve tried with and without it, and it makes no difference.

The webrtc card is very simply this:

type: custom:webrtc-camera
entity: camera.frontdrive
ui: true

EDIT: As to browser errors, I started logging on chrome with chrome://inspect and it showed no errors. On Safari, I’m not sure I can. The Web Inspector apparently requires a Mac which I don’t own.

“can’t get track” error not related to WebRTC connection and sometimes happens. It because multiple simultaneous queries to stream (from webrtc/mse) with different capabilities.

I figured out how to get the Lorex doorbell working. I paired it to the NVR, port 35000 then was able to use the NVR to configure it for H.264 so it’s compatible with my devices without transcoding and that got it going. It’s pretty similar to the Amcrest that a lot of people have, but Lorex doesn’t provide the web UI hence pairing to configure it that way.

I am trying to get my Lorex cameras going with it next, but ran into an interesting issue that I’m hoping someone here has the answer to. If I connect the camera to my switch everything works with two way audio, recvaudio is RTP payload type 8. Interestingly, when I connect it to my NVR and try to access it through the NVRs channel for it, it obeys my video settings and sends audio in the correct RTP type 8, but recvaudio is type 97 which doesn’t work with WebRTC. I cannot seem to figure out where in the Dahua API to get the NVR to change that.

go2rtc will not start
was working, had to restore from BU for unrelated reason, now go2rtc will not start. tried removing and reinstall, same. has anyone experienced this please and if so any luck resolving? thank you for any input
ha core 2022.12.5
dell 7040

Hi all. In one of the latest go2rtc updates, the USB camera stopped working. When you roll back to version 0.1-beta.9, it works again. Sony playstation camera. The file contains ffmpeg:device?video=0&resolution=640x480#video=h264. Does anyone have a USB camera?