pperrin / php-streaming-audio Goto Github PK
View Code? Open in Web Editor NEWThis project forked from gadgetguru/php-streaming-audio
Pseudo shoutcast server
License: Other
This project forked from gadgetguru/php-streaming-audio
Pseudo shoutcast server
License: Other
_______ __ __ _______ | __| |_.----..-----..---.-..--------.|__|.-----..-----. | __|.-----..----..--.--..-----..----* |__ | _| _|| -__|| _ || || || || _ | |__ || -__|| _|| | || -__|| _| |_______|____|__| |_____||___._||__|__|__||__||__|__||___ | |_______||_____||__| \___/ |_____||__| |_____| Description =========== Autonomous pseudo streaming audio server. It supports the shoutcast protocol for mainstream players. This will output streaming mpeg for all other players. The script does not accept a single audio source, but uses lose audio files instead. It employs a trick to keep all the listeners in sync. Through a shuffled playlist with a fixed seed value, the script will always serve the same audio at the same time. The advantage is low processor usage, because the audio has not to be transcoded on the fly. Shoutcast protocol ================== The protocol is a bit of a hack. It's quite simple but there is almost no documentation on the interwebs. The protocol consists of two part: the mpeg audio and the metadata. Audio stream ------------ The stream is just a simple dump of concatenated MP3 files. To make it a bit more of a 'protocol' the header and the id3 tags are stripped of the file. So only the audiodata of a MP3 file used. The metadata ------------ Was a bit of a challege to reverse engineer. This was badly documented. The raw audio stream (without headers and id3-tags) is spliced into chuncks the size of the buffer. The size is specified in the icy-metaint variable in the http header. Then the metadata is inserted at these point in a certain format. The metadata must have this payload: StreamTitle='Artist - Song'; and has an null-character (0x00) to end the string. The string must be padded to the next 16th position. So the example has 28 character + 1 null-character. Makes: 29 characters. You'll have to append 3 extra null-characters. Setup ===== Your audio must be transcoded to MP3 in your transmission bitrate. Please normalize and trim your audio to avoid silent parts. Put the audio in the music folder. music.db -------- If the music.db is present it must be deleted after every change. This is a cache-file for the metadata of the audio. Config ====== Edit the settings in the index.php This is an example: $settings = array( "name" => "Radio Demo", //Name of your radio station. "genre" => "Classic", //Does not have to be a MP3 genre, can be anything. "url" => $_SERVER["SCRIPT_URI"], //URL to the station, this is automatic generated by PHP. "bitrate" => 96, //Bitrate in kbps of the transmission. All audio but be transcoded to this bitrate. "music_directory" => "music/", //Folder where the audio is. "database_file" => "music.db", //Cache filename of the audio metadata. "buffer_size" => 16384, //Buffersize of the icy-data, not really important. Bigger buffer is less updates of the current song name. "max_listen_time" => 14400, //Maximum listen time of a user in seconds. Set to 4 hours. "randomize_seed" => 31337 //The seed of the pseudo random playlist. Must be set to a contant otherwise the clients won't be in sync. ); Usage ===== Point your audio player to the URL where you have installed this script. Recommended players: ==================== VLC - http://www.videolan.org/vlc/ iTunes - http://www.apple.nl/itunes/ Winamp - http://www.winamp.com/ Contact ======= Name: david Domain: beople.com
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.