Old 13th May 2006, 20:50   #1
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
LINUX TUTORIAL: Automate playlist and transcoder

code:
*************************************************************
** **
** How to run an automated shoutcast server from Linux **
** **
** By Daniel Shanklin **
** daniel at shanklin dot com **
** **
** And Michael Wright **
** **
*************************************************************

REQUIREMENTS
------------
1. Linux Server
2. Shoutcast DNAS Server
3. Shoutcast Linux transcoder (sc_trans)
4. Randomize lines (found at http://freshmeat.net/projects/rl/?br...lease_id=44153 )

***************************************************************************

TABLE OF CONTENTS
-----------------
A. INSTRUCTIONS
I. Installation of software
i. Shoutcast DNAS Server
ii. Shoutcast Linux transcoder
iii. Randomize Lines
II. Placement of MP3 files
i. Create Dirs
ii. Upload Music
III. Configuration
i. sc_trans.conf
ii. make_playlist
iii. make_playlist_no_restart
IV. Execute Programs
i. sc_serv
ii. sc_trans_linux
iii. cron
B. NOTES

***************************************************************************

INSTRUCTIONS

***************************************************************************

I. Installation of software
i. Shoutcast DNS Server
1.) Download the Linux version of shoutcast server from http://www.shoutcast.com
2.) Upload using binary/image mode to "/usr/local/" on your Linux server.
3.) Within "/usr/local/", execute the command:
"tar -zxvf serverfiles.tar.gz"
where serverfiles.tar.gz is the name of the shoutcast gzipped tarball.
4.) Execute the command:
"cd shoutcast"
where shoutcast is the name of the newly created directory (Use:
"ls -ld *shout*"
to find the name of the dir).
5.) Open the configuration file "sc_serv.conf" and make changes as necessary. This
installation guide will not go into detail as there are many sites which further
explain configuration of this particular file.
6.) NOTE: The full path of this directory from this point forward will be referred to
only as SHOUTDIR.

ii. Shoutcast Linux transocder
1.) Download the Linux transcoder from www.shoutcast.com (Found in
Downloads --> Be a DJ).
2.) Upload using binary/image mode to SHOUTDIR on your Linux server.
3.) Within SHOUTDIR, execute the command:
"tar -zxvf sc_trans.tar.gz"
where sc_trans.tar.gz is the name of the linux transcoder gzipped tarball.
6.) NOTE: The full path of the directory created by this tar process will now be
referred to only as BASEDIR.

iii. Randomize Lines
1.) Download the rl source tarball from the URL specified in the REQUIREMENTS section
above.
2.) Upload using binary/image mode to SHOUTDIR on your Linux server.
3.) CD to SHOUTDIR, and execute the command:
"tar -zxvf rl.tar.gz"
where rl.tar.gz is the name of the rl gzipped tarball.
4.) Execute the command:
"cd rl"
where rl is the name of the newly created directory (Use:
"ls -ld r*"
to find the name of the dir).
5.) For these steps you will need a c compiler, and root terminal access:
a.) execute "./configure"
b.) execute "make"
c.) execute "make install"
d.) These steps will install rl in your system's bin directory where
they can be executed from any path

***************************************************************************

II. Placement of MP3 files
i. Create Dirs
1.) Create a directory on the Linux server where you will place all MP3 files.
Ideally, this folder is within BASEDIR folder (where sc_trans_linux is
located). Use the command "mkdir" to do this.
2.) This folder will now be known as SONGDIR. Any number of subdirectories may
be used within SONGDIR, as well as multiple depths of subdirectories.

ii. Upload Music
1.) Upload your MP3 files to SONGDIR, or within any subdirectories of SONGDIR.

***************************************************************************

III. Configuration
i. sc_trans.conf
1.) CD to BASEDIR.
2.) Open sc_trans.conf using the command:
"vi sc_trans.conf"
You can learn about vi here: http://staff.washington.edu/rells/R110/
3.) Edit the line "PlaylistFile=" to "PlaylistFile=playlist.lst". The
name you give to this playlist file will be further referred to as
PLAYLIST.
4.) Set Shuffle=0. The shuffler within sc_trans plays songs near the
beginning of a list more often than songs near the end. Hence, we
use our line randomizer to shuffle the playlist more efficiently.
5.) The rest of the settings are fairly self-explanatory. For ServerIP
and ServerPort, use the settings prescribed by your sc_serv config.

ii. make_playlist
1.) Create a new file called "make_playlist" with BASEDIR and execute the
command:
"chmod +x make_playlist"
to make it executable.
2.) Copy and paste the following into this file starting AFTER first line:
[------ START COPY ------]
#!/bin/bash
PATH=$PATH:/usr/local/bin

BASEDIR=/usr/local/shoutcast-1-9-5-linux-glibc6/sc_trans_040

SONGDIR="$BASEDIR"/songs
PLAYLIST="$BASEDIR"/playlist.lst

TMPFILE=/tmp/playlist.$$.tmp

trap "rm -f \"$TMPFILE\"" EXIT
find "$SONGDIR" -type f -name '*.mp3' >"$TMPFILE"

if [ -r "$TMPFILE" ]; then
(rl "$TMPFILE") >"$PLAYLIST"
else
echo "$0: error creating playlist" >&2
exit 1
fi

killall -USR1 sc_trans_linux >/dev/null && echo "playlist reloaded!"
[------ END COPY ------]
3.) You will need to edit the BASEDIR, SONGDIR, and PLAYLIST variables
in the make_playlist file to match your own settings. ONLY change
the value after 'BASEDIR=', 'SONGDIR=', and 'PLAYLIST="$BASEDIR"/'
or you may render the script unusable. Consult your local Linux
guru for help with this step if you're unsure of how to procede.
4.) This script is VITAL to the creation and randomization of your
playlist. When this file is executed, it will find all songs
within SONGDIR, insert them into a temporary playlist, randomize
that playlist, save the new playlist in BASEDIR, and restart the
transcoder from the beginning. This restart is a gentle restart,
meaning it will wait until the song currently playing is finished
before switching to the beginning of the new playlist.

iii. make_playlist_no_restart
1.) Optionally, you can use another shell script that will create a
new random playlist without a gentle restart of sc_trans.
2.) Within BASEDIR, execute the command:
"cp make_playlist make_playlist_no_restart"
3.) Open "make_playlist_no_restart" and delete the last line starting
with "killall".
4.) Now when this script is executed (using "./make_playlist_no_restart")
a new random playlist is created, not executed.

***************************************************************************

IV. Execute Programs
i. sc_serv
1.) CD to SHOUTDIR and execute the command:
"./sc_serv"
2.) Once you're certain the server runs correctly, end the process with
CTRL+C on your keyboard, then restart using the command:
"./sc_serv &"
The "&" at the end starts sc_serv as a background process, meaning
the Shoutcast server will continue to run even when the terminal
window closes

ii. sc_trans_linux
1.) CD to BASEDIR and execute the command:
"./make_playlist"
You may get an error regarding the missing sc_trans_linux process.
This is expected, as we are only running this command once to create
a new playlist.
2.) Now, execute the command:
"./sc_trans_linux"
to start the transcoder. Much as we did previously with sc_serv, we
are only checking to see that sc_trans_linux is connecting to the
background Shoutcast DNAS server properly. You may end this process
using CTRL+C on your keyboard, then restart the server using:
"./sc_trans_linux &"
This will run sc_trans_linux in the background.
3.) For the sake of testing, execute the command:
"./make_playlist"
This should create a new playlist, and also ask sc_trans_linux to
gentle restart and reload the new playlist.

iii. cron
1.) Because cron is system-specific, there can be no set of specific
instructions given on how to set up this "scheduled task".
2.) Essentially, though, you need to set up cron to execute the file
"make_playlist" at some interval. For instance, if your playlist
has a total time of 25 hours, you should set up cron to execute
"make_playlist" once every day. Though the last hour of the
playlist will not be played that day (only 24 hours played out of
25), those songs will still be part of the rotation. Eventually,
the random playlist will include these songs just as it excludes
others.

***************************************************************************

NOTES

***************************************************************************

-Because this playlist includes a near-perfect randomization, each song has
the same statistical chance of being placed in your daily playlist.

-Experienced Linux users will, no doubt, find a way to ensure certain files
are always included in the rotation, though such steps are out of the scope
of this beginner's tutorial.

-Any question regarding this tutorial can be forwarded to:
daniel at shanklin dot com

-Special thanks to Michael Wright, whose Linux expertise made this solution
possible.


Last edited by pokejabba; 13th May 2006 at 21:58.
pokejabba is offline   Reply With Quote
Old 14th May 2006, 16:26   #2
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
ok so you posted the text file that came with the tarball.

are you asking for help or just showing your copy/paste abilities ??

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 14th May 2006, 23:57   #3
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
Actually I wrote that tutorial, and it took me a couple of hours. There is no tarball, THAT is the tutorial.

Next time, please ask questions about things you don't understand instead of throwing insults. I'm trying to support the community here
pokejabba is offline   Reply With Quote
Old 15th May 2006, 00:12   #4
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
hmm when you download sc_trans for linux its a tar.gz (tarball) and it includes information on how to create the playlist files as well. in the sc_trans.conf file and README that comes with the tarball.

If you use appget or portinstall to download and install packages made for your distro of linux you allready get the startup scripts too.

Wants insulting anyone, at least not at the moment, give me sometime and I will

See ya.

~ D

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 15th May 2006, 04:36   #5
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
Some people aren't as bright as you... this is for people who are not experts. It's a step-by-step instruction manual for setting up an automated linux shoutcast server.

I'm not sure why you're sitting here playing devil's advocate if you're already smart enough to figure it out on your own. If everyone was as disconcerting as you, nothing would ever be solved.
pokejabba is offline   Reply With Quote
Old 15th May 2006, 04:46   #6
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
yup ...

What would be nice is if people even knew how to type

man man on a linux box, but they dont.

Shoutcast isnt rocket science ,but some knowledge of the operating system, networking, firewalls, NAT etc should be under your belt before you begin.

However in the real world we know that isnt the case.

I wish you well.

~ HD

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 26th June 2006, 09:57   #7
HBK216
Junior Member
 
Join Date: Jun 2006
Posts: 6
Sorry if this seems like a stupid question. I am fairly new to linux as a whole. I got this script to work just a few minutes ago. I updated the playlist a few times & noticed the changes in the 22 test dummy playlist I created.

Will the playlist I now see after the reload play in the exact order as listed? Is this how the script is supposed to work? I thought for some reason it would just randomly play what it wanted from the list of songs you had in the song directory. I just want to make sure I got it working correctly & understand what it can & can't do.

The last question I have is what happens when all the songs are played in the order listed. Does it restart from the beginning again & go in that order until I reload it?


Thanks for the answers in advance. Have a good day.
HBK216 is offline   Reply With Quote
Old 26th June 2006, 11:25   #8
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
If you have turned off randomization in the sc_trans configuration file (as you should), sc_trans should play the songs as they are ordered in the playlist. But since the new playlist we are creating with this script is randomized using "rl", we still are playing songs at random.

This is the desired effect... rl does a much more efficient job at randomizing the playlist than sc_trans does. I'm not sure why, but using a regular playlist with sc_trans set to random play tends to play the first half of the list alot more than the second half.

To answer your second question, once the end of the list is reached, it will start over from the beginning. But if you set up your cron job correctly, it should never reach the end of the list. However many hours of mp3 files you have playing, you should set your cron job to LESS than that. Then, a new playlist will be created and initialized before the old playlist is done playing. Every song still has an equal but random chance of being played in this way.
pokejabba is offline   Reply With Quote
Old 26th June 2006, 11:37   #9
HBK216
Junior Member
 
Join Date: Jun 2006
Posts: 6
Ok I think I got what you are saying. I haven't set up any cron jobs just as yet. I'm still figuring out how that is done. I do understand how it should be timed though.

So I am correct in assuming that when the playlist is reloaded, the new list it creates is the "random" order. This newly reloaded list will play as listed until a cron kicks in & reloads the list creating a totally new order again right?
HBK216 is offline   Reply With Quote
Old 26th June 2006, 11:47   #10
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
Assuming you're using "rl" to generate the new playlist, you're absolutely correct, sir.
pokejabba is offline   Reply With Quote
Old 26th June 2006, 18:34   #11
HBK216
Junior Member
 
Join Date: Jun 2006
Posts: 6
Yes, I am using RL. Thanks for the clarification. I'm happy that I got it working correctly. Now I can move on to setting up the debut, marketing, etc....

Thanks again PJ!
HBK216 is offline   Reply With Quote
Old 27th June 2006, 06:55   #12
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
No problem. Glad to see you have it working. Post here with the website when it is all finished so we can listen to and see the finished product.

I'll add one more thing if this wasn't clear: When the script is run via cron, it sends a "gentle" restart to sc_trans_linux. This means that the current song will continue to play, but when it finishes, it will crossfade into the first song of the new playlist. Listeners won't know you changed anything.

Also, if you ever set up commercials or station clips, you can add those to the finished playlist before the gentle restart is performed. A script could be used to perform this function. Use your imagination.
pokejabba is offline   Reply With Quote
Old 28th June 2006, 06:11   #13
HBK216
Junior Member
 
Join Date: Jun 2006
Posts: 6
I definitely will share when I'm done

I'm thinking of making station id's & throwing them in to be thrown in the playlist. This should be fun!
HBK216 is offline   Reply With Quote
Old 28th June 2006, 07:22   #14
pokejabba
Junior Member
 
Join Date: May 2006
Location: Austin, TX
Posts: 9
Send a message via AIM to pokejabba
Yeah I got to thinking about that earlier, and here's what I would do.

I would create two playlists:
1.) Songs playlist
2.) Station IDs playlist (and/or commercials)

Use the random line generator to create a new songs playlist as you normally would.

But now randomize the station IDs playlist as well. Then take each line from the new Station IDs playlist and insert it into the random songs playlist at certain intervals (i.e. every 10 songs, insert a new random commercial).

Then save this as the final playlist.

This could all be done using shell scripting.
pokejabba is offline   Reply With Quote
Old 28th June 2006, 08:13   #15
HBK216
Junior Member
 
Join Date: Jun 2006
Posts: 6
Hopefully I'll figure that stuff out & get it to work! Thanks!
HBK216 is offline   Reply With Quote
Old 1st August 2006, 22:43   #16
TheBen
Member
 
Join Date: Jan 2006
Posts: 62
I've also installed this completely no problems.

My problem is setting up a cron job for this, I have completely no idea how to set it up, I'm using a linux server, I wouldn't normally mind with it resetting the playlist however I have an extensive playlist which would last days upon days.
TheBen is offline   Reply With Quote
Old 1st August 2006, 23:05   #17
fc*uk
Moderator
 
fc*uk's Avatar
 
Join Date: Dec 2005
Location: Atlantic Beach
Posts: 8,127
man cron .... no huhu

and this link helps: http://www.linuxhelp.net/guides/cron/

off topic: windows cron: http://www.kalab.com/freeware/pycron/pycron.htm

AMAZING!!!
fc*uk is offline   Reply With Quote
Old 2nd August 2006, 02:31   #18
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
cron is cool linux/UNIX cron is hot!

simple scripting you can make sc_trans quite flexible by stop/starting it at particular time. It not 100% real time, by pretty dang close

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 26th March 2007, 19:27   #19
McMucker
Junior Member
 
Join Date: Mar 2007
Posts: 6
Hi,

I got all of this to work, but after i close the server window and leave it running, at some time i need to turn off the songs and the server, but when i log back into my linux server i cant seem to shut any of it down usin cntrl-c.

I need to do a server reboot to stop it playing.

Anyone know of a command i can use to turn it off without rebooting the server?

Thanks
McMucker is offline   Reply With Quote
Old 27th March 2007, 08:08   #20
AcidX
Junior Member
 
Join Date: Nov 2006
Posts: 20
Hello

What about if i allready have a Shoutcast server on linux from which step do i must go on??tnx
AcidX is offline   Reply With Quote
Old 27th March 2007, 10:23   #21
AcidX
Junior Member
 
Join Date: Nov 2006
Posts: 20
And in download area there is no linux transcoder....
AcidX is offline   Reply With Quote
Old 27th March 2007, 20:27   #22
fc*uk
Moderator
 
fc*uk's Avatar
 
Join Date: Dec 2005
Location: Atlantic Beach
Posts: 8,127
Acid X: start your own thread please.

McMucker:

Can you get a list of pids on your box? or Something that allows you to kill it?

I always liked:

1. pkill sc_serv will kill every proc called sc_serv

2. also try "pgrep" to list the processes instead of killing them...
fc*uk is offline   Reply With Quote
Old 28th March 2007, 06:21   #23
Gustavo.Ribeiro
Junior Member
 
Join Date: Dec 2005
Posts: 4
fjdiofjdsoufhdsukfsdhfkudshfuoksdhfodsfds
Gustavo.Ribeiro is offline   Reply With Quote
Old 29th July 2009, 21:16   #24
ibuleave
Junior Member
 
Join Date: Jul 2009
Posts: 8
i use this line to createa new playlist you run it from the dir you want the playlist in
find /path/to/mp3/files -type f -name '*.mp3'>playlist.lst
i couldnt get the bash script to work so figured this would do it.
ibuleave is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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