How to: RTSP to Chromecast

Hello

I am new and I have only one simple flow behind me (receive an http rquest, speak, on a case-by-case basis, some sentences on google home.

In my home I have surveillance cameras.
I can get the video with an rtsp link.
I would like to play this on my google home (with screen), which has a chromecast incorporated.

I wonder if this possible ?

I found this node


but in "stream a URL" it doesn't seem to accept a rtsp link.

Thank you

The stream is send directly to the cast device by using the castv2 protocol. Only these formats are supported; https://developers.google.com/cast/docs/media

Can you give an example ?

This flow doesn't work:

[{"id":"19d4447a.e78fcc","type":"tab","label":"Castv2","disabled":false,"info":""},{"id":"4ea4de1e.f255d","type":"castv2-sender","z":"19d4447a.e78fcc","name":"Smart Display","host":"192.168.1.113","x":540,"y":200,"wires":[["4200efb7.dfd73"]]},{"id":"4200efb7.dfd73","type":"debug","z":"19d4447a.e78fcc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":720,"y":200,"wires":[]},{"id":"bcb22075.677ec","type":"inject","z":"19d4447a.e78fcc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":200,"wires":[["c86dad8.105995"]]},{"id":"c86dad8.105995","type":"change","z":"19d4447a.e78fcc","name":"","rules":[{"t":"set","p":"payload.media.url","pt":"msg","to":"rtsp://admin:1234@192.168.1.103:554/cam/realmonitor?channel=1&subtype=0","tot":"str"},{"t":"set","p":"payload.type","pt":"msg","to":"MEDIA","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":200,"wires":[["4ea4de1e.f255d"]]}]

I believe this is in the "change" I don't give the info it needs.

Thank you

Can someone give an example of a flow using castv2 node, streaming either a rtsp or a m3u8 file ? Documentation doesn't have an example.

Thank you

You have used not the node-red-contrib-cast node. So I can not help you.

In the website node-red-contrib-cast you can find examples for node-red-contrib-cast.

Hey, actually, in your first message I understood (misunderstood) you told me to use castV2 node.
Now I understand you say I need to use CAST node (knowing it uses castV2 protocol).
Is this correct ?

This cast node, I use it daily for TTS notifications (switching lights on/off, etc) !

So I come back to the "cast" node. In "media url" can I put a rtsp link ?

This flow (tried it with a rtsp link) does not work:

[{"id":"a32c41fb.c31c","type":"change","z":"19d4447a.e78fcc","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"192.168.1.113","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"rtsp://admin:1234@192.168.1.102:554/live","tot":"str"},{"t":"set","p":"contentType","pt":"msg","to":"video/mp4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":340,"wires":[["831444e1.916c78"]]}]

Working directly from a rtsp link would be my preferred option.

However an alternative, if this is not possible, is to use ffmpeg on my Pi (same one where I have nodered) to change the rtsp to m3u8 series of files. Then my question is how to read a file from the Pi (it is on the same device)

Thank you

I am the author of node node-red-contrib-cast. The node node node-red-contrib-castv2 is a fork created by anybody other. So I can not give any support for the castv2 node. But as I know both using the same protocoll and to thus both hase the same limitations.

Only media types are supported that Google lists here. There is nothing about rtsp stream. So this seems not be suported.

OK, well... The title of this discussion is "RTSP to chromecast" so well, yes, it is about RTSP actually... :grinning:
OK so you know nothing about that.

But M3U8 series of files do you know how to read it (M3U8 is listed in "CAST" node examples) ? How to read it on the same device (how to enter path) ? Do you know something about that ? (actually did you read the questions - no offense)

I think you'll find he does know something about it... having read the google support page you would find no mention of RTSP or M3U8 - so the answer is that Google don't support RTSP directly. You would need some other code in between to translate. A quick google finds several suggestions including ffmpeg, a pre-build docker container, etc... so there are solutions out there - but they are not built into Node-RED.

1 Like

Thank you. Actually a few messages above I explained, if RTSP is not possible, I already use FFMPEG on the Pi to change the stream to M3U8.
This is why I asked how to read M3U8 series of files with the cast node.
In the cast node page, there is mention of M3U8 in MEDIA types part.
=> I would like an example with this.
Among others I am curious about the file name and the path.

To be 100% complete, even better would be to have FFMPEG stream directly to the Chromecast but thtat I didn't figure out how to do this, and I am not on the right discussion board... But I am not sure this is possible anyway, without going through intermediate files.

Excuse me if my answer is too short.

So I come back to the "cast" node. In "media url" can I put a rtsp link ?

Any link can be entered in the media url field and the node will transmit this given link to the Cast device (e.g. chrome cast, google home, nest home, ...). The Node does only send the url and the additional context information (e.g. content type, etc...) to the cast device without changing them. To show the video/picture or play the sound it is up to the cast device itself.

The cast device is responsible for whether the desired result is achieved with the URL.
To thus as I answered before:

Only media types are supported that Google lists here. There is nothing about RTSP stream. So this seems not be suported.

Since Google unfortunately does not list RTSP as a supported format, I suspect that it will not work, but You can give it a try. (I have currently no possibility to test this.)

The other possibility is to only provide the video stream in a format that is supported by Google.

The documentation of the node is unfortunately not good here. With the formats listed in the documentation of the node, it is not guaranteed that Google also supports them. I will change the documentation in any of the next versions.

I hope that makes this more clear.

@Gleneroo - So... as the chromcast seems to accept HLS - then maybe the answer is to use ffmpeg to convert RTSP to HLS instead of M38U ?
eg - https://github.com/gihad/streamer

Thanks Hypnos for your more complete answer ! I do understand better what the node does and does not, and to refer to google doc and not node doc.

dceejay: Well, my understanding is HLS is M3U8.
I have ffmpeg on the pi taking the RTSP flow, and doing M3U8 files (*.ts files).
Now what I miss is the node to stream it to the chromecast.
Certainly I am not far.

The node-red-contrib-castv2 node is just a rewrite of the cast node that (hopefully) isn't as glitchy.

As others have said, the cast protocol will only use HLS (Yes, this is m3u8) and DASH for video streaming.

If you have an HLS stream URL available already, you just need to pass a message like this into a castv2 node that's configured to point at your target:

{
    "payload": {
        "type": "MEDIA",
        "media": {
            "url": "URL of m3u8"
        }
    }
}

Could it be,,,you should configure ffmpeg to stream to http instead of creating file? Then you add the url in the castv2 node configuration

How does your ffmpeg command line look like?

Thank you i8beef and krambriw

I would like, as you suggest, to use ffmpeg that stream to http instead of creating files. I just don't know how to do that.

I am using something like that : (found on the internet)

ffmpeg -rtsp_transport tcp -i rtsp://admin:123456@192.168.0.218/live/ch1 \
  -acodec copy \
  -vcodec copy \
  -hls_wrap 40 \
  -flags -global_header \
  /var/www/html/cam/cam.m3u8

The link http://[IP raspberry]/cam/cam.m3u8 doesn't read, same with trying other paths. It just creates 40 small .ts files in the cam directory (overwritten in loop).

I have tried to modify the last line as: -f mpegts udp://[IP chromecast]:[port] but of course doesn't stream to chromecast as well.

I would be happy to stream this HLS to a url, I would just like to know how, then use a node for sending it to the chromecast.

Regards

Take a look here for the correct ffmpeg syntax: Zenki

Keep in mind that Chromecast is finicky about the HLS flavor it gets. There is a known bug for instance when an incorrect audio codec is selected. The HLS stream is functional but Chromecast will then refuse to play it. Good luck.

Realjax maybe you had best intentions but this is not the question. I already have this part covered (rtsp to m3u8 file). Now question is to url.

Install a webserver to serve the files. The files ARE your stream. The link I gave is an example of this.

Actually I already have this part.
See above I have my own ffmpeg lines.

It is in the next part I needed support. "install a web server to serve the files" doesn't help.

I don't know why you want to support the part I already managed and not the part where I asked a question.