Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old November 12th, 2006   #1
Stormx
Just Give Me the Beans!
 
Join Date: Oct 2005
Beans: 75
HOWTO: Stream to an internet radio server using ICY (SHOUTcast)

There are a few tools out there which stream to shoutcast servers. Most are media-player plugins, a few aren't. I've yet to find one I like except for the official, closed source TRANScast client. Its not perfect, but it works for me. There are a few bugs, but my script clears up the big ID3 one.

What this guide shows you how to do
- Setup TRANScast, a piece of software provided by nullsoft to stream MP3 music to a server
- Setup a hack, which fixes the broken ID3 support in this.
- Other nice tools

Okay, lets go!

Code:
cd ~
wget http://www.shoutcast.com/downloads/sc_trans_posix_040.tgz
Download the latest version of the software
Code:
tar -xvzf sc_trans_posix_040.tgz
Untar/ungzip the archive and extract.
Code:
mv sc_trans_040 shoutcast
Move the directory to something more meaningful
Code:
cd shoutcast
gedit sc_trans_conf
Use your favourite editor to edit the config file

Editting the config file
The config file is already pretty well annotated, but I'll go through it:

PlaylistFile
Set this to whatever you want your playlist file to be. You can make multiple files like metal.pls, indie.pls, electronica.pls, beatles.pls, whatever... Each file lists all the tracks in the playlist. Each track must be an MP3. The items are seperated by new lines. The software automatically misses out the first track, but the file has to exist, I think.

ServerIP
Doesn't actually need to be an IP. If you don't know what this is you shouldn't be reading this guide.

ServerPort
Pretty self-explanitory, usually 8000

Password
Server Password. If you have bought some shoutcast hosting you will have got this password. if you set up the server yourself, its in the config file there.

StreamTitle, StreamURL, Genre
This appears in the shoutcast directory, if you enable it. StreamTitle could be like, "Radio 0", StreamURL could be your website, and Genre can be multiple genres, comma seperated. e.g. House, Breakbeat, etc.

LogFile, Shuffle are well explained in the file itself.

BitRate, SampleRate, Channels
Explained in the guide. Remember that halving the amount of channels won't necessarily halve the data your transmitting.

Quality
This is set to 1 by default, but if you find you are getting wierd skipping then it might be worth setting it down a bit, to say, 3.

CrossfadeMode, CrossfadeLength
A good choice to have it on, but 8 seconds (default value) is a bit length. I have mine on 2 seconds (2000)

UseID3
Makes no difference.

Public
Well explained in the guide. 1 for submitting to shoutcast directory, 0 for not.

AIM, ICQ, IRC
Again, pretty obvious / well explained.

Creating a playlist
There are a few ways you can make the playlist. A good one is to use your favourite media player. Set everything up, then save the playlist as .M3U. It is basicly the same format. Then just move it to playlist.pls, or whatever you have in your config.

Another is just to manually edit the file.

Running the server
Running the server is simple:
Code:
cd ~/shoutcast
./sc_trans_linux
Be sure to do that in a terminal. Make sure everything works. Then listen to your stream for a while. Check its not lagging, and that everything is in order

Fun Hacks

Fixing ID3 support

AFAIK, ID3 support is borked in this. I wrote a small workaround, originally in BASH, and finally in PHP. The bash version was very buggy. The PHP version is nice and should work everytime, even if the code is a bit messy.

1.
Code:
sudo apt-get install php5-cli php-getid3
First, install php5-cli and php-getid3
2.
Code:
cd ~
mkdir bin
cd bin
It doesn't matter if bin already exists
3.
Code:
gedit ~/.bashrc
If it doesn't already exist, add this:
Code:
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi
4.
Code:
wget http://www.dython.net/z/hosted/stormx/shoutcast-hack-php
chmod +x shoutcast-hack-php
gedit shoutcast-hack-php
Edit the first variable, shoutcastbase. The rest should be fine.

5. Now to launch shoutcast:

Code:
cd ~/shoutcast
./sc_trans_linux | shoutcast-hack-php
Kill Switches
First, find the pid of the shoutcast server. This is given when it starts up, otherwise:
Code:
pidof sc_trans_linux
Say the PID was 1000, you could do something like

Code:
kill -CODE 1000
Where CODE can be:

HUP - flush logfiles (close and reopen) -- will make console logging stop
WINCH - jump to next song
USR1 - reload playlist off disk (will not interrupt current playing stream)
USR2 - toggle shuffle on/off
TERM - normal sc_trans shutdown (clean, same as hitting Ctrl + C)

Resizing a Terminal Window gives WINCH (I think it stands for Window Change), so best make it full screen.

Last edited by Stormx; December 20th, 2006 at 11:21 AM.. Reason: Fixed up the bashrc stuff
Stormx is offline   Reply With Quote
Old November 25th, 2006   #2
aparigraha
A Carafe of Ubuntu
 
aparigraha's Avatar
 
Join Date: Apr 2006
Location: Biosphere
Beans: 149
Kubuntu 8.04 Hardy Heron
Re: HOWTO: Stream to an internet radio server using ICY (SHOUTcast)

Thx a lot for posting this very valuable php-solution.
Got one issue that i need help with though.
When launching sc_trans with php:

Code:
cd ~/shoutcast
./sc_trans_linux | shoutcast-hack-php
I get shoutcast-hack-php Command Not Found. A bash is started and sc_trans runs as usual... ID3 still not working.

I edited the dirs "home/Barney/shoutcast" in the shoutcast-hack-php file to suit my setup in Xubuntu. Still have the "Command Not Found"-issue. Any suggestions as to where I'm going wrong, would be greatly appreciated. Could Xubuntu be the issue perhaps?

Once again. Great job!

Aparigraha
aparigraha is offline   Reply With Quote
Old June 22nd, 2009   #3
ultratux
First Cup of Ubuntu
 
Join Date: Jun 2009
Beans: 2
Re: HOWTO: Stream to an internet radio server using ICY (SHOUTcast)

Just like to share another way:

Install TunaPie via Synaptic Package Manager (easiest). It can list both Shoutcast and Icecast stations. In the preference menu, you can select the appropriate player. In my case, I use VLC.

Enjoy!
ultratux is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:17 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry