Anyone experienced with chromecast?

Hi,

I’d like to use a chromecast device (smart TV with Android).
Casting my desktop from Chromium works, but this is not what I really want.
But I want to cast a virtual monitors content without a browser involved.

Ideally an ffmpeg solution would be my dream…

Currently I have a script, that starts to use the virtual monitor, set it to fullHD, places to the right of the builtin display, and starts streaming it to a Raspberry with an fps of 10, where the listening to it was started previously.

This low fps is quite good for displaying photos for example, or browing the web there, while the system load it causes is negligible. Of course this is not for a movie playback nor gaming :smiley:

#!/bin/sh

xrandr --setmonitor VIRTUAL1 1920/508x1080/286+1920+0 VIRTUAL1;
xrandr --addmode VIRTUAL1 1920x1080; xrandr --output VIRTUAL1 --mode 1920x1080 --right-of eDP1

ffmpeg -f x11grab -s 1920x1080 -r 10 -i :0.0+1920,0 -vcodec libx264 -b:v 5600K -pix_fmt yuv420p  -preset ultrafast -tune zerolatency -g 2 -fflags flush_packets -f h264  tcp://192.168.1.8:5004?tcp_nodelay=1\&timeout=5000000
ret=$?
if [ $ret -gt 0 ]; 
then
  notify-send "Nem sikerült a képernyőt elérni"
  xrandr --output VIRTUAL1 --off
fi

On the Raspberry side an ffplay does shows the stream:

ffplay -fflags nobuffer -flags low_delay tcp://192.168.1.8:5004?listen=1

(With these parameters I get less than 0.5sec latency)

Now I would like to use the chromecast device a similar way:
-start my secondary virtual monitor
-start streaming of it

Any hint on this?

(Gnome shell extension doesn’t work for me, and the “casting” solutions I found on github all just stream some media files, no live input, and I want this to be browser-independent.

Thanks in advance!

I first tried one around 2015 / 16… Seemed pretty straightforward to me - I wasn’t using Windows even back then - worked flawlessly from Google Chrome on Ubuntu 15 / 16…

Used it at parties to play playlists of stuff I downloaded from youtube (using youtube-dl) on a big TV screen… (and bluetoothed the audio to a jukebox on the other side of the room [it was a big room]).

Never even had to break out any CLI-fu (apart from using youtube-dl) - mainly 'cause there was no “internet” and I was tethering to my mobile phone…

Around 2017 when I no longer had a use for it - gave it to the missus, and she used it from her iPad to the TV in our bedroom… Don’t think she uses it anymore…

I believe, even “today”, they still limited to 720p which seems a bit naff to me… Sorry - can’t really help - just my casual observations from a few years ago - but I was surprised how easy it was the make work in Linux (or Android, or iOS)…

1 Like

I don’t have experience with streaming, but I believe VLC can do exactly what you want.

Thanks Dan!

From Chromium’s “cast” I can send the real desktop, but that in fullHD, so the resolution would be OK.
Framerate is seemingly high above my 10fps, movements are smooth… However latency is about 1 second or so, which is a bit high.

Thanks Mina!

I’ll check wether I can use VLC…

If I just want to open (play) the desktop in VLC, that works. If I select to cast it to a “renderer” (chromecast device), then it says, the vide has to be converted, which is never done if I press OK. However, using cvlc I can cast something to the renderer, which is a good start…

Now I’m stuck here:
ffmpeg -f pulse -ac 2 -i default -f x11grab -s 1920x1080 -r 10 -i :0.0+0,0 -vcodec libx264 -b:v 5600K -pix_fmt yuv420p -preset ultrafast -tune zerolatency -g 1 -f mpegts - | cvlc - --sout="#chromecast{ip=192.168.1.243}"

That actually mirrors my whole desktop -and the default audio output :slight_smile: - (still not the virtual monitor, just the main display, but that’s just matter of coordinates) to the smartTV Almost great…
…but the latency is horrible. :cold_face:
About 18 seconds, and that’s unacceptable.

I have to look around more…

3 Likes

That’s indeed beyond ridiculous.

1 Like

That’s how MaruOS works with showing a desktop on a chromecast (the only way MaruOS can work with non-HDMI enabled phones like the Google Pixel series).
Note : MaruOS is a full linux desktop DE running via chroot on Android…

1 Like

Now after some fiddling with parameters I found mentioned here-and-there:

ffmpeg -f pulse -ac 2 -i default -f x11grab -s 1920x1080 -r 15 -thread_queue_size 65535 -i :0.0+0,0 -vcodec libx264 -b:v 8600K -pix_fmt yuv420p -preset ultrafast -tune zerolatency -g 2 -fflags flush_packets -f mpegts - | cvlc - --network-caching=0 --live-caching=0 --file-caching=0 --sout="#chromecast{ip=192.168.1.243}"

The lag is approximately 6 seconds.
I tend to blame (c)vlc…
Casting the desktop from Chromium has approx. 1 second lag…