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("http://example.com/audio.mp3", '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.


Configuration


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.



/etc/ffserver.conf
See https://github.com/keotl/ffserver-live-radio-mirror-example 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.