oreilly.comSafari Books Online.Conferences.


Streaming Media With Linux, Part 2

by Dave Phillips

Network broadcasting: streaming audio with RealServer and Icecast

If you've been trying out the examples from part one, then you should have a good idea about what's already out there on the Internet radio waves. But perhaps you're thinking that you could do a much better show than anything you've heard so far -- if only you knew where to start. Well, let me show you how you can begin your career as the next famous Internet DJ with some help from RealServer and Icecast.


The complete version of RealServer (RealServer Plus) for Linux is commercially available from It's a proprietary closed source Internet broadcasting solution with a fairly hefty price tag. However, bear in mind that RealServer Plus is industrial-strength software and is certainly more than you are likely to need for desktop network broadcasting.

Thankfully, RealNetworks has provided RealServer Basic for evaluation purposes. This basic server is an excellent package for personal broadcasting, but it's not an all-in-one solution for streaming RealAudio. You'll also need the RealProducer content-creation software in order to make your RealAudio files from pre-existing sound files or prepare live netcasts in RealAudio streams. Again, Real has graciously made available a free basic version of RealProducer. We will use the free versions of both RealProducer and RealServer for our examples here.

Download RealProducer Basic (the link to the basic version is at the bottom of that page) into a temporary installations directory and unpack it with tar xzvf realproducer_8.5_linux.tar.gz. Read the README file, then run ./install to set up RealProducer Basic for your system. Once RealProducer is installed, you can start converting or creating your own content in RealAudio and RealVideo formats. We'll return to RealProducer, but now let's get a server to send our masterpieces out to the networked world.

Retrieve the basic version of the server from the RealServer download site. The software arrives in a binary installation bundle without execution permission. Run this command to make the installation binary executable:

chmod +x rs8-0-linux-libc6.bin 

Next run (as root) ./rs8-0-linux-libc6.bin, follow the instructions at the prompt, and within a few moments your RealServer Basic will be fully installed and ready to use.

Now let's create some content to stream from our new RealAudio server. You can use RealProducer to convert existing soundfiles with this simple command:

realproducer -i first.wav -o first.ra

which will create an RA file with default values for a variety of other options. Here is a more complex command sequence (with line breaks added for clarity) along with its output diagnostics:

[dlphilp@localhost outsider]$ realproducer -i 4_LPC_Studies.wav -o /home/dlphilp/4_LPC_Studies.ra \
-t 4 -a 3 -b "Four LPC Studies" -h "David L. Phillips" -c 1998 \
-q "computer treatments of speech" -n "electroacoustic computer-music" \
-g 6 -r 1 -k 1
RealProducer(r) Basic 8.5
Copyright (c) 1995-2000 RealNetworks, Inc. All rights reserved.

------> Beginning Run: Mon Feb 19 18:25:30 2001

Command line: realproducer -i 4_LPC_Studies.wav -o /home/dlphilp/4_LPC_Studies.ra \
-t 4 -a 3 -b "Four LPC Studies" -h "David L. Phillips" -c 1998 \
-q "computer treatments of speech" -n "electroacoustic computer-music" \
-g 6 -r 1 -k 1
Source: 4_LPC_Studies.wav
Output: /home/dlphilp/4_LPC_Studies.ra
Title: Four LPC Studies
Author: David L. Phillips
Copyright: 1998
Keywords: electroacoustic computer-music
Description: computer treatments of speech
Target Audience: DSL/Cable Modem
Audio Format: Stereo Music
No Video
Allow Recording:Enabled
Allow Download: Enabled
Server Type: SureStream

Merging file...

------> Ending Run: Mon Feb 19 18:30:16 2001


  • -t sets "Target Audience," i.e., intended connection rate
  • -a sets audio quality format (set here for "Stereo Music")
  • -g sets player compatibility to RealPlayer 5.0 or RealPlayer G2
  • -r toggles "Allow Recording"
  • -k toggles "Allow Download"

The output message reveals the obvious meanings of the string options; run realproducer --help for a complete list of the available command options.

Note that the encoding took five minutes, achieving a 3:1 reduction in file size for a 6.5 minute high-quality stream. RealProducer's efficiency may be subjectively evaluated by this comparison of input and output file sizes:

[dlphilp@localhost outsider]$ ls -l 4_LPC_Studies.wav
-rwxrwxr-x 1 root root 68692232 Oct 26 15:47 4_LPC_Studies.wav

[dlphilp@localhost outsider]$ ls -l ~/4_LPC_Studies.ra
-rw-r--r-- 1 dlphilp dlphilp 25349828 Feb 19 18:30 /home/dlphilp/4_LPC_Studies.ra

You can also set up RealProducer for live broadcasting in streaming RealAudio. This very simple command line does the trick:

realproducer -l 2:0

where -l indicates a live feed and n:n selects the audio capture source. RealProducer handles live input from WAV or AU soundfiles, Quicktime MOV files, and input directed to /dev/dsp. The example above uses this last method, setting input to the microphone input to your soundcard. 2:1 selects the Line In of your card, and 2:2 chooses your CD player for input.

Finally, let's assemble a list of RA files to be streamed by RealServer. Open your favorite text editor with a file named something like my_mix.smil. SMIL (Syncronized Multimedia Integration Language) files are composed in a simple mark-up language and are easy to write. Here's a basic example using the loopback adress:

    <audio src="rtsp://"/>
    <audio src="rtsp://"/>
    <audio src="rtsp://"/>
    <audio src="rtsp://"/>
    <audio src="rtsp://"/>

Note that you can symlink your RA files into the RealServer Content directory; you don't need to copy or move them.

This example simply plays the files in sequence, but SMIL allows much greater flexibility in the layout, timing, and even bandwidth choices for each audio source. Alas, we haven't the time to get further into SMIL, but readers interested in knowing more about SMIL can consult the excellent documentation in RealAdministrator. We need to keep moving, we're almost ready for our first Internet broadcast in RealAudio ...

Become root user (su root), go to your RealServer installation directory (/usr/local/realserver on my system), and verify that the installation process created the server configuration file, an XML textfile named rmserver.cfg. Accept the configuration defaults for now, and start the server with the following command:

Bin/rmserver rmserver.cfg &

A series of messages will scroll by. They are reports from various self-checks the server will make before startup, such as license verification and restrictions, the number of CPUs on the host, and a list of the media format modules loaded.

Pages: 1, 2, 3

Next Pagearrow

Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: