Friday, December 7, 2012

Broadcast Audio Online with Icecast Darkice and ezstream


f you ever wanted to broadcast your own voice or a mp3 playlist, here’s the solution for that. When I was exploring about online broadcasting, I found two popular audio broadcastingapplications those are Shoutcast (Windows) and Icecast (Linux). In this guide I’ll setup an Icecast server in Ubuntu. The reason why I choose to Linux based setup is because I don’t want to touch any GUI to setup the whole thing. Before you start prepare the basic requirements.

System Requirements

A computer with Ubuntu 10.04 or 12.04
A decent internet connection

Installation

First install the required applications.
sudo apt-get update && sudo apt-get install icecast2 darkice ezstream
sudo apt-get install openssh-server screen (If you want to manage the server remotely)
When installing icecast2 package you’ll be asked to change the password. Don’t leave the default password. Change it to something else.

How Streaming Works

There are two type of streaming.
1. Live voice streaming (using Darkice).
2. Streaming a premade mp3 playlist (using ezstream).
  • Icecast is the broadcaster which needs to be feeded by another application.
  • Darkice will get the line-in and feed into icecast2 in mp3 format.
  • ezstream will feed the mp3 playlist into icecast.

Setting up Live Streaming

Create a directory called ‘livestream’ in your home directory
mkdir /home/irfad/livestream
Create config file and paste following code
nano /home/irfad/livestream/darkice.cfg
[general] 
duration = 0 # duration of encoding, in seconds. 0 means forever 
bufferSecs = 1 # size of internal slip buffer, in seconds 
reconnect = yes # reconnect to the server(s) if disconnected

[input] 
device = pulse 
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100 
bitsPerSample = 16 # bits per sample. try 16 
channel = 2 # channels. 1 = mono, 2 = stereo

[icecast2-0]
bitrateMode = vbr # variable bit rate (cbr for constant) 
quality = 1.0 # 1.0 is best quality 
format = mp3 bitrate = 64 # bitrate 
server = localhost # or IP 
port = 8000 # port for IceCast2 access 
password = PASSWORD # source password to the IceCast2 server 
mountPoint = live.mp3 # mount point on the IceCast2 server
Change <PASSWORD> to Icecast server password which we setup while installing icecast.
Save the config file and run the following command.
sudo darkice -c /home/irfad/livestream/darkice.cfg
Now open up your web browser and go to

Streaming a Playlist

Create directories in your home directory called ‘mp3streaming’ and ‘mp3store’
mkdir /home/irfad/mp3streaming /home/irfad/mp3store
Now copy all the mp3 files which you want to broadcast into tha mp3store directory.
Create playlist file in mp3stream directory and enter the paths of mp3 files line by line.
nano /home/irfad/mp3streaming/playlist.txt
/home/irfad/mp3store/audio1.mp3
/home/irfad/mp3store/audio2.mp3
/home/irfad/mp3store/audio3.mp3
/home/irfad/mp3store/audio4.mp3
Save the playlist and create the config file and paste the codes.
nano /home/irfad/mp3streaming/ezstream.xml
<ezstream>
<url>http://localhost:8000/myradio.mp3</url>
<sourcepassword>PASSWORD</sourcepassword> 
<format>MP3</format> 
<filename>/home/irfad/mp3streaming/playlist.txt</filename> 
<stream_once>0</stream_once> 
<svrinfoname>Geek Radio</svrinfoname> 
<svrinfourl>http://geeklk.com/</svrinfourl> 
<svrinfogenre>Dance</svrinfogenre> 
<svrinfodescription>Geek Radio Station</svrinfodescription> 
<svrinfobitrate>128</svrinfobitrate> 
<svrinfochannels>2</svrinfochannels> 
<svrinfosamplerate>44100</svrinfosamplerate> 
<!-- No advertising on a public YP directory --> 
<svrinfopublic>0</svrinfopublic> 
</ezstream>
Change the <PASSWORD> to access Icecast server.
Start streaming by typing
ezstream -c /home/irfad/mp3streaming/ezstream.xml
Now go to http://localhost:8000/myradio.mp3 in your web browser.

0 comments:

Post a Comment