Stream data (such as music) using PHP (or another

2019-05-07 13:52发布

问题:

For years, I've been investigating how to create music streams from my computer. I've seen programs, but anything useful I've seen is Windows only (I use a Mac).

Eventually, I got interested in how streams work. Is there any way I could create my own stream, possibly using socket functions in PHP? Is there a PHP library for this?

回答1:

Take a look at Ampache. It is a Web-based Open Source Audio file manager. It is implemented with MySQL, and PHP. It allows you to view, edit, and play your audio files via the web.



回答2:

In the end it all boils down to the protocol you'd want to use. Shoutcast IMHO is plain HTTP, so to make your own stream, you just output the streams content.

To make an ogg based webradio work with my Sonos system, I have created a little transcoding wrapper around sox which is is actually written in PHP, so it may be helpful to you to serve as an example.

You'll find it here: http://www.gnegg.ch/ogg2mp3/

If you are after implementing your very own streaming protocol - maybe even UDP based, then, I'm afraid, PHP may not be the right solution for the problem - at least not as long as it has its share of problems when used for long running processes (which 5.3 may bring some help for with its integrated garbage collection)