Network Radio With Icecast - Surfing the Stream
(Page 5 of 8 )
Streaming music to the server is handled by iceS, the source client. You may remember that you already compiled and installed this component a couple pages back -- now, all that's left is to use it. The first step in doing so is to build a playlist of tracks to be streamed to the server. This playlist is nothing but a plain text file containing absolute paths to the various audio files (OGG and MP3 files, in this case) to be streamed to the server, one per line. Here's what it might look like:
/data/audio/pop/track11.ogg
/data/audio/pop/track163.mp3
/data/audio/pop/track26.ogg
/data/audio/jazz/track126.ogg
/data/audio/jazz/track107.ogg
/data/audio/dance/track192.ogg
/data/audio/dance/track748.mp3
/data/audio/dance/track172.ogg
If you have a large collection of audio files, the quickest way to create this file is to pipe the output of ls into a text file, as below:
$ ls -1 /my/files/*.ogg > playlist.txt
Once you've got the playlist created, hand it over to iceS to begin streaming the respective files, like this:
$ /usr/local/icecast/bin/ices -h olympus.local.net -p 8000 -P abcdef -F
/tmp/playlist.txt -m 80s -n "Local OGG Stream" -g "80s Stuff" -d "Good ol'
pop, rock and jazz" -v -t http &
Logfile opened
DEBUG: Sending following information to libshout:
DEBUG: Stream: 0
DEBUG: Host: olympus.local.net:8000 (protocol: http)
DEBUG: Mount: /80s, Password: abcdef
DEBUG: Name: Local OGG Stream URL: http://www.icecast.org/
DEBUG: Genre: 80s Stuff Desc: Good ol' pop, rock and jazz
DEBUG: Bitrate: 128 Public: 1
DEBUG: Dump file: (null)
DEBUG: Initializing playlist handler...
DEBUG: Initializing builting playlist handler...
DEBUG: Builtin playlist handler serving: /tmp/track11.ogg
DEBUG: Filename cleaned up from [/tmp/track11.ogg] to [track1]
Playing /tmp/track11.ogg
Mounted on http://olympus.local.net:8000/80s
DEBUG: Delaying metadata update...
DEBUG: Updated metadata on 80s to: track1
DEBUG: Updated metadata on 80s to: track1
At this point, your audio file should be available as a stream to any interested listener. On the next page, I'll show you how to listen to what's playing...but first, a quick explanation of the various options to iceS on the command line above:
$ /usr/local/icecast/bin/ices --help
This is ices 0.3
ices <options>
Options:
-B (Background (daemon mode))
-b <stream bitrate>
-c <configfile>
-D <base directory>
-d <stream description>
-f <dumpfile on server>
-F <playlist>
-g <stream genre>
-h <host>
-i (use icy headers)
-M <interpreter module>
-m <mountpoint>
-n <stream name>
-p <port>
-P <password>
-R (activate reencoding)
-r (randomize playlist)
-s (private stream)
-S <perl|python|builtin>
-u <stream url>
-v (verbose output)
-H <reencoded sample rate>
-N <reencoded number of channels>
If you're sharp-eyed, you'll notice that my command line above includes an additional, undocumented parameter -- the -t parameter, which tells ices what protocol to use when communicating with the icecast server. For some reason, this option is missing from the help text displayed by iceS; expect this to be corrected in a future version of the application.
You can also have iceS read these values from a configuration file, instead of specifying them on the command line. Consider the following configuration file, which is equivalent to the command options above:
<?xml version="1.0"? >
<ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices">
<Playlist>
<File>/tmp/playlist.txt</File>
</Playlist>
<Execution>
<Verbose>1</Verbose>
<BaseDirectory>/tmp</BaseDirectory>
</Execution>
<Stream>
<Server>
<Hostname>olympus.local.net</Hostname>
<Port>8000</Port>
<Password>abcdef</Password>
<Protocol>http</Protocol>
</Server>
<Mountpoint>/80s</Mountpoint>
<Name>Local OGG Stream</Name>
<Genre>80s Stuff</Genre>
<Description>Good ol' pop, rock and jazz</Description>
</Stream>
</ices:Configuration>
To have iceS read values from this file instead of the command line, simply tell it where to find the file, by using the -c option, as below:
$ /usr/local/icecast/bin/ices -c /usr/local/icecast/etc/ices.conf
For more configuration options, take a look inside the sample configuration file included with the iceS distribution.
Next: Facing the Music >>
More Multimedia Articles
More By Vikram Vaswani, (c) Melonfire