This tutorial covers a player or receiver of web radio streams at Ubuntu 10.04. It's purpose is to run a stable 24/7 service without user interaction. It consist of a liquidsoap and icecast configuration for streaming audio between 2 locations. Streaming is done by using OGG with a constant bitrate of 160kbit/s, but you use other codecs or settings, because streaming is done completely by using the flexible liquidsoap software.
You will need
Each of the PCs should provide
Both modes require at least liquidsoap >= 1.0.0
The recorder uses live audio input from a soundcard, sends the audio stream to a local icecast server and saves the audio to file archive.
The player connects to the remote icecast stream and plays audio out to soundcard. If stream fails there a fallback to a secondary stream is used instead. If the second stream fails too, a local file will be played.
installation is basically the same for recorder and player, there are only a few differences as described below.
see here for all installation steps needed to get the latest version running.
setup log permissions to user radio
mkdir /usr/local/var/run/liquidsoap/ chown radio /usr/local/var/run/liquidsoap/ chmod 777 /usr/local/var/log/liquidsoap chmod 777 /usr/local/var/log/liquidsoap/*
setup logs to user radio
mkdir /var/log/icecast chown radio /var/log/icecast chmod 777 /var/log/icecast chmod 777 /var/log/icecast/*
add a mount to icecast configuration
vi /etc/icecast2/icecast.xml <mount> <mount-name>/radio</mount-name> <username>user</username> <password>pass</password> <max-listeners>4</max-listeners> <hidden>1</hidden> <no-yp>1</no-yp> </mount>
put set same mount, user and password settings at
/home/radio/radio/source/play/icecast.inc
To make icecast2 restart in case it fails or after power loss we define our own upstart jobs.
You can start or stop icecast2 yourself by
sudo start icecast2 sudo stop icecast2
vi /etc/init/icecast2.conf
description "icecast2" start on ( net-device-up and local-filesystems ) stop on runlevel [016] respawn exec su - radio -c "/usr/bin/icecast2 -c /etc/icecast2/icecast.xml 2>&1 >>/var/log/icecast2/error.log"
add user 'radio' to following groups
We made good experiences with MAYA ESI 44 soundcard with symmetric input/output. Other soundcards should work as well, but especially recording seems to be tricky at some cards at Ubuntu even today.
find ALSA device
aplay --list-devices
create virtual device to make sure to use alsa
vi /etc/asound.conf
pcm.liquidsoap { type plug slave { pcm "hw:0,0" } }
use this device at play.liq
output.alsa(device="pcm.liquidsoap")
download scipts and extract to /home/radio/ so there should be 2 directories: /home/radio/play and /home/radio/record.
PATCH: remove following line from /home/radio/play/output_vorbis.cbr.liq
restart=true,
add following lines to /home/radio/.profile to make some shortcuts available
alias wbox-home='echo "cd /home/radio/play";cd /home/radio/play' alias wbox-restart='wbox-home;echo "sudo ./restart.sh";sudo ./restart.sh' alias wbox-proc='wbox-home;echo "./status.h";./status.sh' alias wbox-log='wbox-home;echo "./log.pl";./log.pl' alias wbox-net='wbox-home;./net_traffic.pl' wbox-proc
To make scripts restart if they fail or after power loss we define own upstart jobs for wbox scripts. depending on your usecase use player or recorder upstart job.
You can start or stop liquidsoap yourself by
sudo start liquidsoap sudo stop liquidsoap
starts when network becomes active
vi /etc/init/liquidsoap.conf
description "liquidsoap" start on ( net-device-up and local-filesystems and runlevel [2345] ) stop on runlevel [016] respawn exec su - radio -c "liquidsoap /home/radio/play/play.liq" 2>&1 >>/var/log/liquidsoap/play.log
starts when local filesystems are mounted
vi /etc/init/liquidsoap.conf
description "liquidsoap" start on ( local-filesystems and runlevel [2345] ) stop on runlevel [016] respawn exec su - radio -c "/usr/local/bin/liquidsoap /home/radio/record/play.liq 2>&1 >>/var/log/liquidsoap/play.log"
You can connect 2 DSL routers to the system, in this case they should connect to different DSL providers. For details see http://wiki.ubuntuusers.de/Multiple_Uplink_Routing. You can enable this settings at the same system you are running the WBOX player at, but you will need a second network device for this.
sudo vim /etc/sysctl.conf kernel.panic = 3 vm.swappiness = 1
mkdir /var/log/wunderbox chmod 777 /var/log/wunderbox chown radio /var/log/wunderbox chmod 777 /var/log/wunderbox chmod 777 /var/log/wunderbox/*
/etc/logrotate.d/wunderbox
/var/log/wunderbox/*.log { compress rotate 5 size 300k missingok notifempty sharedscripts }