Using ffserver to transcode live radio and broadcast to unsupported clients (Chromecast, .m3u8)

Google Chromecast can be easily configured to play audio or video files over HTTP. Using PyChromecast, one can play a publicly-accessible audio file by providing its URL.

media_controller.play_media("", 'audio/mp3')

However, things start to go wrong when trying to play HLS streams, which have the .m3u8 file extension.

Enter ffserver

ffserver is (or rather was) an easy way to take a input feed and transcode it to one or may output streams while being provided with the ffmpeg binaries. Since ffmpeg can already decode .m3u8 HLS streams, it can be used directly as an input feed to ffserver. Given the right configuration, on can then expose this feed as a streaming mp3/ogg/aac file which can be understood by the Chromecast, or any other dumb player which can play a file from an HTTP stream.

ffserver serves ordinary audio streams (.ogg, .mp3, …) over HTTP.

N.B. ffserver has been officially deprecated in 2016 and subsequently dropped from ffmpeg binaries in 2018. Ubuntu 18.04 repositories serve ffmpeg 3.4.6 which still includes ffserver.


ffserver’s configuration itself is pretty straightforward. We both define an input feed and an output stream. Multiple streams can be defined for the same feed.

See for pastable code and a Dockerfile!

Running ffserver should now start an HTTP server, which serves our stream1.ogg on http://localhost:5000/stream1.ogg .

See this GitHub Repository for a complete working example.

Minecraft Discs : Dynamically-loaded Custom Music Discs From YouTube Videos

As usual, the code is on GitHub.

A while ago, I had the idea of a simple Minecraft mod which would allow the creation of custom music discs in Minecraft using YouTube as the primary way of distributing and synchronizing the actual music tracks amongst players. All of this, while allowing any player on the server to add their own favorite music tracks.

The Forge

The actual Minecraft mod is quite simple. It reads a simple JSON-formatted list of tracks, and register them as items with Forge Mod Loader, giving them a game ID. At the same time, they get an item texture assigned, which is simply one of the existing record item textures.

Building Resources

To get the music tracks to play, the mod uses a separate resource pack, built by grabbing YouTube videos, and extracting the audio using ffmpeg. I made a simple java program to parse the JSON track list and download the tracks, while creating the required directory structure for a Minecraft resource pack. At this step, track titles also get added into the game.

Keeping Clients Coherent

Since the primary use case of this mod is multiplayer gameplay, we needed a way of keeping clients coherent, while still allowing a frequent additions. I came up with a simple CRUD-style application hosted on a Heroku container, which would serve a properly formatted track list, and offer a simple form for user to add new songs, all of that using a free-tier database. The only downside to this approach is that the container shuts itself off after 30 minutes of inactivity, then requiring roughly 25 seconds to serve the next request. This causes the game client to freeze in the loading screen, while waiting for a reply. This could be easily fixed by stepping to a more premium usage tier, but the very light usage mostly makes this a non-issue.