
Use Unix Pipes to Improve Chromecast Playback - lowmemcpu
https://alexdelorenzo.dev/linux/2020/03/14/pipes
======
fooblat
My friends often tease me because I read the manual from everything I buy.
Even if it is a tiny pamphlet.

I really like this informative blog post on unix pipes, but reading the readme
would have saved some time.

It contains the answer in a simple form:

    
    
         `youtube-dl -o - https://youtu.be/BaW_jenozKc | castnow --quiet -`

~~~
welfare
As someone who's never read a manual for anything I owned in my entire life I
find this fascinating.

Is there anything I'm missing out on, and if I wouldn't read manuals cover-to-
cover, what parts would you recommend reading?

Also, assuming many are like me, do you find a lot of quality issues or
inconsistencies in documentation just because it's a "tick-in-the-box"
exercise to provide a documentation and maybe an overlooked part of the
product development?

Thank you!

~~~
bogdan314
not the original comment author but I also read most manuals when I buy
something. If you buy electronics/products from decent companies, you will be
surprise how well the documentation is done.

Numerous times I found warnings of how to use or not a certain product, that
further expanded by understanding of how certain things works. Even the most
boring product can have instructions that you might don't know and could use
to learn them.

Example, my local shop sells tomatoes in a box, written with bold letters,
_don 't store in fridge_. I bought from that shop for 2 years, and always
store them in the fridge until I took notice of the warning and it pushed me
to read why.

~~~
wnoise
Well, why shouldn't you store tomatoes in the fridge?

~~~
cbsks
Serious Eats has an in-depth article about how to store tomatoes. Short answer
is that you should store them at room temperature until they ripen, then
refrigerate only if necessary: [https://www.seriouseats.com/2014/09/why-you-
should-refrigera...](https://www.seriouseats.com/2014/09/why-you-should-
refrigerate-tomatoes.html)

------
gregmac
So this (and I assume every other solution people have mentioned) are using
youtube-dl -- which means the chromecast is playing a stream from the device
initiating the cast.

When I cast from my Android phone to a cast receiver, my understanding is it's
basically sending the URL to the receiver and my phone is no longer involved,
other than as a remote to control position. (And frustratingly, I find my
phone will often get disconnected even though the video is still playing, so I
have to spend several seconds waiting or forcing it to reconnect to be able to
pause/stop).

What's the difference between these two modes? Is there something preventing
the URL method from working, or is there a reason it's preferable to download
+ stream?

------
steve_adams_86
Maybe this isn’t a great place to ask, but:

I’m so sick of my chromecast. The audio and video issues are absurd. I have a
fibre connection but I can’t manage to keep a 1080p cast working from my
machine, and Youtube frequently stutters and lags.

Sometimes I go to Apple’s website and almost buy an Apple TV, other times I
think about something more DIY like a raspberry pi media centre.

But what I wonder is... is all of this stuff shit? Do I just stick with my
chromecast? Maybe I’m just fooling myself that spending money and switching
would be any better.

Reading this just reminded me of how obnoxious my chromecast is.

~~~
dmonitor
You can use an adapter to get ethernet to your chromecast. I’ve never run into
issues on mine with YouTube at 1080p

~~~
mongol
I think this adapter is also bundled with the Ultra. Upgrading to that might
do the trick.

------
commotionfever
maybe I've missed something, but `catt` supports youtube natively.

    
    
        $ catt cast https://youtube.com/watch?v=xxx
        $ catt add https://youtube.com/watch?v=xxx
    

the latter will even add to your existing youtube chromecast queue

(it's using youtube-dl in the backgroud, but no need to mess about with pipes)

~~~
rahimnathwani
Presumably this just tells the Chromecast to stream that video from YouTube
directly. But OP's problem is that this doesn't work well for some specific
videos.

So OP is using catt not just to send a video URL to the Chromecast, but also
to actually serve the content.

------
Bnshsysjab
I’ve never figured out if it’s possible to stream to anything that’s not a
chromecast, e.g pc -> phone, or phone -> pc. Are these possible using ‘cast’
technologies available in iOS and Android?

~~~
zamadatix
[https://en.wikipedia.org/wiki/Google_Cast](https://en.wikipedia.org/wiki/Google_Cast)
device list at the bottom.

When they went to the CASTV2 protocol it became very difficult to do anything
unofficial as a server side implementation since official Cast SDK clients try
to authenticate the server as an authentic device.

------
steerablesafe
Re seeking: instead of pipes one could probably use youtube-dl to dump the url
and use a fuse filesystem to mount the url as a seekable file (it is typically
implemented as range requests). I found httpfs2 [1] in the Debian repositories
[2].

[1]
[https://sourceforge.net/projects/httpfs/](https://sourceforge.net/projects/httpfs/)
[2]
[https://packages.debian.org/sid/httpfs2](https://packages.debian.org/sid/httpfs2)

------
knorker
Uhm, the castnow readme has an example of how to cast from stdin. Are you
saying that doesn't work for you?

------
jeffbee
What does the author mean about the "final update"? Is the original Chromecast
really not getting any new software?

~~~
adrianmonk
Perhaps they are just using final to mean latest?

Most often, final means not only that something is currently the last item in
a sequence but also that there will not be any more items in the sequence in
the future. However, sometimes people use (misuse?) it to mean merely the last
time in the sequence for now.

~~~
jeffbee
It's confusing because it says "latest and final".

------
mnw21cam
Is there anything particularly wrong with running:

    
    
      youtube-dl -q -o - 'url' | castnow /dev/stdin

~~~
dannypgh
If it didn't work with process substitution, that's not likely to work either.

I'm guessing it is trying to seek, or running a stat first to check filesize
or similar.

------
frafra
I wrote something similar 9 months ago (just relying on VLC functionalities +
youtube-dl + avahi) and I have been using it since then (but less elegant):
[https://gist.github.com/frafra/9f5770c6af6e4dcdf91ba815225e5...](https://gist.github.com/frafra/9f5770c6af6e4dcdf91ba815225e5e65)

The main problem I have is that it is not possible to easily resume the stream
when youtube-dl stops working and you use a pipe or mkfifo. It would be cool
to be able to rerun the program again and continue from where it left, but
some streams are not seekable, so you would need to restart the software
automatically, consume or skip the first part and start adding the new content
at the end of the FIFO device.

------
Foxboron
> ip=$(dig +short chromecast.lan | tail -n 1)

This line requires some mdns server setup I believe. I didn't like running
avahi and thought there should be some super simple client for this, but after
searching I didn't find anything.

I wrote up 10 lines of go which spits out chromecast devices as json and use
jq to get the appropriate IP. Works quit well and now I have a fairly seemless
way to play videos to my chromecast from qutebrowser.

[https://github.com/Foxboron/mdns](https://github.com/Foxboron/mdns)

------
sdfhbdf
It's a nice solution to a problem that the author found. I am afraid that
knowing Google's walled garden around Chromecast, the `castnow` and `catt`
utilities might have trouble staying afloat.

~~~
tantalor
Here's the API docs for the "walled garden":

[https://developers.google.com/cast/docs/reference](https://developers.google.com/cast/docs/reference)

~~~
arilotter
This lets you create programs that run on the Chromecast, and programs that
can send data to the Chromecast. Programs that run on the Chromecast must be
"registered" on Google's cloud platform, and "published" on Google's
Chromecast platform.
[https://developers.google.com/cast/docs/registration](https://developers.google.com/cast/docs/registration)

The only way to run code on the device is to either serve your code through
Google's platform, or root the device and own it like the Linux box it is.

None of Google's documentation speaks about the Cast protocol itself. It's
against the Chromecast TOS to create a custom receiver device. You must buy
the Chromecast hardware. There have been several attempts to reverse-engineer
the receiver protocol and create custom receiver devices, but none of them
work with the current protocol.

I'd call this a "walled garden."

------
barbegal
What are the advantages of using a named rather than an anonymous pipe?

~~~
scarmig
Here? I guess that VLC displays whatever name you give the named pipe instead
of just a file descriptor.

In general, another advantage is that in scripts giving a pipe a name can
sometimes aid in clarity, supposedly.

