forked from gadgetguru/PHP-Streaming-Audio
-
Notifications
You must be signed in to change notification settings - Fork 1
Pseudo shoutcast server
License
vkynchev/PHP-Streaming-Audio
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
_____ _ _ _____ / ____| | (_) / ____| | (___ | |_ _ __ ___ __ _ _ __ ___ _ _ __ __ _ | (___ ___ _ ____ _____ _ __ \___ \| __| '__/ _ \/ _` | '_ ` _ \| | '_ \ / _` | \___ \ / _ \ '__\ \ / / _ \ '__| ____) | |_| | | __/ (_| | | | | | | | | | | (_| | ____) | __/ | \ V / __/ | |_____/ \__|_| \___|\__,_|_| |_| |_|_|_| |_|\__, | |_____/ \___|_| \_/ \___|_| __/ | |___/ 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 constant 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: Viktor Kynchev Domain: http://kynchev.eu
About
Pseudo shoutcast server
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- PHP 100.0%