Sunday, September 14, 2014

Set up Media streaming server utilizing Linux, icecast2, ezstream

We can setup media streaming utilizing Linux System over your home network.
Media streaming is about broadcasting audio / video over Ethernet or WiFi

Let's see how to do it ... :-)

Prerequisites:
1. Computer with xUbuntu 14.04, 1GB RAM,
   32GB Hard Disk, WiFi / Ethernet 10/100 Mbps network
2. Decent Internet connection (512Kbps)
3. Basic knowledge of using command line, configuring servers in LINUX, Windows.

Conventions used:
## indicates comments
$ indicates Linux command prompt
> indicates windows command prompt

Step 01.00#
## Install
## 1. icecast2 - an MP3/Ogg Vorbis broadcast streaming media server
## 2. ezstream - easy media streaming client for icecast servers
## 3. mplayer - movie player
$ sudo apt-get install icecast2 ezstream mplayer

Observation: It takes ~14MB of network data to install without upgrade.

Step 02.00#
## Configure Icecast2:
## Select yes by pressing tab and enter

Step 02.01#
## Icecast2 hostname:
## Type in 'jbjs' without quotes, press enter / carriage return

Step 02.02#
## Icecast2 source password:
## Type in 'jbjs' without quotes, press enter / carriage return

Step 02.03#
## Icecast2 relay password:
## Type in 'jbjs' without quotes, press enter / carriage return

Step 02.04#
## Icecast2 administration password:
## Type in 'jbjs' without quotes, press enter / carriage return

Note: choose appropriate Host name and password(s),
      I have selected all as 'jbjs' :-)

Step 02.05#
## The icecast2 server page can be viewed in web browser at below URL:
http://127.0.0.1:8000/

## You may view that the server is active from command prompt.
$ ps aux | grep icecast

## You may discover the version of icecast installed:
$ dpkg -l | grep icecast2

Output: 
ii  icecast2        2.3.3-2ubuntu1         i386      streaming media server

Observation: we are using icecast2 version 2.3.3-2

## You can discover the version of ezstream installed:
$ dpkg -l | grep ezstream

Output:
ii  ezstream        0.5.6~dfsg-1       i386         easy media streaming client over icecast servers

Observation: We are using ezstream version 0.5.6

Step 02.06#
## If asked for login, provide
## User: admin
## Password: jbjs

Step 02.07#
## One can access the configuration file of icecast2 as super-user
$ sudo vi /etc/icecast2/icecast.xml

Note: you may use your favorite editor like gedit / nano instead of vi.

Step 03.00#
## Create directory 'Playlists' to store list of mp3 files to stream.
$ mkdir ~/Music/Playlists/

Step 03.01#
## Create file 'icecast-playlist.txt' in directory '~/Music/Playlists',
## with absolute paths of mp3 file locations.
$ find ~/Music -name *mp3 -type f > ~/Music/Playlists/icecast-playlist.txt

Step 03.02#
## Check that you have all the files required to stream.
$ vi ~/Music/Playlists/icecast-playlist.txt

Step 03.03#
## Contents of file would look like this:
/home/loginName/Music/02Madhurashtakam.mp3
/home/loginName/Music/03DasavataramGitaGovindam.mp3
/home/loginName/Music/01GanesaPancharatnam.mp3
/home/loginName/Music/04NamaRamayana.mp3
/home/loginName/Music/05HanumanChalisa.mp3

Observation: Mp3 file names can have white space.

Step 04.00#
## Create directory for 'ezstream' configuration file.
$ mkdir ~/.ezstream

Step 04.01#
## Copy 'ezstream' configuration file 'ezstream_mp3.xml' to,
## directory '~/.ezstream/'
$ cp /usr/share/doc/ezstream/examples/ezstream_mp3.xml ~/.ezstream/

Step 04.02#
## Modify 'source password', play list file name, ipaddress in the configuration
## file for ezstream.
$ vi ~/.ezstream/ezstream_mp3.xml
  <sourcepassword>jbjs</sourcepassword>
  <filename>/home/loginName/Music/Playlists/icecast-playlist.txt</filename>
  <url>http://aaa.bbb.ccc.ddd:8000/stream</url>

Note:
1. Replace aaa.bbb.ccc.ddd with ip address of your system.
2. You get ip address of your system using command: ifconfig
3. You may require a unused port number on server.

Observation:
1. Provide absolute path of the play-list file: icecast-playlist.txt
2. Default password of icecast2 is 'hackme', for this example it is 'jbjs'

Step 04.03#
## Start streaming mp3 file content
ezstream -c ~/.ezstream/ezstream_mp3.xml

## On the server that is running icecast2 or ezstream, one can view the resources consumed

Step 05.00#
## Start receiving the media stream on your system or other system in same
## network and play.
$ mplayer http://aaa.bbb.ccc.ddd:8000/stream

Step 05.01# (optional)
## On a windows system open command prompt.
## Change directory to the folder where vlc.exe is installed (for me it is Software\vlc-2.1.5-win64\vlc-2.1.5, for you it may differ, you can find it by pressing 'windows' button, type in vlc, right click on vlc.exe, click on open file location).
## Issue below command to receive media stream and play.
C:\Software\vlc-2.1.5-win64\vlc-2.1.5> vlc.exe -vvv http://aaa.bbb.ccc.ddd:8000/stream

Note: We used vlc version 2.1.5 Rincewind

Step 05.02# (optional)
## Alternatively, from vlc gui application,
## Click on 'Media'
##  => Click on 'Open Network Stream...'
##  => type in 'http://aaa.bbb.ccc.ddd:8000/stream' without quotes
##  => click on 'Play'

Step 05.03# (optional)
## Alternatively from Windows Media Player,
## Click on 'File'
## => Click on 'Open URL...'
## => type in 'http://aaa.bbb.ccc.ddd:8000/stream' without quotes
## => Click on 'Ok'

4 comments:

  1. How to broadcast live and then continue with recorded content ?

    ReplyDelete
    Replies
    1. As of now I guess Ezstream 0.5.6 did not support mixing. This may require more research, source code modification & experimentation.

      Delete
  2. Mahodaya
    How to intersperse content?
    I saw the instructions to make playlists. But once a playlist is set for next say 5 hours. How to add after that while the radio is still running ?

    ReplyDelete
    Replies
    1. I experimented by changing the content of file: '~/Music/Playlists/icecast-playlist.txt', it did NOT work. This would also require research, source code modification & experimentation. I see from ChangeLog file of 'ezstream' source that, the last update to ezstream software is on 2009-08-30.

      Delete