How to mirror an internet audio stream (using Icecast)
Sometimes you might run into an internet radio station or stream that you like, but which keeps dropping out because of too many people listening. So what can you do about it? You can create a mirror and post a link to it somewhere where listeners are watching or send it to the station or stream manager. Then some people can tune in to your mirror instead of the original stream reducing the load and increasing the stability of the stream for everyone.
So let's see how to set this up. Ideally you would have a server online (VPS or dedicated), but this could be done at home too. I will cover a GNU/Linux set up with emphasis on Ubuntu or Debian since this is what most people are likely to be using. You will need to have a terminal open. If you use GNOME (Ubuntu's default desktop environment) try gnome-terminal and if you're using KDE (Kubuntu) try konsole.
1. Download and install Icecast2
Use your distribution's package manager to install package "icecast2". On Ubuntu or Debian you can run this in the terminal:
sudo apt-get install icecast2
On Fedora you can also use
yum install icecast2
2. Configure Icecast2
Open the configuration file /etc/icecast2/icecast.xml:
sudo nano /etc/icecast2/icecast.xml
Go the the
<authentication> section that should like this:
<authentication> <!-- Sources log in with username 'source' --> <source-password>hackme</source-password> <!-- Relays log in username 'relay' --> <relay-password>hackme</relay-password> <!-- Admin logs in with the username given below --> <admin-user>admin</admin-user> <admin-password>hackme</admin-password> </authentication>
Change "hackme" into the passwords of your choice. You can use the same password for both sources log and the admin login. You can also change "admin" user name to something else.
Now scroll to the end of the file and just above the last closing tag
add the following:
<relay> <server>xx.xx.xx.xx</server> <port>8000</port> <mount>/</mount> <local-mount>/mirror</local-mount> </relay>
Replace xx.xx.xx.xx above with the address of the original stream you're mirroring (don't use http://) and also replace 8000 with the port of the original stream. Also replace "mirror" with the desired name of the mirror.
You can now save this file and edit /etc/default/icecast2:
sudo nano /etc/default/icecast2
Just modify the last line from
ENABLE=true. Then save and start the Icecast server like this:
sudo /etc/init.d/icecast2 start
3. Log in to pick up your new mirror stream
Go to your mirror address (xx.xx.xx.xx:8000) and enter the admin username and password you set up in the authentication section above. You should then see the stream there, looking something like this:
You can click on the M3U or XSPF links to tune in. These are also the links you can publish for your stream. In case there are no these links (some servers might be using older Ubuntu or Debian packages of Icecast) you can just append the stream name to your address like this xx.xx.xx.xx:8000/streamname and use that as a link.
Note that if you are setting this up at home you need a public IP address of your computer which you can see here and you'll need to set up port forwarding for the port of your mirror stream in your router. Consult the manual of your router for this. Of course, if your connection drops out your IP will change. To prevent that you can use a free Dynamic DNS service to get a permanent hostname. Modern routers should have a facility for setting this up with the Dynamic DNS service as well.
Here is my example stream mirror of an excellent ambient radio station called "Cryosleep": http://memenode.com:8000/cryosleep.m3u
This tutorial is based on one available at Howtoforge which is about setting up an icecast radio station of your own rather than just mirroring.