Streaming Media With Linuxby Dave Phillips
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.
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.