Oh wow, original author here. Never thought this would ever be picked up by HN after 12 years... :)
I lost the credentials for this account, so no fixes for this script. I hope it will inspire people to reverse engineer MP3, it was very interesting for back in the days.
I found some poorly documentation on the winamp website. And basically it comes down to this:
- you recode the MP3 to the lower bitrate
- get rid of all headers
- concatenate all audio into one big stream
- inject every x bytes a "StreamTitle=[title]" regardless of frames
Well, part of that is it predates Composer by a few years (and especially popular adoption of Composer). PEAR never really had the adoption that Composer did. The popularity of frameworks didn't soar until Composer was adopted by the community, either. And the overall application is actually fairly simple, assuming that getid3 folder is a third party library as it appears to be.
That said, I'm not discounting anything done here. I've had to do deep dives on streaming video before. Even built my own h264 streaming protocol prior to HLS and DASH being introduced more than a decade ago now. Figuring out the format, finding obscure documentation on the file headers, figuring out how request and send it in pieces, hell just finding documentation that long ago... it's not easy. And at least when I did it, I was working on PHP 5.4 which had namespaces. This was likely built on 5.2 if I had a guess, which lacked that luxury
Changing bitrate does not work, do you know how to change bitrate of audio file? Now it always streams the file as it is, even if I change the bitrate to 1 in the settings, it streams the file as it is.
Yeah, this is fun. I remember back in 2007 setting up a dinky audio stream for a 3 day jam session. Using php on Dreamhost, which had practically unlimited bandwidth back then. Worked great. The alternatives were either expensive livestream services or required a colocated box.
PHP is now run mainly as fcgi server. For streaming data that needs some fix on the server side so that the http server doesn't try to fetch the complete page before sending that data to client. And I am not sure how to achieve that.
This wasn't a problem 12 years back as then Apache's mod_php had been the default way to serve pages. Your http server was the PHP interpreter.
You need to disable fcgi buffering in whatever http server you're using. For exemple in nginx, the option name is "fastcgi_buffering". Then flush() and the likes will work again.
Note that if enabled you need to disable gzip compression too since that has its own buffering.
Buffering can still be accomplished php side when needed with ob_ functions.
I found some poorly documentation on the winamp website. And basically it comes down to this: - you recode the MP3 to the lower bitrate - get rid of all headers - concatenate all audio into one big stream - inject every x bytes a "StreamTitle=[title]" regardless of frames
Very simple format.