Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Streaming Media With Linux

by Dave Phillips
03/23/2001

Related Articles

Streaming Media With Linux (Part 2)

Creating Great Audio for the Web

Could Ogg Vorbis Replace MP3?

Linux Audio Plug-Ins: A Look Into LADSPA

Server-Side Considerations for Video Streaming

Shooting Digital Video PDA Style

The Internet is buzzing these days; more precisely, it's shouting, singing, talking, and playing its way to your desktop through the new medium of network broadcasting. New music sites such as MP3.com and Internet radio stations such as those listed at Live365 and Real.com's Real Guide bring you the latest news and music of the world, available instantly merely by selecting an interesting link in your browser.

Linux left out? No way!

What's that, did I hear you say that you'd like to enjoy surfing the network radio wires but nothing happens for you when you click on those links? That your browser remains mute and deaf to the Internet's song? Calm yourself, help is at hand. Or did you say that you'd like to set up your own network broadcasting station and add your voice to the choir, but you're overwhelmed by the apparent complexities? Relax, that is not a problem. And did I understand that you want to do these things in Linux, OS of champions? Ah, then have no fear, you've come to the right place with the right questions and the right operating system.

In this article I'll show you how to obtain, install, configure, and use the software you need to play, produce, and broadcast streaming audio in Linux, in a variety of popular formats, from X and from the console. I will present the material in two major divisions: In Part One I will describe streaming audio and suggest some minimum hardware and software requirements, then I'll present some of the most popular streaming audio formats and players. I will finish Part One with instructions for preparing the Netscape and Lynx Web browsers for streaming audio.

Part Two, which will run next week, describes how you can set up your own network broadcast server, with detailed instructions on configuring servers for RealAudio, streaming MP3s, and streaming Vorbis.

So, now it's time to begin our explorations with a definition of streaming audio and an overview of its requirements.

What's streaming audio?

Streaming audio is a subset of the more general topic of network broadcast multimedia, a subject far too broad to treat here, even focusing solely upon Linux software. Linux multimedia software has recently attained impressive sophistication: Content creators enjoy powerful media production tools such as Blender (3D audio/video, game development, animation), GIMP (general image manipulation), and Broadcast2000 (non-linear audio/video editing), all of which have their places in broadcast media production.

Regular users can find excellent media players for every Linux environment (see the Linux Music & Sound Applications site for a complete listing), including the KDE and GNOME desktops, X Window managers such as AfterStep and Window Maker, and even the unadorned console. And now Internet media broadcasters are also turning to Linux: Its famed stability and performance, open access to source code, and relative freedom from odious licensing issues (along with the system's rather low overall price tag) combine to make Linux a very attractive platform for the creation, delivery, and playback of streaming media, particularly streaming audio.

Technically, streaming audio is network-delivered audio data that is immediately or almost immediately rendered to sound upon its arrival at your local machine. The streaming data is routed directly to your soundcard's DAC (digital to analog converter), producing real-time audio output. On a properly configured system with a fast network connection, an audio stream will start playing within moments after connecting to the server (the receiving player usually cycles through a short pre-buffering phase before playback begins). Under ideal conditions, once playback starts it will continue without interruption. Depending on the connection, you may be able to stop and restart playback at will ("on-demand" streaming).

The delivery model for streaming audio follows the familiar client/server design: A broadcast server sends (streams) compressed audio over the network for reception, decompression, and real-time playback by client applications (standalone programs or browser plug-ins) running on machines connected to the network. Streaming connections are enabled by linking the client to the URL of a file or playlist of files streamed from the broadcast server; the URL is passed to the client either by specifying it at the command prompt, entering it in a dialog box, or activating a link within a web browser. Browser plug-ins will start rendering a stream automatically when you select a plug-in-enabled page.

System requirements

Whether you intend to become a network broadcaster, or you just want to enjoy cruising Internet radio stations, you will have three primary components to optimize for your system: software, hardware, and bandwidth. As you will see in this article, building and installing the software is easy enough, and powerful multimedia-capable hardware is abundant and affordable. Bandwidth then becomes the crucial final factor.

Basic software and hardware

Client-side systems need a Linux kernel properly configured for network and sound support. No other special software is needed, but you should know how to configure and use your soundcard's mixer. Aumix is a good choice: It can be used in X or at the console and is included with most Linux distributions. Servers must be configured for network support, but may not require a working sound system (it comes in handy for testing purposes though).

Connections and bandwidth

The rate (in kilobits per second) at which a sound file is converted to the MP3 format. Bit-rates of 128-Kbps approach CD-quality audio fidelity. Higher bit-rates ensure better sound quality at the expense of increased consumption of bandwidth and storage space.

Dial-up connections using 56K or less are capable of sending and receiving streaming audio; however, only a very limited number of connections will be possible, the audio quality will be compromised (severely so at baud rates lower than 56K), and constant buffering may break the flow of sound too frequently for the experience to be enjoyable. The sound quality of streaming audio is dependent on the stream's bit-rate: Higher bit-rates raise the quality of the audio stream but use up more of your network capacity, lowering the number of possible connections. High-quality streaming audio truly requires a fast digital network connection for client and server alike. And to obtain optimal performance from the software and procedures described in this article, I strongly recommend a minimum connection equal to ISDN. Preferred connections are xDSL, cable modem, or T1/T3 lines.

The test system

The system used for the following tests and examples included a 550-MHz Pentium III with 256 Mbytes of RAM, two 15-Gbyte IDE hard disks, and a Creative Labs SBLive Value soundcard. The system runs Linux kernel 2.4.0-test9 patched for low-latency, and the disks are tuned (with hdparm). The network connection is ADSL at 768 Kbps down, 128 Kbps up. Audio output runs to studio-grade monitors powered by a 100-watt QSC amplifier. These numbers are not necessarily minimum requirements, they simply indicate what I used to achieve the results presented here. As your system capabilities approach or surpass them, your mileage will vary.

Please be aware that some of these examples involve a fair amount of Linux know-how, particularly with regard to accessing CVS and other version control repositories, compiling applications from source code, and system configuration and administration. Make sure you understand the responsibilities of running as root, especially if you are on a network (you should have your network administrator's approval before you experiment with some of the material presented here), and as a matter of course back up any system files you may need to change here. Readers truly lost at sea would do well to obtain and study a good introduction to Linux such as Matt Welsh and Lar Kaufman's Running Linux or Bob Rankin's No BS Guide To Linux. More in-depth material on network administration may be found in the Linux Network Administrator's Guide by Olaf Kirch & Terry Dawson.

Common streaming audio formats and players

Uncompressed CD-quality WAV and AIFF files are too large to stream over the Internet for playback in real time. Instead, lighter-weight compressed formats such as MP3 and RealAudio are employed for streaming network audio. These formats use what are called "lossy" compression schemes, reducing file sizes by eliminating certain inaudible data from the original files without too significantly degrading playback sound quality. MP3 and RealAudio are excellent streaming formats, achieving performance factors great enough to allow real-time encoding/decoding over current network bandwidth conditions while delivering satisfying audio quality.

MP3 and RealAudio are not the only players in the network streaming audio arena. We'll also look at Macromedia's Flash and the Ogg Vorbis project from the Xiphophorus group. Since RealAudio's Internet history begins the earliest, we'll start with RealAudio.

RealAudio

In 1995, Progressive Networks (now RealNetworks) introduced RealAudio, the Internet's first widely-deployed streaming audio format. The RealAudio player (RealPlayer) was freely distributed to users who at that time were typically connected to the Internet via low-bandwidth modems; thus, the player supported connection rates as low as 14.4 Kbps, which delivered audio quality comparable to the sound of a decent AM radio. Faster connections such as ISDN accordingly improved reception speed and sound quality.

By giving away basic versions of RealPlayer and the RealProducer content-production utility, Progressive Networks seeded the market for their commercial product line and sparked an explosion in network multimedia. Today you can find an astonishing number and variety of RealAudio-enabled sites. As a curious example, I searched Google for "realaudio history", hoping to find some background material on the format; instead, I found thousands of sites dedicated to various historical topics, all of which included audio presentations requiring RealPlayer.

RealPlayer Basic tuned in to NetRadio.com.
Figure 1. RealPlayer Basic tuned in to NetRadio.com.

RealPlayer: RealAudio in X

Happily, RealPlayer is available for Linux, and you can retrieve it for free as either an RPM or tarball package from the Real.com downloads page. Installation is fairly straightforward, but there are a few snags to report. Close your web browser before installing the software, then become the root user and run the installation package. The RPM file needs to be renamed:

mv rp8_linux20_libc6_i386_cs1_rpm rp8.linux20.libc6.i386.cs1.rpm

before installing it (as root) with this command:

rpm -i rp8.linux20.libc6.i386.cs1.rpm

The tarball must have its permissions set (as root again):

chmod u+x rp8_linux20_libc6_i386_cs1.bin

Now you can run the installation package:

./rp8_linux20_libc6_i386_cs1.bin

The installation procedure will automatically set up RealPlayer as a helper application in Netscape, but be forewarned: It will also overwrite any custom settings you have for audio formats such as WAV, AIFF, and AU, so you may want to back up your Netscape preferences before installing RealPlayer. Also, the installation will not automatically update the RealAudio plug-in. Close Netscape, copy the rpnp.so file from your new $HOME/RealPlayer directory to $HOME/.netscape/plugins, fire up Netscape again, and your RealAudio plug-in should now be enabled. Check the Help/About Plugins menu item in Netscape for a status report.

TRPlayer: RealAudio for the console

At least three RealAudio players are available for the Linux console. They all depend upon an existing installation of RealPlayer and act as wrappers for RealPlayer, making its functions available to console applications. The RAP and RaWrapper players require support for the frame-buffer device; I wanted to avoid the need for any special graphics support (such as SVGA, frame-buffer, or ncurses) in my console RealAudio player, so I chose Matthew Campbell's TRPlayer.

TRPlayer is available as a binary in RPM and DEB packages, but I chose to build the latest beta version (2.0.b2) from the source tarball. TRPlayer's only unique requirement is the slang library and header. Fortunately, slang is found on most mainstream Linux distributions, and a straightforward ./configure; make should have your player ready to rock. However, due to the filesystem vagaries of Linux distributions your build may fail with this message:

main.cc:17: slang.h: No such file or directory
make: *** [main.o] Error 1

If so, change this line in main.cc:

#include <slang.h>

to this line:

#include <slang/slang.h>

and recompile.

When the build is complete, become root (su root), run make install, and you will have a new command-line RealAudio player. You can call it from the prompt at the console or in xterm, invoking it with an address linking the player to the RealAudio stream:

trplayer http://www.orientaltunes.com/realaudio/Train-288.ram

You now have streaming RealAudio at the Linux console. Cool...

Reality check

RealNetworks deserves praise for maintaining and steadily improving a freely available RealPlayer for Linux, particularly since there's no other way to enjoy all those RealAudio-empowered sites. Harder-core users and developers might be dismayed to learn that Real's software is available only in binary format and that source code is not freely available. Nevertheless, there's only one place to go for RealPlayer, so if you want it, there you go.

Now let's look at that other major streaming audio format, the notorious MP3.

MP3

By this time almost every Internet citizen knows something about the turbulent history and controversy surrounding the MP3 file format. Readers interested in the historical and technical details should consult the excellent material at MP3'Tech, but in this article we shall simply accept the MP3 as a fact of Internet life and consider its use as a commonly-employed streaming audio format.

The MP3 format has become enormously popular, rivaling RealAudio in the quality of its sound and the proliferation of MP3-powered sites. Of course, Linux can claim its fair share of encoders, decoders and players, tag writers, database managers, and other MP3 amenities. Damien Morel's excellent DAM's MP3 Page lists more than 40 Linux MP3 players available for use in X and at the console. Let's take a look at two of the most most popular players: XMMS and mpg123.

XMMS

XMMS playing a Shoutcast stream.
Figure 2: XMMS playing a Shoutcast stream.

XMMS is the X MultiMedia System. Among its many virtues, XMMS supports a plug-in architecture that lets you add such niceties as effects-processing interfaces, OpenGL spectrum analyzers, and modules for various types of input/output files (including MPEG and AVI movies). The default setup for XMMS includes support for playing a variety of audio formats, including WAV, AIFF, various types of MOD music files, and of course standalone and streaming MP3s.

RPMs and tarballs are available from the XMMS web site. Installing the RPM is easy: rpm -i xmms-latest.rpm will install the binary, the documentation, and the default plug-ins. The tarball should be unpacked in your home directory with tar xzvf xmms-latest.tar.gz. Then just follow the familiar pattern of ./configure; make and (as root) make install. That's all there is to it, you're ready to roll with XMMS.

Enter xmms at an xterm prompt. If you're new to the program you'll be pleased to find that you'll be able to change its appearance with skins, play with DSP effects in real time, and set up playlists of arbitrarily mixed media types. Unfortunately, we can't go into all the features of XMMS, we just want to know how to connect to a streaming MP3 broadcast.

There are three ways to connect XMMS to an audio stream. You can specify a network URL as a command-line option:

xmms http://linux10.cs.uaf.edu:8000/kuac64stereo

You can also select Play Location from the XMMS main menu (or use Ctrl-L at the keyboard) and enter the URL in the pop-up dialog box, or you can specify XMMS as the MIME type player

Multipurpose Internet Mail Extensions. MIME types enable the exchange of non-ASCII data such as audio and video over the Internet.

of your choice in an Internet browser for X such as Netscape or Konqueror. This last method is a great way to enjoy Internet broadcasts: Simply log on to a site such as MP3.com, click on the link to what you'd like to hear, and voilà, streaming audio while you surf the Web. Later in this article I'll guide you through the details of setting up your browser to use XMMS as a helper application, but now let's look at the premier MP3 player for the Linux console: mpg123.

mpg123

Michael Hipp's mpg123 is certainly the best-known MP3 player for the console. It is included with most mainstream Linux distributions, and rightfully so: mpg123 is still the fastest Linux decoder for standalone and streaming MP3s.

Unfortunately, some versions of mpg123 prior to 0.59s contain a bug that corrupts the URL for an audio stream, and as of Feb. 15, 2001, the properly working code is available only via the mpg123 CVS (Concurrent Versions System). Fortunately, CVS is also included with almost every major Linux distribution, and retrieving the repository code is easy. In X or at the console, run this command from your home directory:

cvs -d :pserver:guest@cvs-ti.informatik.uni-tuebingen.de:/home/hippm/cvs login

You will be prompted for a user ID and a password: Enter guest for both, then run this command to download the mpg123 CVS files:

cvs -z9 -d :pserver:guest@cvs-ti.informatik.uni-tuebingen.de:/home/hippm/cvs checkout mpg123

When the CVS files have finished transferring, log out of the remote server:

cvs -d :pserver:guest@cvs-ti.informatik.uni-tuebingen.de:/home/hippm/cvs logout

Downloading the CVS sources to your home directory will create a new $HOME/mpg123 directory. Enter that directory and read the INSTALL and README files for any late-breaking news or changes to the installation process. Building mpg123 is quite straightforward: The author has provided a simple multi-platform makefile, and you need only type make linux-help to view the Linux-specific compile-time options. I used make linux-pentium, the build was quickly done, and make install (as root, of course) put the new mpg123 into my system.

Connect mpg123 to an MP3 stream by pointing it to the stream's URL at the command prompt, just as we've done with RealPlayer and XMMS:

mpg123 http://linux10.cs.uaf.edu:8000/kuac64stereo

Mpg123 is also suitable as your browser's default helper application for playing MP3 streams in X or console mode. Configuring Netscape for mpg123 is identical to the XMMS configuration, substituting mpg123 for xmms in your MIME type definitions. And with no need for a graphic interface, mpg123 will be our natural choice when we configure the Lynx text-mode web browser later in this article.

Creating content With BladeEnc

Most of us probably get our MP3s from popular sites such as MP3.com or the various Napster services, or we rip them from our CD collections (ripping is a term for the process of lifting the audio data from a CD and converting it to WAV and/or MP3 format). Linux users are perhaps most familiar with Mike Oliphant's wonderful Grip, a front-end for a variety of CD and MP3 utilities.

Grip with CD title listing.
Figure 3: Grip with CD title listing.

Grip is pre-configured for a number of MP3 encoders, including my favorite, Tord Jansson's BladeEnc.


Figure 4: BladeEnc default configuration in Grip.

After downloading and unpacking it (with tar xzvf bladeenc-latest.tar.gz), installing BladeEnc follows the familiar routine of ./configure; make; make install. You can configure Grip to use BladeEnc as the default encoder, but the encoder is perfectly usable on its own at the command prompt. It may even be preferable to work with it that way: perhaps you've recorded some masterworks of your own as WAV files in Kai Vehmanen's great ecasound and you want to convert them to MP3s to stream over your own Internet broadcasting station. The process is simple enough, and this command :

bladeenc *.wav

will create MP3s from every WAV file found in the current directory. It really is that easy to make MP3s from your original material. BladeEnc has many other control options, but I leave their exploration to the interested reader.

The future of MP3

It may appear that MP3 has everything going for it to remain one of the most popular streaming audio formats: high-quality audio with low resource requirements, excellent streaming performance, and an enormous installed software base. However, not all the news is good: MP3 is a proprietary format patented and licensed by Fraunhofer IIS-A, a fact of some concern to many programmers of MP3 encoders. In 1997, Fraunhofer sent an order to developers of free and open-source encoders to cease and desist unless they started paying royalties. The company has also stated that it intends to charge licensing fees for broadcasting MP3s, perhaps by the end of the year. It seems that if you're looking for "...a fully open, non-proprietary, patent-and-royalty-free, general-purpose compressed audio format for high quality (44.1-48.0 kHz, 16+ bit, polyphonic) audio and music at fixed and variable bit-rates from 16 to 128 Kbps/channel," you won't get it from MP3. Perhaps you should be looking at Ogg Vorbis.

Ogg Vorbis

Ogg Vorbis: The Ogg Vorbis Codec Project

The Xiphophorus group wants to ensure that you have free access to open Internet multimedia standards. Ogg Vorbis is the group's combined "wrapper" file format (Ogg) and audio codec (Vorbis) with technical specifications equal to MP3 and RealAudio, but free of the complications imposed by the proprietary nature of those formats. The project's open-source software is licensed under the GPL, with the Vorbis libraries now under the protection of the BSD license.

Download the vorbis_nightly_cvs.tgz file from the Vorbis CVS FTP site. Create a holding directory for the package (something like $HOME/OggVorbis is good), move the package into it, then unpack it with tar xzvf vorbis_nightly_cvs.tgz. Directories will be created for the various parts of the system, including these components:

Note: Ogg Vorbis beta4 should be officially available by the time this article is published. The packages are in the same order as the CVS material, but the individual builds are handled by the familiar procedure of ./configure; make; make install. The directions given here remain valid for the current CVS versions.

You'll want to compile the code in the first four directories before compiling the plug-ins. Enter each directory and run these commands to build the software:

./autogen.sh
make
make install

You may need root privileges to install everything. Now enter the plug-ins directory and build the plug-ins you need. At this time, three plug-ins come with the Ogg Vorbis package, one each for Kmpg (a media player for KDE), RealPlayer, and Winamp (a popular media player for Windows). Installation rules and requirements vary with each plug-in, so be sure to read the notes for each plug-in you want to build.

Users of XMMS 1.2.4 will be pleased to note that a Vorbis plug-in is included in the source package for that program. You will need to configure the build for Ogg Vorbis support:

./configure --with-ogg-prefix=/usr/local/lib --with-vorbis-prefix=/usr/local/lib

Make XMMS in the usual manner, then manually install the libvorbis plug-in. Become root, copy the contents of $HOME/xmms-1.2.4/Input/vorbis/.libs to /usr/X11R6/lib/xmms/Input, and at last you can fire up XMMS with Vorbis support. Once XMMS is started, go into the Preferences menu and enable the Ogg Vorbis plug-in (Figure 5).

OggVorbis plug-in for XMMS.
Figure 5: Ogg Vorbis plug-in for XMMS.

Once the Ogg Vorbis package components are installed you can create your own Vorbis-encoded files with oggenc and play them with ogg123 (both of those tools are built and installed from the vorbis-tools subdirectory). To encode a file run this command sequence:

oggenc -o output.ogg input.wav

That sequence will produce an OGG-format file with default output values (see oggenc --help for the full list of command-line options). Here's a more complex example (with line breaks added for clarity), along with its diagnostic messages:

[dlphilp@localhost wav]$ oggenc -o /home/dlphilp/choral.ogg \
   -b 128 -c "An example OGG file" \
   -t "Choral Music" -a "King's College Choir" \
   choral.wav 

Opening with wav module: WAV file reader
Encoding "/home/dlphilp/choral.ogg" [ 99.6%] [ 0m00s remaining]

Done encoding file "/home/dlphilp/choral.ogg"

        File length:  0m 54.0s
        Elapsed time: 0m 50.9s
        Rate:         1.0621
        Average bitrate: 125.6 kb/s

where:

Note that the input argument (choral.wav) takes no flag and must appear at the end of the command sequence.

Users of Grip (described above) will be pleased to know the most recent versions include support for oggenc as one of Grip's default encoders. Open the Config/MP3 tabs, then select oggenc from the encoder list. Grip's default settings for oggenc specify the encoder's output as MP3, but those settings can be changed easily (Figure 6). Using oggenc, Grip becomes a splendid system for ripping and converting CD audio to Ogg Vorbis files.

Oggenc custom settings in Grip.
Figure 6. Oggenc custom settings in Grip.

The Ogg file format was designed with an excellent system for comments and descriptive fields similar to the ID3 tags found with many MP3 files. However, Ogg tags are more flexible and much better defined and organized than ID3. The vorbiscomment utility lists and modifies these fields:

Martin Cameron's Vocoditor simplifies editing the Vorbis comment fields, providing a handy Perl/Gtk graphic interface to vorbiscomment. You can create new comments or modify existing entries, then save the Ogg file along with the edited fields (Figure 7).

Vocoditor, a Vorbis comment fields editor.
Figure 7. Vocoditor, a Vorbis comment fields editor.

Playing a standalone Ogg file is equally easy. Here's an example using ogg123 to play the file created above with oggenc:

[dlphilp@localhost dlphilp]$ ogg123 -d oss choral.ogg 
Playing from file choral.ogg.
Unrecognized comment: 'An example OGG file'
Title: Choral Music
Artist: King's College Choir
Bitstream is 1 channel, 44100Hz
Encoded by: Xiphophorus libVorbis I 20010218
Done.

where the -d flag specifies the output device which may be null, the OSS /dev/dsp (used in the example), a WAV file written to disk, or the audio hardware on machines running Irix and Solaris.

Vorbis vs. MP3: My impressions

I ran BladeEnc and oggenc on the same WAV file to establish some performance comparisons. The input was a CD-quality WAV file (16-bit stereo with a sampling rate of 44.1 kHz) 3 minutes and 20 seconds long, and both encoders were employed with only their default values. The results were interesting:

File  Size (Mbyte) Encoding Time (minutes/seconds)
 
test.wav 35.1      -
test.mp3  3.2  2m 46.0s
test.ogg  2.7  3m 29.8s

Note that BladeEnc encoded with a fixed bit-rate of 128 Kbps, while oggenc used a variable bit-rate that defaults to 160 Kbps for stereo files. Clearly, oggenc yielded the better compression ratio, but the higher default bit-rate contributes to the longer processing time.

I do not claim that this test represents anything other than a crude comparison. Careful tuning would certainly improve performance from each encoder, but the figures do place Ogg Vorbis in a favorable light. I hold a similar conclusion from a subjective evaluation of the audio quality from the encoded files, though again I caution the reader to consider that the encoding was untuned.

In my opinion, Vorbis truly does have the potential to replace MP3 as a preferred network streaming audio file format. While bypassing the controversial or inhibiting aspects of MP3 and RealAudio, it encourages a community development effort in the domain of streaming media. Plug-ins are already available for rendering Ogg Vorbis files in media players for Windows, the Mac, and Linux/Unix platforms, and the upcoming Icecast 2.0 supports streaming audio in the Ogg format. The future is definitely looking bright for Ogg Vorbis.

Some other formats and players

Flash

Macromedia's Shockwave Flash is a compact streaming media file format playable by a browser plug-in (Netscape-only for Linux). The plug-in is available for free from Macromedia: Follow the link to download the tarball, then unpack it and place the contents in your Netscape plug-ins directory ($HOME/.netscape/plug-ins or /usr/lib/netscape/plug-ins). Restart Netscape and you're ready to experience the wonders and marvels of Flash streaming multimedia. Using the Flash player is a transparent process: If the plug-in is correctly installed all you need to do is log on to a Flash page, use the player's handy set of controls, then relax and enjoy.

Flash at Bossmonster.
Figure 8. Flash at Bossmonster.

Unfortunately I did not find any fully developed Flash authoring tools or broadcast servers for Linux, nor could I find any console Flash players; however, a search on Freshmeat located some interesting items, including Ming (a library for creating Flash content) and the Swift Tools. The Swift Tools come closest to providing a Flash content-creation suite for Linux users, but its Swift-Generator still requires templates produced by a template-generator in Windows. The Swift-MP3 file converter and the Swift-Inspector are standalone Linux applications that work with existing Flash files.

Macromedia is to be commended for supplying Linux users with the free plug-in, and Flash is capable of some incredible effects (see Marc Stricklin's eerie brittlebones and Maruto's Once Upon A Forest for some great demonstrations of streaming Flash power), and the player usually works flawlessly. However, if another player (such as XMMS or RealPlayer) is up and running, your Flash pages may remain silent until the other player is closed. Any other problems with the Linux Flash plug-in should be reported to Macromedia.

MPEG-4

MPEG-4 is a collection of standards, protocols, and tools for compressed audio and video that is attracting the attention of major manufacturers of communications devices from cell phones to synthesizers. Many electroaoustic music composers are also familiar with MPEG-4 in the form of SAOL (structured audio object language), but SAOL is only one possible implementation of the MPEG-4 standard. A complete description of MPEG-4 and SAOL is beyond the scope of this article, but this quote supplies a useful summary:

"MPEG-4 Audio Version 1 integrates the worlds of synthetic and natural coding of audio. The synthetic coding part is comprised of tools for the realization of symbolically defined music and speech. This includes MIDI and text-to-speech systems. Furthermore, tools for the 3-D localization of sound are included, allowing the creation of artificial sound environments using artificial and natural sources. MPEG-4 audio also standardizes natural audio coding at bit rates ranging from 2 Kbps up to 64 Kbps. To achieve the highest audio quality within the full range of bit rates, three types of codecs have been defined: a parametric codec for the lower bit rates in the range, a Code Excited Linear Predictive (CELP) codec for the medium bit rates in the range, and Time to Frequency (TF) codecs, including MPEG-2 AAC and Vector-Quantiser based, for the higher bit rates in the range. Furthermore, a number of functionalities are provided to facilitate a wide variety of applications which would range from intelligible speech to high quality multichannel audio." -- MPEG Audio FAQ: MPEG-4

As might be expected, streaming media quality and delivery are priority issues for the MPEG-4 designers, but there are currently no streaming MPEG-4 players or netcasters. That situation will change soon: iVAST Inc. is developing an MPEG-4-based streaming media software solution for broadband network services, and Philips Semiconductors is working on the hardware end to supply an MPEG-4 engine on a single chip (their TriMedia media processor).

MPEG-4 is certainly a very flexible and capable solution to the streaming media needs of the modern Internet. Unfortunately it's not quite ready for primetime, and it remains to be seen how it might step into the positions currently held by the MP3 format. I know that I'll keep a close watch on its development. Readers desiring more information on the MPEG-4 standards should consult the pages on the Web at Eric Scheirer's MPEG-4 Structured Audio and the Web3D sites.

Setting up web browsers for streaming audio

I must tell you that I had entirely too much fun while researching the material for this section. Internet broadcasting is a flourishing medium, as I quickly discovered, and I spent hours at work listening to newscasts from Egypt, talk shows from England and Russia, and music programs from Thailand, Turkey, and Hong Kong. Thanks to the miracle of plug-ins and helper applications, all I had to do was select interesting links and let my players do the rest. Of course, I had my web browser properly configured for receiving and playing streamng audio, and in this section I'll show you how you can do it too.

Preparing Netscape for RealAudio

The RealPlayer installation will automatically set up your Netscape preferences. As noted above, RealPlayer handles more than its proprietary RA (RealAudio), RAM (RealAudio Metafile), and RM (RealMedia) files. The installation will overwrite any custom settings in your preferences for WAV, AIFF, and AU files. However, because the player works flawlessly with those formats and provides a useful set of transport controls, I recommend keeping it as a handy multiformat audio player for Netscape.

Preparing Lynx for RealAudio

Lynx is a popular text-mode web browser included with most mainstream Linux distributions. Since its basic design ignores graphics, Lynx is lightweight and very fast, even on slower modem connections. However, the program can render certain MIME types with the appropriate helpers, and it can be configured for rendering streaming audio.

Setting up Lynx for RealAudio is a somewhat involved procedure. First you'll need to edit your $HOME/lynx.cfg file, making sure that the following lines are uncommented and edited for your system:

PERSONAL_EXTENSION_MAP:/home/dlphilp/mime.types
PERSONAL_MAILCAP:/home/dlphilp/.personal_mailcap

These two files allow you to specify new MIME types and indicate their players to Lynx.

Next you must create and edit your personal extension map and mailcap files for playing RealAudio. Your mime.types file should include these lines:

audio/realaudio         ra ram
audio/pn-realaudio      ra ram
audio/x-pn-realaudio    ra ram
audio/rn-realaudio      ra ram
audio/vnd.rn-realaudio  ra ram

and your .personal_mailcap file should include these settings :

audio/realaudio; trplayer %s
audio/pn-realaudio; trplayer %s
audio/x-pn-realaudio; trplayer %s
audio/rn-realaudio; trplayer %s
audio/vnd.rn-realaudio; trplayer %s

Now Lynx can play any RealAudio streams in the RA and RAM formats at the Linux console. However, a few caveats remain: Sites using the application/smil MIME type will not work with TRPlayer, and of course sites using the RealPlayer plug-in are also unavailable (Lynx does not support plug-ins). If you have difficulties with certain sites, comment out the mailcap entries and see how Lynx reports the MIME type for the offending page (it will display the type along with a request to download or cancel the requested file). You can try adding the new type to your mime.types file, coupling it with TRPlayer in your .personal_mailcap file, but there's no guarantee that TRPlayer will actually be able to handle the file type. Trial and error seems to be the method for figuring out how some MIME types get handled, and I ask readers to let me know if there are other types that behave well with TRPlayer.

Preparing Netscape for MP3 and Vorbis

To set up XMMS as Netscape's default streaming MP3 and Vorbis player, go to the browser's Edit menu and proceed to the Preferences > Navigator > Applications dialog box. Create the following new MIME type entries:

Description: MP3 Audio
MIMEType: audio/x-mpeg
Suffixes: mp3,mp2,mpa,abs,mpega
Application: xmms %s
 
       Description: Icecast Playlists
       MIMEType: audio/x-mpegurl
       Suffixes: m3u
       Application: xmms %s
 
       Description: Shoutcast Playlists
       MIMEType: audio/x-scpls
       Suffixes: pls
       Application: xmms %s
 
       Description: OggVorbis Audio 
       MIMEType: application/x-ogg
       Suffixes: ogg
       Application: xmms %s

These entries configure Netscape for playing single files or playlists of files at a given URL. You can now enjoy streaming audio from sites such as MP3.com or Shoutcast simply by clicking on any interesting broadcast link.

Preparing Lynx for MP3 and Vorbis

Preparing Lynx for streaming MP3s is similar to setting it up for RealAudio. Check your $HOME/lynx.cfg file and be sure to point your PERSONAL_EXTENSION_MAP and PERSONAL_MAILCAP settings to your $HOME/mime.type and $HOME/.personal_mailcap files (as described above for TRPlayer). Add these settings to your mime.types file:

audio/mpg               mp3 mp2 mpega MP3
audio/mpeg              mp3 mp2 mpega MP3
audio/x-mpeg            mp3 mp2 mpega MP3
audio/mpegurl  m3u
audio/mpeg-url  m3u
audio/x-mpegurl         m3u
audio/x-mpeg-url m3u
audio/m3u  m3u
audio/x-m3u  m3u

Now add these lines to your .personal_mailcap file:

audio/mpg;mpg123 %s
audio/mpeg;mpg123 %s
audio/x-mpeg;mpg123 %s
audio/mpegurl;mpg123 -@ %s
audio/mpeg-url;mpg123 -@ %s
audio/x-mpegurl;mpg123 -@ %s
audio/x-mpeg-url;mpg123 -@ %s
audio/m3u;mpg123 -@ %s
audio/x-m3u;mpg123 -@ %s

These settings will let you listen to M3U playlist streams and single MP3 files in Lynx at the Linux console (Shoutcast PLS playlists and Vorbis streams are not yet supported by mpg123). Incidentally, the abundance of essentially identical MIME types reflects my experience while doing research for this article. I've erred on the side of surplus; you are of course free to edit those settings to your own preferences.

Preparing Lynx for streaming Vorbis is equally straightforward. Add this line to your $HOME/mime.type file:

application/x-ogg ogg

and this one to your $HOME/.personal_mailcap file:

application/x-ogg;ogg123 -d oss %s

and you're all set. You now have Lynx configured for your listening pleasure in RealAudio, MP3, or streaming Vorbis.

This section concludes Part One of this article. In Part Two you will learn how to set up the RealServer and Icecast streaming audio servers, but for now let's take a break ... and listen to some music!

Dave Phillips maintains the Linux Music & Sound Applications Web site and has been a performing musician for more than 30 years.

Related Articles

Streaming Media With Linux (Part 2)

Creating Great Audio for the Web

Could Ogg Vorbis Replace MP3?

Linux Audio Plug-Ins: A Look Into LADSPA

Server-Side Considerations for Video Streaming

Shooting Digital Video PDA Style


Return to the Linux DevCenter.

Copyright © 2009 O'Reilly Media, Inc.