Netflix and Spotify on a Raspberry Pi 4 with Chromium and Widevine
blog.vpetkov.net
blog.vpetkov.net
It really bummed me out because the potential of a language-agnostic cross-platform library for legally streaming music is huge. It essentially decouples the service from the UI.
[1]: https://github.com/Fornoth/spotify-connect/blob/master/READM...
> Using this code to connect to Spotify's API is probably forbidden by them. Use at your own risk.
The eSDK replaces it, but it's basically partners-only.
It's not much of a replacement. And as you say, there is no public access anyway.
Not really a huge hurdle nowadays, but they used to have the VM and anti-debug detection ratcheted up all the way and it would trigger when I had IDA open. (I believe it was a findwindow check)
I don’t think that’s inadequate hardware performance. I think that’s Linux GPU stack. More specifically, the parts where hardware acceleration integrates with that decades-old X11.
I once made a toy project for Pi4 that can render GLES content either with or without desktop manager: https://github.com/Const-me/Vrmac/ I did observe occasional tearing on desktop, with both 3D content or accelerated h264 video. Maximizing window into borderless fullscreen didn’t help. However, rebooting into console and running the same code on top of DRM/KMS without X11 resulted in no tearing.
If you tell the compositor to fuck of by overriding the windows redirect state or have a compositor that at least detects full screen windows you generally get no screen tearing at the cost of everything the compositor normally does.
I don’t disagree with that, but I think the underlying reason is X server protocol. It’s hard to implement vsync properly when there’s a socket connecting application to display server.
On Windows, various GPU APIs and even parts of the GPU driver are DLLs loaded into the process. DLL functions don’t have latency and API designers don’t need to consider that (except stuff that have good reasons for latency, e.g. asynchronous draw/compute/copy calls). Works quite well in practice, I don’t remember screen tearing issues on Win10 unless I explicitly disable vsync, e.g. with DXGI_PRESENT_ALLOW_TEARING flag. Most apps don’t do that and don’t tear.
The problem statement “implement proper vsync” only looks easy on the surface. If one considers all the hairy details, a good implementation gonna affect many components of the OS, not just GUI related also power management and others. Otherwise it gonna introduce presentation latency (especially bad for online games), consume much more RAM and VRAM, and/or waste too much electricity (especially bad for laptops).
> If you tell the compositor to fuck of by overriding the windows redirect state or have a compositor that at least detects full screen windows
If a developer is in a position to replace OS components, that’s probably an embedded environment. For that case DRM/KMS combo is already flawless, at least according to my experience. That’s not just on Pi4, I’ve developed stuff for a few other ARM SoCs, too.
Desktop software developers can’t replace OS components or ask users to do so. They need something that works out of the box, is reliable and efficient.
That would affect all X11 based applications, yet somehow screen tearing consistently seems to disappear as soon as I bypass the compositor.
> Otherwise it gonna introduce presentation latency (especially bad for online games)
I once went around looking how much latency various Linux desktop environments introduce. The most widely used ones (KDE and Gnome) on their default settings are outright catastrophic. KDE lets you disable desktop effects and the compositor, Gnome only bypasses it for full screen applications. As always eye candy > functionality.
This article was helpful for the Rpi4 as well: https://lemariva.com/blog/rss/raspberry-pi-4-video-accelerat...
Approximately all software in the world is very suboptimal, as is occasionally proven by people who make things go fast on slow hardware for fun and games (eg see 3d engines on c64 or realtime video decoding & streaming from floppy on 8088)
eglSwapInterval does nothing. The GPU driver exposes no *_swap_control extensions anywhere. There’re 3 extendable parts, EGL, GLES client and GLES server with many extensions each, but nothing resembling GLX_EXT_swap_control/GLX_MESA_swap_control/GLX_SGI_swap_control.
Other applications on that Pi4 who render many FPS (web browser or VLC player) also have screen tearing. I assume these people know way more about Linux GPU stuff, yet they failed too.
Do you have an advice how I can do that on that Pi4, with EGL 1.1 and GLES 3.1?
P.S. Based on the internets, the problem was introduced in Pi4. In earlier versions things were good.
Netflix I watch in Kodi Netflix Addon. Worked great so far with no screen tearing.
See:
https://gist.github.com/ruario/19a28d98d29d34ec9b184c42e5f8b... (ARM version)
https://gist.github.com/ruario/3c873d43eb20553d5014bd4d29fe3... (x86 and x64)
They’ve stopped rotating their curated playlists and made discovering playlists more and more annoying.
I’ve stopped paying for Spotify because of that and now primarily use Amazon Music Unlimited for music on the go but it also now started to have issues with too tracks becoming unavailable day in and day out.
I wish Pandora would become available outside of the US or Spotify Stations (I don’t know if it’s good, I’ve used Pandora back when they didn’t geoblock their services) because I want to be able to discover music.
Since the lockdown in the UK I’ve went back to using Internet Radio, my Yamaha Music Cast receiver has a good directory and it’s so far been a much better daily listening experience than Spotify.
I might give Napster and Deezer a try since they are supported by my main music setup at home too.
Amazon seems to work right now and I was pleasantly surprised that Spotify et al hasn’t killed internet radio yet.
Their API (MusicKit) is decent, but the rate limiting is fairly onerous.
The bit about "every single track" isn't true. It's hard to find torrents for older, more obscure things.
Your general take is right, though. It's easier to pay Spotify $10 per month than to go to the effort of torrenting, cataloging, transferring to your device, etc.
Maybe this falls in to the hard category but once you make it in to the private music tracker, you have everything trivially accessible. I still have an account on the tracker but I just don't bother using it since spotify is so cheap and useful. It just makes no sense that they would implement DRM since it does basically nothing since no one was prevented from piracy through DRM.
Don't remember how I got Widevine installed exactly, but if I remember right, it's a blob ripped from ChromeOS, which is why it only works for Chromium and not Firefox.
What happens if you install Chrome on a new (Arm64 M1) Macbook? This is the sort of situation where I am looking forward to Mac's causing improved ARM support in general.
Here's a typical media manifest for a typical piece of netflix content: https://gist.githubusercontent.com/justjanne/b2cbff54588466f... (identifying data and URLs redacted).
Note how (a) the audio is only 128kbps, and (b) the audio is just directly linked (the files are just aac directly, you can play them in any player).
Spotify would revoke the app keys if they were published in something like this I expect.
And yes, by and large. Widevine offers a bit more than just being closed source in terms of Google doing breach monitoring and fixing but yes.