WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

WebRTC Dashcast Nest Google Hub stops working

Open adoreparler opened this issue 11 months ago • 13 comments

I have a Google Nest Hub and Home Assistant and also WebRTC Installed. My Cameras are Ubiquiti cameras and in the options for the camera I turned on RTSPS Link for High Definition.

I created a script:

alias: Streaming Outside Camera to Kitchen Display
sequence:
  - service: webrtc.dash_cast
    data:
      entity_id: media_player.kitchen_display
      url: rtspx://11.0.0.71:7441/{UniqueIdentifierWasHere}
      force: true
mode: single
icon: mdi:webcam

When I tell the google hub the alias above it starts displaying and I can see the camera feed with about a 2 - 3 second lag. But after about 5 seconds the stream goes black and does not load back up. If I close out and say the alias again it works again for about 5 seconds and the stream goes black.

I turned on Debug logging but I am not sure where to go to see the debug logging. I went to system -> Logs and dont see anything in there around WebRTC.

adoreparler avatar Feb 29 '24 14:02 adoreparler

You can open go2rtc WebUI and check stream info when stream active

AlexxIT avatar Feb 29 '24 17:02 AlexxIT

{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsps://11.0.0.71:7441/{UniqueIdentHidden}/",
      "remote_addr": "11.0.0.71:7441",
      "user_agent": "go2rtc/1.8.5",
      "sdp": "v=0\r\no=- 1476 0 IN IP4 11.0.0.71\r\ns=AC8BA98F79F9_0\r\nu=www.ui.com\r\[email protected]\r\nc=IN IP4 11.0.0.71\r\nt=0 0\r\na=recvonly\r\na=control:*\r\na=range:npt=now-\r\nm=audio 0 RTP/AVP 96\r\na=recvonly\r\na=rtpmap:96 mpeg4-generic/16000/1\r\na=control:trackID=0\r\na=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=1408; SizeLength=13; IndexLength=3; IndexDeltaLength=3;\r\nm=audio 0 RTP/AVP 96\r\na=recvonly\r\na=rtpmap:96 opus/48000/2\r\na=control:trackID=1\r\na=fmtp:96\r\nm=video 0 RTP/AVP 97\r\na=recvonly\r\na=control:trackID=2\r\na=rtpmap:97 H264/90000\r\na=fmtp:97 profile-level-id=4d4032; packetization-mode=1; sprop-parameter-sets=Z01AMqaAKgC/+WbgICAoAAAfSAAHVOTtBEI1,aOqPIA==\r\n",
      "medias": [
        "audio, recvonly, MPEG4-GENERIC/16000",
        "audio, recvonly, OPUS/48000/2",
        "video, recvonly, H.264 Main 5.0"
      ],
      "receivers": [
        "97 H264, bytes=12978016, senders=1",
        "96 MPEG4-GENERIC/16000, bytes=196463, senders=0",
        "96 OPUS/48000/2, bytes=199318, senders=1"
      ],
      "recv": 13402933
    }
  ],
  "consumers": [
    {
      "type": "WebRTC/WebSocket async passive consumer",
      "remote_addr": "udp4 prflx 11.0.0.251:44454 related :0",
      "user_agent": "Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000",
      "medias": [
        "video, sendonly, VP8, RTX, VP9, H264, AV1, RED, ULPFEC, FLEXFEC-03",
        "audio, sendonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000, L16, PCML"
      ],
      "senders": [
        "100 H264, bytes=12978016, receivers=1",
        "111 OPUS/48000/2, bytes=199318, receivers=1"
      ],
      "send": 13349588
    }
  ]
}

adoreparler avatar Feb 29 '24 18:02 adoreparler

11.0.0.251 - is this IP of your Nest? All looks fine in the info

PS. I don't like "Main 5.0". This maybe case of problem. Too high profile for low end devices like Nest Hub: https://developers.google.com/cast/docs/media

AlexxIT avatar Feb 29 '24 18:02 AlexxIT

Yes, that is the IP of the Nest Hub. Most of the time it shows the bar at the bottom counting but just has a black screen. Sometimes it shows the feed for 5 seconds and then goes to the black screen.

adoreparler avatar Feb 29 '24 19:02 adoreparler

I have the option to use medium or low quality RTSP Links from Unifi. I can try that first. If that does not work, does the links in the WebRTC UI for the rtsp stream provide lower quality streaming and does it add lag if it has to convert it to lower quality (if that is what the different links do in the UI?).

From the page you linked: Google Nest Hub

H.264 High Profile up to level 4.1 (720p/60fps)
VP9 up to level 4.0 (720p/60fps)

Nest Hub Max

H.264 High Profile up to level 4.1 (720p/30fps)
VP9 up to level 4.0 (720p/30fps)

adoreparler avatar Feb 29 '24 19:02 adoreparler

Using the Medium Resolution (1280x720) link from Unifi Camera seems to work. I will test it over the next couple of days and then close out this question. Thanks for your help.

adoreparler avatar Feb 29 '24 19:02 adoreparler

Maybe related but may be not.... Home Assistant version 20224.3.0 seems to break WebRTC.dash_cast service (see below). @adoreparler you never mention your version of HASS and what platform its running on I rolled back to HASS 2024.2.5 and DashCast is working again. @AlexxIT, I have included the HASS 2024.3.0 log for your information. Let me know if you need anything else if you look into this break. YAML in HASS

service: webrtc.dash_cast
data:
  entity_id: media_player.apartment_tv
  url: rtsp://192.168.0.5:8554/OfficeEast
  force: true

ERROR IN HASS LOG

This error originated from a custom integration.

Logger: custom_components.webrtc.utils
Source: custom_components/webrtc/utils.py:191
integration: WebRTC Camera (documentation, issues)
First occurred: 3:59:21 PM (2 occurrences)
Last logged: 4:01:54 PM

Can't DashCast to ['media_player.apartment_tv']
Traceback (most recent call last):
  File "/config/custom_components/webrtc/utils.py", line 191, in dash_cast
    entity.dashcast.load_url(url, force)
TypeError: DashCastController.load_url() takes 2 positional arguments but 3 were given

ddean6232 avatar Mar 07 '24 23:03 ddean6232

@ddean6232 fixed in latest master version

AlexxIT avatar Mar 08 '24 09:03 AlexxIT

@ddean6232 fixed in latest master version

Confirming the fix works here, had the same issue as @ddean6232

Even when working though, I struggle with a similar issue that @adoreparler reports with Google Nest Hub but not sure it's WebRTC since I get the same results with generic camera stream. I'm using an Amcrest camera, and even at the lowest resolution, bitrate, and quality settings, the stream works great for about 5 minutes until loading wheel of death and then it needs to be restarted only to happen again.

hankfic avatar Mar 08 '24 12:03 hankfic

Having the same issue, I am not able to stream using dash cast, it was working normal, streaming my reolink cameras with automation.

damianrovira avatar Mar 08 '24 19:03 damianrovira

@hankfic @AlexxIT Havent got the fix to work.... HASS still reporting error as:

This error originated from a custom integration.

Logger: custom_components.webrtc.utils
Source: custom_components/webrtc/utils.py:191
integration: WebRTC Camera (documentation, issues)
First occurred: 2:15:27 PM (2 occurrences)
Last logged: 2:18:59 PM

Can't DashCast to ['media_player.apartment_tv']
Traceback (most recent call last):
  File "/config/custom_components/webrtc/utils.py", line 191, in dash_cast
    entity.dashcast.load_url(url, force = force)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: DashCastController.load_url() takes 2 positional arguments but 3 were given

I even went directly into the custom_components/webrtc folder and checked that the fix was applied... it was

@hankfic How did you apply the fix? redownload through HACS and restart HASS? I rolled back to HASS v2024.2.5 and everything (webrtc cards and dashcast) is working again

ddean6232 avatar Mar 08 '24 21:03 ddean6232

@ddean6232 are you running off master? delete webrtc integration and then add it back again selecting master branch instead of latest version (default).

hankfic avatar Mar 09 '24 00:03 hankfic

I think I got it now.... not sure why it didnt take the first time.... The steps this time were:

  1. get the repo direct from master branch
  2. delete the WebRTC integration in HASS
  3. copy the custom_components/webrtc repo structure over the HASS custom_components\webrtc structure
  4. add back the WebRTC integration
  5. upgrade HASS from 2024.2.5 to 2024.3
  6. test dash_cast service --> success

Thanks @hankfic @AlexxIT

ddean6232 avatar Mar 09 '24 01:03 ddean6232

Small question, will this be fixed in a later update ?

cgilis avatar Mar 15 '24 14:03 cgilis

Original problem was with very hi video profile for chromecast device "Main 5.0"

AlexxIT avatar Apr 07 '24 08:04 AlexxIT