CGIcast

WTF is CGICAST?

cgicast is a selection of perl scripts which are intended to make it possible to perform live internet radio via any standard (read cheap) web hosting account which provides CGI facilities. Typically these accounts are about $5 a month compared with $15/month which you would pay to someone like live365.com to host your streams (and they still add advertising to your stream!).

Is This Legal?

I'm sure some hosts will not like it.... maybe you wanna check with them first, furthermore, the RIAA and other music industry bodies may take offence at streaming music. This code covers none of this legal stuff, just promise to be good people and don't accept payola.

How Does It Work?

There are 3 scripts - the client runs on your local machine and sends the mp3 data in chunks up to the receiver script running on the web host, this script stores the most recent audio on the filesystem. When the listener connects they connect to the transmitter script - this serves the mp3 data from these files in almost real time.

Files? Perl? Haven't you heard of sockets and shared memory?

This is a hack, but I targeted it at the lowest common denominator, I don't use any special modules of software on the server side - just whatever will probably be available. On the Client side there are a few more bells and whistles - but not many.

Bells an What?

Oh to make it work best you need to have some common unix tools - in particular SoX and "esdmon" are used for getting raw audio data. LAME is used for encoding audio to mp3, and cURL is used for pushing the data to the server (I could've done this in pure perl, but it saves about 15 lines of code). You can also encode using OGG/Vorbis if you're wanting to get the best quality with the least amount of licensing problems. Oh and one example demonstrates relaying an audio stream from an SoX

  • LAME or OggEnc
  • cURL LAME is the only one that's not commonly found in unixs distributions, because of the legal problems surrounding the mp3 patents.

    Download CGIcast and untar the distribution somewhere safe, don't untar it straight into a cgi directory on a web server, there are probably secirity problems with the client if you let just anyone run it. Take the 3 perl scripts and first setup the remote system

    Wow That Rocks! No Seriously I'm Not Being Sarcastic!

    Of course you're not.

    How Can I Ever Repay You?

    Just send thanks, adulations, and dj gigs to me ;-)

    Copyright 2002 Scott Manley