Streaming to icecast/liquidsoap directly from the browser
Toots, one of the main liquidsoap developers, has been working on a very exciting tool that allows you to stream directly to liquid soap from a web browser. Imagine if your DJs could start broadcasting on your radio without needing to download any software!
Technologies at hand
Here is the flowchart from the webcast project itself.
The main technologies that make this possible are websockets and emscripten.
There is a websocket endpoint on liquidsoap that receives the mp3 data.
Emscripten is used to compile the libshine fixed point encoding library to
here if you are interested.
here and has an example client
I’ll show you how to set up liquidsoap to use the example application.
There are a few git submodule dependencies in this repository you’ll need to checkout. Run git submodule init and git submodule update to fetch them.
Check it out and run make, then run make test to start the server. Access the client in your web browser on localhost:8000.
The easiest way to get some sound going is to upload some mp3s to this cute little web based mixer. You can try the microphone as well.
Click ‘Start Streaming’ to connect. You are able to set bitrate, samplerate, and
stereo or mono output. You can change the stream destination URI if your
liquidsoap harbor is on a different IP or port.
The webworker option
is for performance reasons. MP3 encoding is CPU intensive to begin with, let
Check the output of liquidsoap and you should see that a client connected to the harbor. Since you’re using the libao output you should hear sound immediately!
You can use this setup with your usual icecast/shoutcast based liquidsoap configurations as well.
But wouldn’t it be nice if…
Now, the microphone input works well. For me, I’d like to stream directly from
Traktor to this. If you’re looking to stream from audio software already running
on your system, you might be out of luck as it looks like only
microphone/line-in can be captured. You could use something like soundflower to
route your computer’s output to input, but that’s another article.
Luckily Traktor and similar software already supports broadcasting to icecast anyway, so I guess its not really an issue.
Modern Online Radio with Liquidsoap Book - Free Sample
Need more help with liquidsoap?
Can’t get your script to work?
I wrote a book to help you learn Liquidsoap. The book covers all aspects of liquidsoap, from getting started, to making dynamic streams, audio processing, video, customizing metadata, authentication, and more. The book is available for purchase now here!
You can get a free sample chapter of my book! Just enter your email address to subscribe to my mailing list and I'll send you a free PDF sample of the book in return.