Shoutcast radio

From SlackWiki
Jump to navigation Jump to search

Introduction

This tutorial is written for people who want to broadcast music to other people but don't know how. This tutorial is dealing with SHOUTCAST client and server, although there are many others. Also this tutorial is going to teach you how to make a "radio" user. So you can give other people this users password and they can broacast music too.

Getting Started

First thing to do is make an user account for radio. Let's choose user radio:

adduser radio

Put the home directory wherever you want.

Firstly, download the server and broadcasting tool.

Now comes unpacking part.. first let's unpack server:

tar zxvf shoutcast-(your version here).tar.gz
tar zxvf sc_trans_posix_(your version here).tgz

You should rename the server directory to shoutcast:

mv shoutcast-(your version here).tar.gz shoutcast

and broadcasting tools folder to sc_sender:

mv sc_trans_posix_(your version here).tgz sc_sender

This is done to make scripts work, we talk about them later. Now you should configure server and broadcasting tool as you like. There are some things you should definately do though, for the scripts.

Configuring the Broadcasting Tool

First create a playlist file:

touch sc_sender/playlist

Now configure the broadcasting tool. Let's cd to it's directory and delete some files we don't want and rename binary:

cd sc_sender
rm sc_trans_freebsd sc_trans_macosx example.lst # unneeded files
mv sc_trans_linux sender # rename for convenience

Now open sc_trans.conf in your favourite editor, and change:

  • "PlaylistFile" to "playlist"
  • "ServerIP" to "localhost"
  • "LogFile" to blank
  • Your password
  • "Shuffle" to "0"

The logfile is blanked to avoid broadcasting tool crashing. When log file grows too big, the broadcasting tool usually crashes.

There are lots of other things to edit; fortunately this file is well commented.

Configuring the Shoutcast Server

cd ../shoutcast && pico sc_serv.conf

Only thing you need here is setting password to the same password you did set broadcasting tool. Then edit 'MaxUser' to something you can handle. And then disable LogFile again.(same problem as broadcasting tool):

LogFile=

Nothing more is needed. You should edit things like 'TitleFormat' etc for making it look nice on http:/yourhost:8000 and client player.

Configuration of scripts

Now create 'bin' directory to your radio user's root dir.

mkdir bin

After that create a file '.profile' to your users root dir.

pico .profile

Add this line to that file:

export PATH=~/bin:$PATH

Character ~ stands for your homefolder, so with my user radio it's like /home/radio/ and ~/bin means /home/radio/bin/. Now if you use program 'screen' alot then you should add the same line to a file .bashrc too. Because 'screen' doesn't use .profile.

Now go to your bin directory and download scripts.

cd ~/bin/

and

wget http://www.hot.ee/sdogi/scripts.tar.gz

then unpack them and delete scripts.tar.gz

tar zxvf scripts.tar.gz

and

rm scripts.tar.gz

These scripts are all simple bash scripts. If you didn't follow my filenaming and playlist creation then you can always change filenames from those scripts. Also you could change them however you like and put a newer and better ones link up here. These are kind a outdated. Now I have created scripts that you can use from remote host. Like you write "next" and ssh connection is made to radio server to change the song with signal. It is actually easy to implement to those scripts if you are familiar with bash. Although it is possible that I will some day add my improved scripts here.

Add command

Add command works like this. You go to some folder, find some file you like, and then you write

add filename.mp3

Pretty simple eh? Anyway, if i remember correct it won't support adding multible files, if it does it's great. But what it does support is just writing add, then it adds all files from folder, also the folder name, which could screw up the playing, so you usually do like this

cd somefolder/

and

add

and then you write edit and get rid of the folder name. Edit uses pico so you just press Ctrl+K on the folder line and it removes the whole line.

Other scripts and using them all together

Now basic usage of those scripts is like this. You log to system, want to change songs... first you write 'dlist' it deletes your old playlist. Then you go and add some mp3's with add command. If just wrote add in a folder you write 'edit' after adding all the songs and you remove stuff you don't want. These could be the songs you don't want, folder names and maby even pictures or some other crap. After you have done editing you just write 'reload' to load new playlist in. After that you can again delete that playlist, it's known to broadcasting tool already.

For checking what files are in the playlist you write 'list', dohh.. for next song you write 'next' if you want to check what song is playing without going to webinterface(http://localhost:8000) you write 'radio'. Also there is a command 'shuffle' which shuffles, dohh.

Making it all run 24/7

When you are creating a dedicated Shoutcast server, you should make it come up even when program crashes or computer goes rebooting for some reason. For this i have made simple spawn scripts. You can get them here:

wget http://www.hot.ee/sdogi/spawn.tar.gz

Extract it to your users root dir. Like this:

tar zxvf spawn.tar.gz

Delete spawn.tar.gz, and again, if you didn't follow my renamings, sc_trans_linux to sender, etc then you should edit these two files. Spawn is for server and spawn2 is for broadcasting tool. you have to set exec bit on them if they don't have one. You do it like this:

chmod +x spawn spawn2

Also keep in mind that if you let some other guy to broadcast to your radio you should take exec bit off from spawn2, because it will autoconnect and rune your friends broadcast be overbroadcasting it. You do it like this:

chmod -x spawn2

And then kill your broadcasting tool. Do it like this:

killall sender

Now for the crontab part finally. Crontab is for making it to exec spawn and spawn2 every couple of minutes. You can edit crontab by writing

crontab -e

This brings up crontab file in vi. If you don't like vi you can do

export VISUAL="pico"

and use pico. Then type crontab -e. Anyway, to crontab you have to add two lines, these are:

*/10 * * * * ~/spawn &> /dev/null
*/10 * * * * ~/spawn2 &> /dev/null

This makes crontab hit spawn and spawn2 after every 10 minutes. You can make this interval larger or smaller if you want. And remember, if spawn and spawn2 don't have exec bit, they aren't ran.