Python Web Proxy Convinces Sonos To Stream YouTube

[Maurice-Michel Didelot] owns a Sonos smart speaker, and was lamenting the devices inability (or plain unwillingness) to stream music from online sources without using a subscription service. YouTube Music will work, but being a subscription product there is a monthly fee, which sucks since you can listen to plenty of content on YouTube for free. [Maurice] decided that the way forward was to dig into how the Sonos firmware accesses ‘web radio’ sources, and see if that could be leveraged to stream audio from YouTube via some kind of on-the-fly stream conversion process.

What? No MP4 support for web radio? Curses!

So let’s dig in to how [Maurice] chose to approach this. The smart speaker can be configured to add various streaming audio sources, and allows you add custom sources for those. The Sonos firmware supports a variety of audio codecs, besides MP3, but YouTube uses the MP4 format. Sonos won’t handle that from a web radio source, so what was there to do, but make a custom converter?

After a little digging, it was determined that Sonos supports AAC encoding (which is how MP4 encodes audio) but needs it wrapped in an ADTS (Audio Data Transport Stream) container. By building a reverse web-proxy application, in python using Flask, it was straightforward enough to grab the YouTube video ID from the web radio request, forward a request to YouTube using a modified version of pytube tweaked to not download the video, but stream it. Pytube enabled [Maurice] to extract the AAC audio ‘atoms’ from the MP4 container, and then wrap them up with ADTS and forward them onto the Sonos device, which happily thinks it’s just a plain old MP3 radio stream, even if it isn’t.

Sonos doesn’t have the best reputation, let’s say, but you can’t deny that there’s some pretty slick tech going on inside. Here’s a neat hack we covered last year, adding Sonos support to an old school speaker, and a nice teardown of a IKEA Sonos-compatible unit, which uses some neat design hacks.

Thanks [mip] for the tip!

Featured image by Charles Deluvio on Unsplash.

Video Projector From An Old Single-slide Unit

Here’s a video projector that [Matt] hacked together. He needed a small and inexpensive solution to use with his R2D2 build. As you can see in the video after the break, it has no problem playing back the Princess’ distress call. But even if R2D2 is not one of the droids you’re looking for, we think this can be useful in other ways. One use that pops into mind is for projector-based Halloween displays.

As with past projector hacks, all you really need to pull this off is a light source, an LCD screen on which you can playback video, and a lens to focus the light onto a screen. Usually the LCD is the most expensive part of the project and building an enclosure to the correct dimensions can be a bit difficult. [Matt’s] solution was to use an MP4 knockoff media player. The rest of the setup is a ’50s era slide projector. The screen from the media player is about the same size as a single film slide, so he removed the screen from the case and put it where the slides go.

Continue reading “Video Projector From An Old Single-slide Unit”