Icecast2
Icecast is a streaming media server which currently supports Ogg Vorbis and MP3 audio streams. It can be used to create an Internet radio station or a privately running jukebox and many things in between. It is very versatile in that new formats can be added relatively easily and supports open standards for communication and interaction.
Icecast is distributed under the GNU GPL, version 2. A copy of this license is included with this software in the COPYING file.
Find the Icecast2 documentation here
Prerequisites
Your URL needs to be setup:
[isabell@stardust ~]$ uberspace web domain list
isabell.uber.space
[isabell@stardust ~]$
Installation
[isabell@stardust ~]$ cd ~/tmp
[isabell@stardust tmp]$ wget http://downloads.xiph.org/releases/icecast/icecast-2.4.4.tar.gz
[isabell@stardust tmp]$ tar -xzf icecast-2.4.4.tar.gz
[isabell@stardust tmp]$ cd icecast-2.4.4
[isabell@stardust icecast-2.4.4]$ ./configure --prefix=$HOME
[isabell@stardust icecast-2.4.4]$ make
[isabell@stardust icecast-2.4.4]$ make install
If there were no errors, you can safely remove the installation directory and archive:
[isabell@stardust icecast-2.4.4]$ cd ..
[isabell@stardust tmp]$ rm -r icecast-*
[isabell@stardust tmp]$
As --prefix=$HOME
was used, components of icecast are in the home directory now:
~/bin/icecast (icecast binary)
~/etc/icecast.xml (config)
~/share/icecast/ (files of the web interface)
~/share/doc/icecast/ (documentation)
Configuration
Before editing a config, it’s best practice to copy the untouched config file to a *.dist
file.
[isabell@stardust ~]$ cp ~/etc/icecast.xml ~/etc/icecast.xml.dist
[isabell@stardust ~]$
You can then later compare your config with the default one with diff
.
[isabell@stardust ~]$ diff ~/etc/icecast.xml ~/etc/icecast.xml.dist
[isabell@stardust ~]$
Use this snippet to generate random passwords:
[isabell@stardust ~]$ pwgen 32 1
topsecretrandompassword
Edit ~/etc/icecast.xml
and change the following entries:
<hostname>isabell.uber.space</hostname>
<source-password>y0uRS3cR3t_1!</source-password>
<admin-password>y0uRS3cR3t_2!</admin-password>
<relay-password>y0uRS3cR3t_3!</relay-password>
<admin>yourmailadress</admin>
<location>YourLocation</location>
<listen-socket>
<port>8000</port>
<shoutcast-mount>/stream</shoutcast-mount>
</listen-socket>
<paths>
<ssl-certificate>/home/isabell/share/icecast/isabell.uber.space.pem</ssl-certificate>
</paths>
Use the port you were assigned by uberspace port add
above.
Create ~/share/icecast/update-cert.sh
to consolidate certificate keys into one file.
#!/bin/sh
CRTFILE=/home/isabell/etc/certificates/isabell.uber.space.crt
KEYFILE=/home/isabell/etc/certificates/isabell.uber.space.key
PEMFILE=/home/isabell/share/icecast/isabell.uber.space.pem
cat $CRTFILE $KEYFILE > $PEMFILE
chmod 640 $PEMFILE
supervisorctl restart icecast
Change permissions and execute this script initially.
[isabell@stardust ~]$ chmod +x ~/share/icecast/update-cert.sh
[isabell@stardust ~]$ ~/share/icecast/update-cert.sh
[isabell@stardust ~]$
Edit crontab with crontab -e
and add following line for monthly execution.
@monthly /home/isabell/share/icecast/update-cert.sh > /dev/null
Create the directory for the log files.
[isabell@stardust ~]$ mkdir -p ~/var/log/icecast/
[isabell@stardust ~]$
Try to manually run icecast with your config to print out possible errors.
[isabell@stardust ~]$ ~/bin/icecast -c ~/etc/icecast.xml
[isabell@stardust ~]$
If it is running without errors, close it with Ctrl+C
. Otherwise most likely you need to fix them in your config.
Now you can set up the service by creating a file ~/etc/services.d/icecast.ini
with the following content. Be sure to place your username.
[program:icecast]
command=%(ENV_HOME)s/bin/icecast -c %(ENV_HOME)s/etc/icecast.xml
autostart=yes
autorestart=yes
After creating the configuration, tell supervisord to refresh its configuration and start the service:
[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE RUNNING pid 26020, uptime 0:03:14
[isabell@stardust ~]$
If it’s not in state RUNNING
, check the logs.
Configure web server
Note
Icecast is running on port 8000.
To make the application accessible from the outside, configure a web backend:
[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$
Additional configuration
Find more configuration possibilities in the configdocu.
With this basic setup you can already stream audio from a source client like mixxx to your icecast server by providing
the listening port,
source
as username and the source-password,your hostname or ip address.
On the icecast website you can find a list of other possible clients.
Administration
You can find your logs in ~/var/log/icecast/
.
You may want to change the log level from Info 3
to Debug 4
for debugging.
<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
After having changed the icecast.xml
you need to restart the service.
Best practices
Source streaming can be done locally by oggfwd in combination with ffmpeg to encode to Ogg Vorbis format.
[isabell@localhost ~]$ ffmpeg -i $yourinputfile -vn -acodec libvorbis -b:a 128k -f ogg -y /dev/stdout |
oggfwd isabell.uber.space $yourlisteningport y0uRS3cR3t_1! /stream.ogg
A more detailed setup for live streaming concerts with JACK audio server can be found at: https://lar.ven.uber.space/streaming_setup
Updates
Note
Check the latest news regularly to stay informed about the newest changes.
Tested with icecast-2.4.1 and Uberspace 7.3.10
Written by: benks <uberspace@benks.io>