Industrial-Strength Webcasting with mod_mp3

In the wake of Napster, new solutions are emerging for accessing digital music online. While most users access music through file-sharing services by downloading then playing files,
streaming MP3 technology is beginning to come into its own.

Streaming MP3 technology lets you treat MP3 files similar to the way you interact with streaming music in
formats such as Windows Media or Real Media. In other words, you can set up Net radio stations where users can choose to listen to a long stream, or even build their own streaming channel by selecting files.

This article introduces mod_mp3, a module that optimizes Apache for streaming MP3s.

Sites like Shoutcast,
Live365, and
Icecast offer ways for
independent DJs to webcast MP3s easily, and get their stations listed in each site's directories. These systems have become extremely popular -- Live365 lists more than 36,000 stations that use its site -- because they've taken what was the domain of expensive, proprietary servers like those from RealNetworks and Apple Computer's QuickTime division and put it in the hands of MP3 users mobilized by file-sharing, independent artists, and open formats.

However, the capabilities of Shoutcast and Icecast servers, and web services like Live365, are still limited and focused on only playing a static stream. Users want to be able to control their playlists, and some want to publish and syndicate content from within a webcast. Those features are beyond the domain of these online services.

MP3s meet Apache

That's where Brian Aker, a lead developer of
Slash, and
mod_mp3,
comes in. Shoutcast and Icecast have done a lot of important work by creating the protocols (Shout and ICE) that enable MP3 streaming, and that are now supported by most MP3 players. Mod_mp3 gives Apache the ability to use these protocols to stream MP3s and Ogg Vorbis files. This module also adds an XML-RPC API for requesting and controlling custom streams, playlists and RSS output -- almost instantly creating the most powerful platform for webcasting MP3s yet.

At O'Reilly Network, we plan to implement mod_mp3 and experiment with new ways to serve MP3 audio files. Have you installed mod_mp3 or used another MP3 server? Tell us what you've found, and let others know what to expect. Post your comments

What makes this module particularly alluring is the developer's focus on exposing functionality through the XML-RPC API, allowing any third-party developer to create custom front-ends. Since the mod_mp3 module's initial release a month ago, there are already several projects underway to create interfaces with Perl and PHP. Read through the mailing list and you'll find developers showing off their ability to choose songs from an HTML checklist and play them, as well as their ability to store information about local and remote MP3s in MySQL databases for high volumes of files. The list is also active with feedback from third-party developers and has already been rolled into current releases.

With mod_mp3, you can also publish information about your broadcast with an RSS 1.0 news feed, enabling you to easily syndicate your content or keep track of favorite stations. Developing the playlist window most webcast services feature is now practically effortless, as are Mozilla's My Sidebar tabs, news feeds, and Slashboxes. This isn't too surprising, coming from a developer of Slash, which now supports RSS 1.0 as well.

Couple these features with seven releases of mod_mp3 in the first month, each supporting new features, and there's a lot to be excited about.

From file-sharing to webcasting to DJ web services

Mod_mp3 sees the MP3 format through an evolution -- from the disposable, transient commodity on Napster, to a ubiquitous streaming audio and indie publishing format on Shoutcast and Live365, to the foundation of new broadcasting services previously unavailable to either the webcaster or the traditional radio producer.

To see what I mean, take a look at an early interface to
mod_mp3 called
Ampache. Here you can browse
through Scott Kveton's personal library of over 3,000 songs; order and listen to them by album or artist; and listen to playlists that can be random, preset, or customized. You can even search the songs as you would on Napster or Gnutella, and get a list of results which you can stream or enter into a new playlist.

Some of these features are offered by Launchcast, a web service where you can create a music station based on personal tastes, and BearShare, a Gnutella client that also functions as a file-sharing web server. But mod_mp3 puts full webcasting and file-sharing capability in the hands of anyone who can run Apache.

Next steps

At this point, mod_mp3 supports all the basic webcasting functions of Shoutcast, but the next level of architecture for mod_mp3 is already brewing. The mailing lists have been buzzing with ideas from developers looking into creating a much more robust directory service than YP.Shoutcast, and into P2P
"webcast clouds" of mod_mp3 servers.

A stroll through the mailing lists exposes some interesting ideas for future uses and features. Here's one from Manuel Veloso, who was thinking about micropayments and playing statistics:

"[An] interesting model for the future of radio and micropayments. Tune into a server (or search the playlists of all the servers), then build your playlist from all the servers and your client auto-connects to the source.

Then, you could download the song from the server (after a fee paid to the appropriate copyright holder of course). Then, you could aggregate the listening statistics of all the songs/servers, to get a big-ass list of 'who's listening to what.'"

Here's another from Scott Kveton, whose server I pointed to above in this article, about the control one would have to choose how others tap into your file-sharing system.

"If a client is built that just uses mod_mp3 as the back-end delivery mechanism, you wouldn't have to worry about being a Napster. I've got email from folks wanting to be able to set up "shared" servers on their internal networks and want Ampache to be able to a) search across them, and b) allow access to "trusted" hosts. This would be pretty trivial to code up ... I might just do it as a proof-of-concept."

Here's one more, from Brian Aker, the main developer of mod_mp3. He's discussing the limits of the module, and other features that should live in the interface:

"One major thing to consider is we have the ability to do things right the first time ... However, I can also assure you that mod_mp3 will not become a full-blown [Yellow Pages] service on its own. The YP service will have to be done in an external program. This is going to be something the interface folks will probably have to deal with on their own, but it will be made easy for them by the time these features are ready.

The only part we need to concern ourselves with is making the meta info available for the external program to access. The RSS has already proven to be a good outlet for meta info regarding the playlists."

Although this project is only a couple months old, its direction and ambition make it one to watch. I urge anybody interested in open-source music to spend some time with mod_mp3, and give your web server a soundtrack.