-
Notifications
You must be signed in to change notification settings - Fork 65
/
README
72 lines (55 loc) · 3.57 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
_______ __ __ _______
| __| |_.----..-----..---.-..--------.|__|.-----..-----. | __|.-----..----..--.--..-----..----*
|__ | _| _|| -__|| _ || || || || _ | |__ || -__|| _|| | || -__|| _|
|_______|____|__| |_____||___._||__|__|__||__||__|__||___ | |_______||_____||__| \___/ |_____||__|
|_____|
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