Go2rtc project - help thread

I sometimes have issues. I thought it was the loveance card, but even with an Iframe it sometimes stops and won’t restart until I restart the container.

When it works I get the following in the logs:

13:10:01.200 DBG [webrtc] new consumer url=fynn_camera
13:10:01.257 DBG [streams] probe producer url=rtsp://admin:[email protected]:88/videoMain
13:10:01.937 DBG [streams] start producer url=rtsp://admin:[email protected]:88/videoMain
TODO: webrtc ontrack &{mu:{w:{state:0 sema:0} writerSem:0 readerSem:0 readerCount:0 readerWait:0} id:2e1d963c-203a-4cf7-994f-799efdb66eb5 streamID:6Yk3m4hN69YNNYnrs2TMQucn00RLbshXrxgq payloadType:111 kind:1 ssrc:718835236 codec:{RTPCodecCapability:{MimeType:audio/opus ClockRate:48000 Channels:2 SDPFmtpLine:minptime=10;useinbandfec=1 RTCPFeedback:[{Type:transport-cc Parameter:}]} PayloadType:111 statsID:} params:{HeaderExtensions:[{URI:http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 ID:4}] Codecs:[{RTPCodecCapability:{MimeType:audio/opus ClockRate:48000 Channels:2 SDPFmtpLine:minptime=10;useinbandfec=1 RTCPFeedback:[{Type:transport-cc Parameter:}]} PayloadType:111 statsID:}]} rid: receiver:0x400009a2a0 peeked:[144 239 1 224 250 229 74 247 42 216 142 36 190 222 0 1 65 0 1 0 120 11 228 193 54 236 197 141 140 73 70 153 4 197 170 237 146 231 99 74 58 24 152 238 98 203 96 255 108 27 41 0] peekedAttributes:map[0:0x400022ca00]}

So, instantly after the ‘new consumer’ entry it starts the stream. When it doesn’t work I get the following:

13:08:05.835 DBG [webrtc] new consumer url=fynn_camera
TODO: webrtc ontrack &{mu:{w:{state:0 sema:0} writerSem:0 readerSem:0 readerCount:0 readerWait:0} id:68bce349-6d72-4145-9b25-80013bb05a11 streamID:xL3JRwRR1X7GDJSuY49cDhli94jKg2jUOFvC payloadType:111 kind:1 ssrc:1048239277 codec:{RTPCodecCapability:{MimeType:audio/opus ClockRate:48000 Channels:2 SDPFmtpLine:minptime=10;useinbandfec=1 RTCPFeedback:[{Type:transport-cc Parameter:}]} PayloadType:111 statsID:} params:{HeaderExtensions:[{URI:http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 ID:4}] Codecs:[{RTPCodecCapability:{MimeType:audio/opus ClockRate:48000 Channels:2 SDPFmtpLine:minptime=10;useinbandfec=1 RTCPFeedback:[{Type:transport-cc Parameter:}]} PayloadType:111 statsID:}]} rid: receiver:0x400007a960 peeked:[144 239 20 14 109 141 80 4 62 122 220 173 190 222 0 1 65 0 1 0 120 11 228 193 54 236 197 141 140 73 70 153 4 197 170 237 146 231 99 74 58 24 152 238 98 203 96 255 108 27 41 0] peekedAttributes:map[0:0x4000643b80]}

So the stream never starts.

I also got another error:

12:30:54.482 WRN [streams] start error=“parse "\xcb\x00\rK": net/url: invalid control character in URL” url=rtsp://admin:[email protected]:88/videoMain

The reason this is weird, is because it has never changed. I don’t understand why it does this.

Hi guys, I’ve been quite lost with this topic up until now.
And let me tell you, did it help to write this down!
Bear with me as I describe how painful this has been for me :slight_smile:

1. First I started experimenting with this add-on: “RTSPtoWeb - WebRTC”.
And it worked great, I got low-latency streaming, except I didn’t realize at first that this wasn’t going to work outside of my LAN.
So I disabled “RTSPtoWeb - WebRTC” in the integrations page.
Note: I didn’t remove the integration. This will be important later on.

2. Then I installed the add-on “RTSPtoWebRTC” - visiting http://[my HA ip]:8083 returns “No Stream Found (add stream and reload page)” - add stream where exactly?
I’m confused with the tutorial… There seems to be some mix-up between these two add-ons.
The page about this one, shows a video about the first one: RTSPtoWebRTC - Home Assistant

Well, I added the integration “WebRTC Camera”, configured the UDP port range, and added the UDP port forwarding in my router.
Using the ‘custom:webrtc-camera’ does work outside of my LAN, however it’s very unstable. Stream isn’t fluid nor low-latency.

After all this, still no cameras listed here: http://[my HA ip]:8083

I didn’t know where to go from here.

3. Now I’m trying to work with the add-on “go2rtc”.
Visiting http://[my HA ip]:1984, no cameras show up so I really must be missing something, since go2rtc was supposed to “grab” any existing streams.
So I added the streams to the config/go2rtc.yaml file and now they show up under http://[my HA ip]:1984
And I added these streams as “Generic Camera” integrations, the source being something like rtsp://[my HA ip]:8554/[some_camera]
Adding them as picture cards, it all works, but once again this isn’t low-latency.

And then I realize, maybe I had previous configurations messing with my current setup.
So I removed all the “RTSPtoWeb/WebRTC”-related integrations, and re-added the “RTSPtoWebRTC” integration.
This time using the server address http://[my HA ip]:1984
I removed the streams from the config file go2rtc.yaml
Then I re-added the lovelace cards as regular picture cards with “live view”.
And now I do get a dynamic list under http://[my HA ip]:1984; this list changes when I watch the streams in my Dashboard.
However, they take a long time to show up at first. (several seconds; sometimes returning an error and not showing up, and I need to refresh)
And again I lost remote access to the streams.

Now, how do I enable remote access?

#go2rtc.yaml
api:
  listen: "127.0.0.1:1984" # localhost
  listen: "xxx.xxx.xxx.xxx:1984" # vm host

rtsp:
  listen: "127.0.0.1:8554" # localhost

webrtc:
  listen: ":8555" # external TCP port - forward this in your router
  candidates:
    - stun:8555  # if you have dynamic public IP-address

And still not working remotely, I mean, rarely one stream passes through.
So what’s happening?
This pops up a lot in the go2rtc Log:

WRN [webrtc] candidate error="address xxxx:xxx:xxxx:xxxx:xxx:xxxx:xxxx:xxxx:xxxx: too many colons in address"

So I disabled IPv6 under Settings → System → Network
And finally I have remote streaming. :smiley:
But with remote access it’s choppy again. Just 1-2 frames per second.
Do you know how to improve this, or what’s wrong with the way I configured it?

This may be an obvious suggestion, but make sure you’ve forwarded port 8555 in you router to the IP address of your home assistant instance (an RPi 4 in my case).

WebRTC Camera integration has fallback to MSE technology in case when WebRTC couldn’t connect remotely. You can check it by icon on top right corner of lovelace card.

WebRTC Camera custom card incompatible with go2rtc add-on.

1 Like

Well I guess this was indeed my router’s fault.
I restarted everything, including the router, and now the streaming is fluid :slight_smile:
However, I often get errors when trying to opening up the streams in Lovelace:
Failed to start WebRTC stream: Timeout handling WebRTC offer
and something else in the lines of
WebRTC streaming error: undefined
Upon restarting the add-on, it works again, so for now I made a button to quickly restart the add-on when needed:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: hassio.addon_restart
  data:
    addon: a889bffc_go2rtc
  target: {}
entity: ''
name: Restart go2rtc
show_state: false
icon: mdi:restart
icon_height: 50px

I thought others might want to be aware of something I discovered today.

I thought my Amcrest AD410 button ring wasn’t working for hte past week and was about the warranty a claim. But I just figured out that I was sending video to my tv/nest hub devices when a ‘human’ was triggered from the cameras like I have always done. However, now that trigger opens up a ‘call’ to the doorbell every time and while there is a ‘call’ going on, the doorbell button itself won’t function.

So lesson here is be careful that with doorbells when sending videos to a display ahead of a doorbell press, it will actually disable the button. :slight_smile:

I really need to figure out how to initiate video from the doorbell through this integration without activating a ‘call’ (stop turning on the microphone maybe?)

From the Amcrest app, I can view the live feed while not in a ‘call’ letting the doorbell still ring properly.

What’s worse too is pipup doesn’t seem to close the connection resulting in the go2rtc connection remaining open with the camera and afte the first button press, the doorbell never works again until I restart go2rtc. :frowning:

Would a coral TPU help to resolve the transcoding issue?

As far as I know, Coral TPU is not involved in transcoding at all. Even when you using Frigate.

Could you explain your setup a bit more? I’m trying to set this up with my unifi protect integration and Nothing loads.

Good afternoon,
Installation of go2rtc: Home Assistant Add-on failed, error
‘AddonManager.install’ blocked from execution, system is not healthy
Installation of go2rtc: Docker, successful
Question 1: where was it necessary to register the data from the instructions?
'services:
go2rtc:
image: alexit/go2rtc
network_mode: host
restart: always
volumes:

“~/go2rtc.yaml:/config/go2rtc.yaml”’
In portainer alex it/go2rtc:latest there is , status Unused
Reboot…
In config/go2rtc.yaml
, I wrote
''api:
listen: “127.0.0.1:1984”

rtsp:
listen: “127.0.0.1:8554”

webrtc:
listen: “:8555” # external TCP port - forward this in your router
candidates:

stun:8555 # if you have dynamic public IP-address
streams:
1_camera: rtsp://admin:ХХХХ@192.168.0.8/Streaming/Channels/102 /’
Reboot…
It is not possible to reach the addresses 127.0.0.1:1984, 192.168.0.108:1984 (server address).
Question 2: How to reach the go2rtc web page, which I’m not doing right.
So far at this stage …

If you setup go2rtc on localhost on remote server, you can’t reach its web UI via browser.

1 Like

Good afternoon, I have access to RP3 via Vnc server remotely, but I still can’t log into the go2rtc web. even when I enter the address 127.0.0.1:1984 or 129.168.0.108:1984

@nprez83 Is this still working for you in the current beta 8? It seems to have stopped working for me somewhere along the line…

14:28:28.838 DBG [webrtc] new consumer url=camera.kitchen_display
14:28:28.861 DBG [streams] probe producer url={input}
2022/10/06 10:28:28 http: panic serving 172.30.33.9:36814: runtime error: slice bounds out of range [:-1]
goroutine 70 [running]:
net/http.(*conn).serve.func1()
	net/http/server.go:1825 +0xb8
panic({0x6ab5a0, 0x40004ba7c8})
	runtime/panic.go:844 +0x260
github.com/AlexxIT/go2rtc/cmd/streams.GetProducer({0x4000137c78, 0x7})
	github.com/AlexxIT/go2rtc/cmd/streams/handlers.go:30 +0xec
github.com/AlexxIT/go2rtc/cmd/streams.(*Producer).GetMedias(0x40001d76c0)
	github.com/AlexxIT/go2rtc/cmd/streams/producer.go:46 +0x12c
github.com/AlexxIT/go2rtc/cmd/streams.(*Stream).AddConsumer(0x40001aeff0, {0x7edb10?, 0x400020c1c0})
	github.com/AlexxIT/go2rtc/cmd/streams/stream.go:63 +0x2c8
github.com/AlexxIT/go2rtc/cmd/webrtc.offerHandler(0x40000e6380, 0x40003480c0)
	github.com/AlexxIT/go2rtc/cmd/webrtc/webrtc.go:109 +0x408
github.com/AlexxIT/go2rtc/cmd/api.apiWS({0x7ee890, 0x400008c460}, 0x40002c0800)
	github.com/AlexxIT/go2rtc/cmd/api/api.go:131 +0x198
net/http.HandlerFunc.ServeHTTP(0x72?, {0x7ee890?, 0x400008c460?}, 0x1cd20?)
	net/http/server.go:2084 +0x3c
net/http.(*ServeMux).ServeHTTP(0x40002d40fc?, {0x7ee890, 0x400008c460}, 0x40002c0800)
	net/http/server.go:2462 +0x144
net/http.serverHandler.ServeHTTP({0x400034c720?}, {0x7ee890, 0x400008c460}, 0x40002c0800)
	net/http/server.go:2916 +0x408
net/http.(*conn).serve(0x400030a280, {0x7eef20, 0x40000900c0})
	net/http/server.go:1966 +0x550
created by net/http.(*Server).Serve
	net/http/server.go:3071 +0x448

It is, although interestingly when I went to check it right now, it initially wasn’t. I tried restarting the addon first and that did not fix it. I then reloaded the RTSPtoWebRTC integration and that did the trick. I’ve had to reload the integration a few times over the past few days after getting an error related to not being able to access the WebRTC server or something like that. I am on beta 8 btw.

Reloading didn’t help. I get consistent panics where this all used to work flawless.

Hmm, interesting. The only other difference I see is in the way we define our video streams. Here’s how I’m defining them. Try it and see if it helps.

streams:
  "camera.foscam1": ffmpeg:{input}#video=copy#audio=opus
  "camera.foscam2": ffmpeg:{input}#video=copy#audio=opus
  "camera.foscam3": ffmpeg:{input}#video=copy#audio=opus
  "camera.nest_cam": ffmpeg:{input}#video=copy#audio=opus

Yes I tried that as well.

Its something with localhost and docker I think. I am on HAOS and even this doesn’t work anymore which used to:

  testing:
    - ffmpeg:rtsp://127.0.0.1:8554/hass%3Abackyard#audio=opus
1:26:10.215 ERR [streams] probe producer error=timeout url=ffmpeg:rtsp://127.0.0.1:8554/hass%3Abackyard#audio=opus

I see. I run hassos in a RPI4, not sure what else you can try, sorry.

Good Afternoon All!

I’ve been attempting to setup a WebRTC / go2rtc system in hass to help with latency and consistency in a baby monitor I have running through hass. The generic camera integration works as it should, but is slow to load the video / audio and drops out regularly. I have had luck improving both latency and consistency with WebRTC and go2rtc, but am having issues with audio not being passed through.

The WebRTC add-on (RTSPtoWeb - WebRTC) doesn’t support audio at all. The other WebRTC add-on (RTSPtoWebRTC) does support audio but is labeled as not preferred and I have been unable to get any config to work properly.

I just finished getting the go2rtc add-on setup and it is functioning properly, just not as I would like in this situation. I have done:

Camera > RTSP > WebRTC > go2rtc

Go2rtc is set to combine the video from WebRTC and the audio from the RTSP stream and this plays correctly in the webview for the go2rtc add-on when viewed as webrtc. The issue is, if I pass this back into hass via the Generic Camera integration the audio is once again cut off by WebRTC. If I leave it only in go2rtc, then I have no way to view it from a lovelace dashboard, only the webview for go2rtc.

I would like to find a way to get this combined video and audio into hass in a way that it can be viewed from a dashboard. Any suggestions?

1 Like

Hey @WhatTrees
One option is to use an iframe card to display the direct go2rtc webrtc url like this:

type: iframe
url: http://192.168.0.22:1984/webrtc.html?src=frontdoor
aspect_ratio: 76%

Alternatively you can try the WebRTC Card and check the notes on that github page about audio. You’ll need to find out what format your audio is and adjust the WebRTC card settings accordingly.