AWMN @ oZoNet

You are here: Home > Mirrors > Shoutcast Streaming Server Guide

Shoutcast Streaming Server Guide

[HOWTO] Shoutcast Streaming Server Guide
Major Hayden - February 14, 2005

1. Introduction & Premise

This guide explains how to set up a Shoutcast streaming music server. It covers situations when the server and transcoder are on the same machine, and when they are on different macines. The entire installation should take between 15-30 minutes at most.

The system works by taking mp3 files and feeding them into a transcoder. The transcoder in turn re-encodes the music and passes it to the server. The server receives the stream and when listeners connect, the server splits the stream so that each listener can hear the mp3's.

Schematic

Code:
/----------\ /----------\ /---------------\-----------> LISTENER
| YOUR | | TRANS- | ENCODING | SERVER | MULTIPLE
| MUSIC |------>| CODER |---------->| | STREAMS
\----------/ \----------/ \---------------/-----------> LISTENER
*** MUSIC/TRANSCODER/SERVER CAN BE ON SAME MACHINE ***


2. Requirements

      Gentoo Linux

      Working network connection

      Some MP3's (legal ones!)
:D

3. Installing/Configuring the Server

First, let's install the Shoutcast server that we will be piping our music into. We can't emerge it without first getting the file from Shoutcast's site (due to licensing/fetch restrictions). If you try, you will get an error like this:

Code:
# emerge shoutcast-server-bin
Calculating dependencies ...done!
>>> emerge (1 of 1) media-sound/shoutcast-server-bin-1.9.5 to /
!!! shoutcast-1-9-5-linux-glibc6.tar.gz not found in /usr/portage/distfiles

!!! media-sound/shoutcast-server-bin-1.9.5 has fetch restriction turned on.
!!! This probably means that this ebuild's files must be downloaded
!!! manually. See the comments in the ebuild for more information.

!!! The following are listed in SRC_URI for shoutcast-server-bin:
!!! shoutcast-1-9-5-linux-glibc6.tar.gz


So, read the license agreement and then let's get the tarball, move it to the distfiles directory, and emerge it:

Code:
# wget http://www.shoutcast.com/downloads/sc1-9-5/shoutcast-1-9-5-linux-glibc6.tar.gz
# mv shoutcast-1-9-5-linux-glibc6.tar.gz /usr/portage/distfiles/
# emerge shoutcast-server-bin


Great, now let's edit the configuration file for a moment:

Code:
# nano -w /etc/shoutcast/sc_serv.conf

# There is one line in the file you MUST CHANGE
Password=changeme

# There are a couple of other lines you might want to alter
AutoDumpUsers=0
AutoDumpSourceTime=30


The password is used when we take the transcoder and pipe in the music to the server (which we'll do in a second). AutoDumpUsers left as 0 means that we don't want users to be kicked off the stream if we accidentally cut off the stream for a period of time. Setting it to 1 means you want users kicked off the server if the stream is disconnected. AutoDumpSourceTime is the time that the server will sit without music coming from the transcoder. If you leave it at 30 seconds, then after 30 seconds of silence from the transcoder, the server will kick the stream.

4. Installing/Configuring the Transcoder

Now we've got to get the transcoder installed:

Code:
# emerge shoutcast-trans-bin


Let's edit its config file as well:

Code:
# nano -w /etc/shoutcast/sc_trans.conf

# Change the playlist line to look like this
Remember -> PlaylistFile=/opt/shoutcast/playlists/playlist.lst

# There's a few things we MUST change
ServerIP=localhost ServerIP=your.linux.box.ip.address Password=changeme shoutcast/sc_serv.conf
StreamTitle, StreamURL, Genre
# Example of my data
StreamTitle=Major's Music StreamURL=http://my.box.address Genre=Classical


There's a few other options you can edit in the file, like crossfading and your bitrate/samplerate/channel.

IMPORTANT - Remember that you need enough bandwidth to server all of your listeners. If you're working off a cable modem, you can't pipe 160kbps tracks in stereo to 50 people. :)

Also, remember the playlist file you denoted in /etc/shoutcast/sc_trans.conf.

5. Setting Up A Playlist

Now, let's create our playlist. I keep my mp3's for this server in /mp3/classical, but change this to what suits your server:

Code:
# find /mp3/classical/ -type f -name "*.mp3" > playlist.lst


Just to err on the side of caution, make sure your file names in the file have full paths, otherwise shoutcast's transcoder can't find them!

Code:
# cat playlist.lst
/mp3/classical/Heavy Classix - Wagner - The Ride of the Valkyries.mp3
/mp3/classical/Heavy Classix - Berlioz - Hungarian March.mp3
/mp3/classical/Heavy Classix - Borodin - Polovtsian Dance.mp3
/mp3/classical/Heavy Classix - Khatchaturian - Gayaneh Sabre Dance.mp3
/mp3/classical/Heavy Classix - Tchaikovsky - 1812 Overture.mp3
/mp3/classical/Heavy Classix - Berlioz - IV March of the Scaffold.mp3
/mp3/classical/Heavy Classix - Prokofiev - Montagues and Capulets.mp3
/mp3/classical/Heavy Classix - Holst - Mars The Bringer of War.mp3
/mp3/classical/Heavy Classix - Tchaikovsky - III Allegro Molto Vivace.mp3
/mp3/classical/Heavy Classix - Wagner - Lohengrin - Prelude to Act III.mp3
/mp3/classical/Heavy Classix - Mahler - IV Sturmisch Bewegt.mp3
/mp3/classical/Heavy Classix - Espana.mp3
/mp3/classical/Heavy Classix - Stravinsky - Infernal Dance.mp3


Now let's move that playlist to where the transcoder will be looking for it:

Code:
# mv playlist.lst /opt/shoutcast/playlists/playlist.lst


6. Finalizing the Installation

All that's left to do is start the server and the transcoder, and (optionally) add it to the default runtime so that it loads on boot-up:

Code:
# /etc/init.d/shoutcast start
# /etc/init.d/shoutcast_trans start
# rc-update add shoutcast default
# rc-update add shoutcast_trans default


NOTE - The init scripts are great. If you stop the server init script before stopping the transcoder script, it will stop both. By the same token, if the server isn't running and you try to start the transcoder, the server automatically starts up. Thank the smart Gentoo folks for that!

If you use IPTABLES for your firewall, make sure you adjust your rules!

Code:
// If your shoutcast server AND your iptables run on the same machine
# iptables -A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
// If your shoutcast server is behind the machine running iptables
// NOTE: Change 192.168.0.100 to the IP if your shoutcast server box
# iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 8000 -j DNAT --to 192.168.0.100:8000


Your server should be going now! Try it with XMMS or Winamp. Point them to the address for your server on port 8000, as in http://your.box.address:8000 and you should hear music. Also, open up Firefox and go to the same address and you should get a nifty web status, plus past songs.

7. Fun Stuff

If you want to see who is listening, kick/ban people, or reserve spots for certain listeners by IP, click the ADMIN link on the far right of the web status page. Use "admin" for your username and use the password from /etc/shoutcast/sc_serv.conf to login. Once you login to the page, you can tweak all kinds of stuff, and ruin someone's day if you don't want them to listen to your stuff! :wink:

What happens if you want to add new tracks to the server? What happens if you don't like the current track and want to advance to the next track? What if you want to quit shuffling the music and make it play straight through? You can!

Issue these commands (as root) from the command prompt:

Code:
// To advance to the next song
# killall -s WINCH sc_trans_linux
// After you change the playlist a little, reload it
# killall -s USR1 sc_trans_linux
// Toggle shuffle play on and off
# killall -s USR2 sc_trans_linux


KEEP IN MIND that your commands will not go into effect immediately. Due to buffering, it sometimes takes 20-30 seconds for you to hear it switch to the next track (which it will crossfade into, if you left the default crossfade in the conf).

Enjoy your new music server and get in touch with me if you have any questions about the setup.

LEGAL NOTICE: :roll:
I don't want to rain on your parade, but PLEASE UNDERSTAND that streaming YOUR music to other people is a violation of copyright law unless you have been given the right to play the music, or the music is in the public domain. You're more than welcome to stream the music for your own benefit, but please do not violate any copyright laws by using this server to broadcast music illegally. I am in no was advocating the infringement of any copyrights and I am not supporting music piracy in any form.

Also, Shoutcast is a copyright of Nullsoft. I am in no way associated with either. With that said, enjoy your music! :)


Revisions:
14-Feb-05: Initial Writing

nach oben