How to build a Streaming Radio Server with Icecast on Linux

Configurare noua (How To)

Situatie

Solutie

Installing Icecast

You can download Icecast using your distribution’s package manager, which is the method we’ll use in this article.

As with many software projects, if you want the most recent version of Icecast, download and build the source directly from the official website or clone the public Git repository. Version 2.5 is near completion at the time of writing and has many new features, including a complete overhaul of the web UI—but is not included in distros just yet.

For Debian based distributions, install the icecast2 package using apt:

sudo apt install icecast2

1-15.png (750×50)

For Redhat distros, use dnf to install the icecast package:

sudo dnf install icecast

1-17.png (750×50)

Initial Configuration

So you’ve installed Icecast. Now what? Debian distros will run a post-install script which helps you configure things. At the first dialog, hit the left arrow key to select “Yes” and then hit Enter:

2-8.png (750×184)

Since we’re setting up a private radio stream, we’ll enter the machine’s LAN IP at the next prompt:

3-8.png (750×184)

A source client is the program you use that streams media files (or live audio) to the server. The source password authenticates with Icecast to allow you to start a stream. I recommend a unique password and not the default (which is “hackme”). Maybe something like:

4-6.png (750×184)

Relays are useful in larger setups for distributing listener load to multiple servers. We won’t be setting up relays here, so you can enter whatever you want (but again I recommend changing the default):

5-8.png (750×184)

Finally, we’re asked for the admin user password. You’ll use this to access Icecast’s web interface admin section. Change the default to something unique:

6-6.png (750×184)

Redhat distros simply return to the command prompt after installing. No big deal, we’ll set things up directly in the configuration file, located at “/etc/icecast.xml”. Fire up your favorite text editor and let’s get to work:

3-install-2.png (750×50)

The default configuration is well-thought-out for most simple installations like ours. Icecast developers recommend the best practice of changing as little as possible, and fine-tune afterwards to suit your needs.

First, change passwords from their defaults:

5-install-2.png (750×184)

Next, change the bind-address to your server’s LAN IP address:

7-install-2.png (750×184)

Save the configuration file, then restart Icecast for our changes to take effect:

9-install.png (750×50)

Let’s verify that we’re up and running:

sudo systemctl status icecast.service

11-install-1.png (750×143)

Choosing a Source Client

There are 3 primary components of Icecast streaming: the source client, the Icecast server, and the listener client. They are all independent of each other and can all (and many times do) operate on different machines. A source client is what actually plays your music files, or streams live audio to Icecast. Icecast then distributes that stream to listeners via the HTTP protocol. It goes a little something like this:

icecast-flow-1.png (750×406)

Choosing the right source client for your setup depends on many factors. Some questions you may consider when deciding will include:

  • Will I stream pre-recorded sound/music files?
  • Will I stream live audio from microphones and mixing consoles?
  • Will I broadcast from a desktop/laptop or a mobile device (or both)?
  • Do I have operating system constraints or requirements?

There’s a non-exhaustive list of source clients on the Icecast Apps page.

For this tutorial we’ll use a feature-rich yet easy-to-use source client made by Daniel Nöthen called Broadcast Using This Tool (BUTT for short—don’t ask me whether this acronym was intentional or not!). We’ll use BUTT to livestream from our microphone to Icecast. BUTT is available for Linux, macOS and Windows. You can get it from the official download page.

Configuration is pretty straightforward. From the main window, select the “Settings” button, then on the “Main” tab, under “Server Settings”, click the “Add” button. A new window pops up to configure your server.

Choose a name for this server’s config (multiple server configurations are supported) and select the “Icecast” radio button. Fill out the IP address as well as port (default port is 8000) of your Icecast server, along with your source password. Under “Icecast Mountpoint”, add .OPUS to the end (Adding an extension helps some listener clients determine which codec is being used). Leave the “Icecast User” as source and “Use legacy Icecast protocol” unchecked. Click “Add” and then, under the parent window, click “Save”.

butt-1-1.png (750×816)

Ok, let’s talk sound! Following in the spirit of F/OSS, we’ll use Opus (a totally open, royalty-free, highly versatile and widely supported audio codec, also created by Xiph.org) for our stream.

From “Settings”, click the “Audio” tab. Set “Samplerate” to 48000Hz (required by Opus), verify “Primary Audio Device” is where your microphone is connected and set “Streaming Codec” to Opus:

butt-2.png (750×1108)

Finally, go back to the “Main” tab and click “Save”:

butt-3.png (750×1034)

From here you can close the “Settings” window. When you’re ready, click on the “Play” button, which will start your stream. If you’ve configured everything correctly, you’ll currently be making your server’s radio stream debut!

butt-4.png (744×362)

Cool! Now let’s log into the Icecast web UI at “http://LAN_IP:8000/admin/” and enter “admin” for the username along with your configured Icecast admin password:

ff-1.png (750×212)

Select “Mountpoint List” from the main Admin page:

ff-2.png (750×100)

Copy the “M3U” hyperlink:

ff-3.png (750×307)

This link, minus the .M3U extension, is what you will use to listen with your web browser.

Choosing a Listener Client

Listener clients in general require very little configuration. Thanks to HTML5 audio, you can simply point a web browser to your new stream URL. Here’s a list of browser supported HTML5 audio encoding formats.

Using a web browser, paste the stream URL you copied above into the address bar (again, removing the .M3U extension) and hit Enter.

ff-4.png (750×292)

Additional Configuration

Icecast has many advanced features. Some of them are:

  • Multiple simultaneous streams on a single server
  • A “fallback” system which can programmatically move listeners between mountpoints
  • Relay functionality, distributing your streams across multiple servers
  • “URL Authentication”, authenticating users against a dedicated server/database (v2.5+)
  • Built-in chroot ability
  • Publishing your stream in the Icecast YP directory
  • Shoutcast compatibility mode

These features and more are very well explained in the official Icecast documentation.You can also use port forwarding to access your stream from outside your local network.

Promoting Your Station

Promoting really depends on the type of station you create. If it’s just for fun, telling a good friend will suffice! If you want more exposure: listing in the Icecast directory, creating a quality website around it and executing a comprehensive marketing campaign on social media is a surefire way to gain some attention online.

The most important piece of information I can give you when building your first streaming radio station is to have fun! The result is very rewarding and full of exciting moments that you’ll treasure forever.

Tip solutie

Permanent

Voteaza

(1 din 3 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?