i8beef / node-red-contrib-castv2

MIT License
22 stars 14 forks source link

Trying to load a Ring Door bell stream - rtsp #103

Closed matheuscanela closed 1 month ago

matheuscanela commented 2 months ago

Hey folks! I'm trying to automate using the CAST from node-red; however, when I attempt to add the cast, it doesn't work.

The stream works fine using the following formats:

  1. Through the VLC app
  2. If I go to the Google Cast plugin in the Home Assistant dashboard and ask it to play from the cameras - which I added as per the manual
  3. Using the Home Assistant "call service" to play the camera via stream

I tried the cast and castv2 nodes from the palette, but I'm still getting the errors below:

From Cast: The device tries to open the video, but nothing happens, and node-red returns "Not able to load media:Load failed Not able to load the media."

From Cast v2: Similar to the above, but it returns the error "Error: Unknown command."

Also, the HA logs shows the errors below

If I open the IP in VLC, it works normally. Also, all the devices are on the same network without any segregation. I have also tried using it without a password and with the hostname instead of the IP, but the issue persists.

The reason why I want to use the cast is that I want to set the live option and avoid the buffer settings.

Configuration

cast Screenshot 2024-05-05 015446

castv2 castv2 ^^ the above image shows @192... but I removed the @ and it didn't work too.

rtsp is coming from this addon https://github.com/tsightler/ring-mqtt

i8beef commented 2 months ago

In your image you are attempting to cast an RTSP stream. You can't do that. The Cast protocol only supports HLS, DASH, and WebRTC for streaming.

I am not sure what your other logs are telling you, but you can see it attempting to convert the RTSP stream to HLS in there. I use Frigate to convert my camera RTSP streams to HLS for streaming to cast targets when I want to. It reads the RTSP stream and provides and HLS stream URL (m3u8) which is the URL I send to my Cast targets.

This node does not do any sort of RTSP conversion for you.

matheuscanela commented 2 months ago

Thanks @i8beef for replying back to me, you actually helped me to find the issue.

I solved the problem by adding the go2rtc add-on and streaming it using DashCast, which is quite quick. Not sure if it is the best solution, but works as expected! Also, while researching, I found a ticket on the internet complaining that the Ring doorbeels (which is my case) was starting every 10 minutes without stopping. I noticed the same issue, but I fixed it by asking the CASTv2 to stop casting before reaching 10 minutes - as the camera closes the stream after 10 min. Otherwise, I think the Google Nest continues to open the stream, even if it times out.

However, I still don't understand how the native Google Cast integration works just by clicking in the camera integration.

If any other suggestion, please let me know.

i8beef commented 2 months ago

go2rtc is actually what Frigate uses for restreaming WebRTC under the hood. That page you are DashCasting has a JS based player on it that just plays the WebRTC stream full screen, and then casting it directly like that is essentially a "poor man's custom cast receiver". Im sure it has caveats, but honestly that's a fairly clever way to do it. I scrape that go2rtc JS out and use it to embed WebRTC camera streams on my node-red dashboards because they have a lower latency than HLS.

I was actually wrong, the cast protocol does NOT seem to support WebRTC natively: the Google Home camera intents do, which is what I was trying to work with before on another project, and its a pain in the butt.

The CAST protocol supports HLS (and DASH, but thats just Google branded HLS), and it doesn't even support LL-HLS (low latency) if I remember right. https://developers.google.com/cast/docs/media

I restream RTSP to HLS via a docker image called rtsp-simple-server, and then just do a simple media cast of that m3u8 URL to the cast devices. HLS by definition is several seconds behind, though, which is why WebRTC is better if you can figure out a way to do it. (LL-HLS is actually pretty close, but as I said I don't think that's supported by Google Cast).

i8beef commented 1 month ago

Closing as you have a work around, which seems as close as you'll get with the native cast protocol.