Open Source Web Radio with Icecast and Raspberry PI

Connect with me on social networks for updates and content!
twitter icon facebook icon pinterest icon mastodon icon
5
(1)

As web became more popular, a number of web radio born because of their low maintenance costs. One of most popular platform to broadcast a private web radio is Icecast2, which runs also on Raspberry PI computer boards

In this tutorial I’m going to show you how to install Icecast2 on Raspberry PI.

This post will start from describing what Icecast is, what do you need to run a public web radio, installation and configuration for a very simple web broadcasting.

What is Icecast

Icecast logo

Icecast is an open source software (distributed indet GNU GPL, version 2) able to create a self hosted streaming server. Supports a number of audio/video media formats, like Ogg (Vorbis and Theora), Opus, WebM and MP3.

You can use Icecast to create an Internet radio station, run a private jukebox and many other things. Even if its configuration may appear a bit complex, because its main configuration requires manually handling xml files.

This is compensed by that Icecast offers a great flexibility and many options to get advanced behaviour.

Before Starting

Before starting with Icecast installation and configuration, you need to arrange how your listeners will reach you.

First of all, you will probabily want to share with users a mnemonic url instead of a simple IP address (which can also change with your Internet Service Provider updates). For this purpose, the famous No-IP service can give a way to have your free second level domain.

Moreover, you will need to configure your router to forward requests from outsider (internet) users directly to Raspberry PI. This vary from router to router. Usually, this option is available on WAN settings and is merely called “Port Forwarding”. Remember to forward both TCP and UDP traffic, using your favorite port (default for Icecast2 is port 8000). If you choose a different port, remember to set Icecast configuration file (icecast.xml) accordingly.

What We Need

Raspberry PI 4 model B image

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box

Step-by-Step Procedure

We’ll proceed by installing OS, installing Icecast2, configuring our first mount point and configuring a common client from where our voice will be broadcasted.

Prepare Operating System

Start installing you OS. I strongly suggest to use Raspberry PI OS Lite (for a fast, headless operating system). But you can also install Raspberry PI OS Desktop, in this case working from its terminal console.

Make your OS up to date. From terminal:

sudo apt update -y && sudo apt upgrade -y

Install Icecast2 on Raspberry PI

Official Icecast installation docs require to download source and compile it from your computer. An easier way is using the convenient aptitude package manager. From terminal:

sudo apt install icecast2

Installation procedure will ask you if you want set initial configuration and passwords from now. I suggest to select yes and press ENTER key:

Icecast apt install 1

Next screen will ask your domain from where your listener will receive radio stream. I will use my free No-IP domain, you must use your one instead:

Icecast apt install 2

Before completing Icecast installation, you will be required to add 3 passwords. The first one is to control access to media sources (please add your favourite password):

Icecast apt install 3

The second password is required to use stream relays (used in multinode streaming). Even if you will hardly use this configuration, you have to enter your favourite password and press enter:

Icecast apt install 4

Final, and most important, password will grant access to administration console. Please add also this password (using your favourite one) and press ENTER:

Icecast apt install 5

For all the 3 password just added, default user will be “admin”. These passwords can be edited from default icecast configuration file (icecast.xml).

Configure Your First Icecast Radio (Mount)

An Icecast radio (or, in general, media) can be tought as a mount point that will be mapped in a specific url to be published. To create you very first radio, make a backup copy of default icecast configuration file and open it to edit:

sudo cp /etc/icecast2/icecast.xml /etc/icecast2/icecast.xml.backup
sudo nano /etc/icecast2/icecast.xml

Add following code before final “</icecast>” row:

    <mount type="normal">
        <mount-name>/example.ogg</mount-name>
        <username>iceUser</username>
        <password>icePwd</password>
        <max-listeners>10</max-listeners>
        <dump-file>/tmp/dump-example.ogg</dump-file>
        <burst-size>65536</burst-size>
        <hidden>1</hidden>
        <public>1</public>
        <on-connect>/home/icecast/bin/stream-start</on-connect>
        <on-disconnect>/home/icecast/bin/stream-stop</on-disconnect>
    </mount>

Use your favourite user and password instead of iceUser/icePwd. These credentials will be needed in your source software to stream your radio. Also set max-listeners (the maximum number of users which can listen your stream) according to your needs, but also caring that Raspberry PI can suffer too much listeners. You need to test increasing this value to understand how many concurrent people you can serve.

Close and save your file. Restart icecast to make changes running:

sudo systemctl restart icecast2.service

You can also check if new configuration file worked with Status command:

sudo systemctl status icecast2.service

This will create a very basic web radio, that will be available from http://myhomepi.webhop.me:8000/example.ogg (last part coming from mount-name), with a common web browser, once a streaming source will start broadcasting.

Configure Icecast2 Streaming Source

We now need to configure our source: the device from where we’ll broadcast our voice.

Icecast supports a number of clients, listed at https://icecast.org/apps/. I will use the free Android CoolMic. You can install this app from Google Play Store.

Once installed, we have to configure setting by using domain:port, username and password from what added in icecast configuration file.

Open Cool Mic app:

Android Cool Mic home

Identify the 3 dots on top right side of screen:

Android Cool Mic home - options

Tap on them to open options and identify Settings:

Android Cool Mic home 3 dots tap

Open Settings by tapping on it. In next screen, there are (beside other) 4 main parameters to set, according to what configured in icecast.xml file:

  • Server – we need to set this to our domain:port
  • Username – we need to insert here the user configured in icecast.xml mount-point
  • Password – we need to insert here the password configured in icecast.xml mount-point
  • Mountpoint – to be set, of course, according to mount-name
Android Cool Mic settings icecast2

Finally go bask to Cool Mic home and tap “Start Livestream” button. Your device will start streaming to your web radio:

Android Cool Mic streaming

From your favourite browser, add your url composed by domain name, port and mount-point. According to my example, it will be “http://myhomepi.webhop.me:8000/example.ogg”. You will find a player read to listen:

Raspberry pi icecast2 streaming page

More info about configuration and tunings can be found in Icecast2 official Docs.

Enjoy!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?