Open Source Web Radio with Icecast and Raspberry PI

4
(4)

Last Updated on 13th April 2024 by peppe8o

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

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

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

What is Icecast

Icecast logo

Icecast is an open-source software (distributed in 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 compensated by that Icecast offers 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 probably 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 you 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 varies 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 favourite port (default for Icecast2 is port 8000). If you choose a different port, remember to set the Icecast configuration file (icecast.xml) accordingly.

Finally, please remember that Icecast works as a broadcasting server. So, you need to configure:

  • The Icecast server, that we’ll install in our Raspberry PI computer board
  • a voice source, for this tutorial I will show how to get this with an Android smartphone, but you can choose one of the supported Icecast clients

The following picture shows you a general schema:

raspberry-pi-icecast-schema

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 to continue with the project or remove them from the shopping cart. So, hardware will be only:

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 your OS. I strongly suggest using 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 you to download the source and compile it from your computer. An easier way is using the convenient aptitude package manager. From terminal:

sudo apt install icecast2

The installation procedure will ask you if you want to set the initial configuration and passwords from now. I suggest selecting yes and then press ENTER key:

Icecast apt install 1

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

Icecast apt install 2

Before completing the 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

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

Icecast apt install 5

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

Configure Your First Icecast Radio (Mount)

An Icecast radio (or, in general, media) can be thought of as a mount point that will be mapped in a specific URL to be published. To create your very first radio, make a backup copy of the 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 who can listen to your stream) according to your needs, but also care that Raspberry PI can suffer too many 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 the new configuration file worked with the 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 (the last part coming from mount-name), with a common web browser, once a streaming source starts 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/.

For this tutorial, I will use the free Android CoolMic, available for Android smartphones. You can install this app from the Google Play Store.

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

Open the Cool Mic app:

Android Cool Mic home

Identify the 3 dots on the top right side of the 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 the next screen, there are (besides other) 4 main parameters to set, according to what is configured in the 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 back to Cool Mic home and tap the “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.

Next Steps

Interested in projects to perform with the Raspberry PI computer board? Try to look at my Raspberry PI computer tutorial pages.

Enjoy your web radio with Icecast and Raspberry PI!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 4 / 5. Vote count: 4

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?