DIY: Icecast Internet Radio Server
Those of you who have found the time to enjoy my previous DIY articles will know that the series is about trying to encourage those swamped by the business of streaming to spend an evening rolling up their sleeves and getting their hands dirty with some tech. They aim is to foster a sense of "I can do it myself" and give those who spend more time on whiteboards and project management apps or CRM databases a little break actually playing with small pieces of streaming technology to help get a real-world understanding of "the art of the possible."
In the first article I focused on the simple but ever-in-demand issue of making an RTMP encoded live stream available to multiple distribution servers—something that few RTMP encoders natively allow you to do.
In the second I looked at the netcat command, combined with the sox command, and used the two together to deliver an extremely rudimentary audio stream from one point on our home network to another.
This second article brought up some interesting concepts, and I want to stick with audio for a while for a few reasons. First, there is less going on, so it makes some of the more fundamental concepts a little easier to focus on. Also, I am a big fan of audio streaming: Back when I started streaming in 1996 there was very little out there for video workflow engineering, but the audio space was maturing relatively quickly. It meant that many of my early webcasts were solving challenges not focused on "How much data and image quality can we get down this pipe?" but more on "How can we send stereo over a standard phone line to a remote location?"
These early webcasts were usually using RealAudio which, I hasten to note (as was discussed at the Content Delivery Summit in New York City earlier this month), remains popular in China even today. By the early 2000s, SHOUTcast and Icecast were dominating the streaming audio workflows. And while even today SHOUTcast is probably more well known in the consumer side of the market because it provided an "aggregation" website along with the software, Icecast has become a massive player in the professional audio streaming business, with many thousands of internet radio stations presenting themselves to their audiences with an Icecast-based platform, and more interestingly wide support in DSPs and embedded chips that were initially produced exclusively for MP3 players. While the control software rarely made use of that by adding the simple ICY/HTTP headers leaving the DSP to do the hard work of compression/decompression of the audio, actually in many cheap car radios is the latent (and in some cars, more recently enabled) ability to stream audio directly to the car (network connectivity aside), and it has been there for more than a decade in many cases.
The aim of this DIY article is to get you fired up with a cloud compute instance (no more scary than a few mouse clicks) and then connect to the Icecast server and have a look around, and confirm it is working and can play an audio file located on the server.
I will break the article at that point, and the next article will be a description of how to connect FFmpeg to the Icecast server and stream your own audio.
While I logically think that the FFmpeg article should have followed my previous netcat article, in the chicken and egg race between writing the FFmpeg one first or the Icecast DIY first, I came to the conclusion that it would be hard to understand if FFmpeg was correctly configured without a streaming server to which to send the stream from ffmpeg .
So for now be prepared that at the end of the article you will feel a bit "Meh… OK, so I can play an mp3." But with the next article adding the FFmpeg live audio encoding input, you will suddenly moved from "meh" to having a platform that allows you to properly live stream to a worldwide audience and to one of the most ubiquitous "device reaches" for audio that can receive a live stream. And all with open source software and a license free codec.
Let's do it.
In my first article on RTMP splitting, I used a Google Cloud Instance. I want to remain agnostic and so this time I will use my AWS server. You can opt to spin up any type of cloud instance. My only suggestion is that you take a step up from the free tier ones for this, since even if you are only streaming 192Kbps to a single remote location there will be times that that extra capacity will matter. This Icecast server might inadvertently become your headend for your world famous weekly internet radio show, and it is much easier if even the odd spike of bandwidth doesn’t cause downstream problems. The good thing is that you can move your instance type on most cloud infrastructures so ultimately you are not stuck.
Lets repeat the set up of the Ubuntu 16.04 machine I create in the RTMP splitter article. Assuming you can get as far as a log on yourself then let’s simply use the Ubuntu package manager to install Icecast2.
sudo apt-get update
sudo apt-get install icecast2
You will see the system install a long list of prerequisites and eventually install icecast2.
Now, to simplify things, I have created a config file for you to use for the rest of this article, so you can grab it from my Dropbox folder, copy it over the default config file, and we are all on the same page for the rest of our exploration. (Note that, due to the formatting of this page, the following line of code is split over two lines. You should copy and enter it all as a single line, with a space before the "-o")
sudo wget https://www.dropbox.com/s/lc1f8brjbsqmjn5/icecast.xml
Now simply restart Icecast:
sudo /etc/init.d/icecast2 stop
sudo /etc/init.d/icecast2 start
That wasn’t so hard now was it?
So what have we done? We now have a computer with a lot of connectivity (so many listeners can connect at the same time – the current default limit is 100, but you can [later] explore the config file you got from my Dropbox and adjust this upwards—and you can adjust this up a longway. How far? That will depend on the connectivity of the compute instance you have, and the bandwidth of the streams.
For now, though, lets confirm its running properly: first thing to do is, on your local machine open the web browser and (replacing <external-ip> for your machine’s IP address, found in the cloud management console) navigate to http://<external-ip>:8000.
In my case I opened http://220.127.116.11:8000/
So assuming you see that we are up and running!
Now click Administration. The username is "admin" and the password is "str3amingmedia."
At this stage there is little in the UI.
Let’s make sure we can stream.
In the next DIY installment, you’ll start sending an audio stream to the system from your local machine, and follow that through the Icecast UI and back to a media player on your local machine.
Back when online video was the size of a postage stamp, audio companies were changing the way the world heard radio. Here are reminiscences from RealNetworks and other pioneers.
22 Oct 2018
Can you believe it's been a quarter of a century since the first internet radio broadcast? In this first installment of a two-part series, we talk to some of the trailblazers who started a revolution.
06 Sep 2018
Building on previous DIY articles, this installment will walk you through capturing audio, encoding and packaging with FFmpeg, then playing out through the Icecast server you set up in the last article
15 Jun 2018
For the second installment in our do-it-yourself series, we look at how to set up a very basic audio stream between two computers on the same LAN. While the coding is simple, the concepts underneath are crucial to an understanding of how streaming works.
04 Apr 2018
Want to stream to YouTube, Facebook, and Twitch, but don't need a commercial streaming service and don't mind doing a bit of coding? Read on!
21 Feb 2018