| View previous topic :: View next topic |
| Author |
Message |
satapi
Joined: 30 Nov 2009 Posts: 2
|
Posted: Mon Nov 30, 2009 8:52 am Post subject: Write icy-metadata |
|
|
[EDIT] Work, i will post my final solution, but i need to start with 6 more bytes, and don't write ascci 0 as char, because it's h(4
Hi, sorry, it's not directly a request for icecast server, but i need help with icy metadata and i can't found much information.
I need to do a "mp3 stream with php" and i'm trying to set icy-metadata, but it seem to don't work. My winamp parse more metadata as expected (in case, part of mp3 frame).
Can you help me? Thanks
| Code: |
<?php
header('Icy-MetaData: 1');
header('Current title: Chevelle - I Get It');
header('icy-notice1: This stream requires Winamp');
header('icy-notice2: SHOUTcast Distributed Network Audio Server/Linux v1.9.5');
header('icy-name: Radio Pixstar');
header('icy-title: jflj');
header('content-type: audio/mpeg');
header('icy-metaint: 8192');
$file = './mp3_files/joedu.mp3';
$fs = filesize($file);
//Opening of the mp3 file
$fp = fopen($file,'r');
// Reading loop
while(!feof($fp)) {
echo fread($fp,8192);
echo 0; //0*16=0 bytes of metadata
}
?> |
|
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Mon Nov 30, 2009 6:29 pm Post subject: |
|
|
When icy-metaint is sent, there are always metadata blocks every N bytes (8192 in this case). Each block has to be at least 1 byte in length 1 + N*16 when N is the value in the initial byte.
karl. |
|
| Back to top |
|
 |
satapi
Joined: 30 Nov 2009 Posts: 2
|
Posted: Tue Dec 01, 2009 9:54 am Post subject: |
|
|
Thanks , that's work, i'm just trying to read more than one mp3 right now. I Will post my solution when (and if) it works  |
|
| Back to top |
|
 |
alefbetac
Joined: 09 Jan 2010 Posts: 1
|
Posted: Sat Jan 09, 2010 2:32 pm Post subject: did you get it it work |
|
|
I'm trying to do more or less the same thing and I can't get it to work. WAMP (apache and php):
In the headers section I send something like this (php):
| Code: |
header_remove();
header('ICY 200 OK');
header('icy-notice1: Icecast Mode');
header('icy-name: My station');
header('content-type: audio/mpeg');
header('icy-metaint:4096'); |
Problem/question 1: apache ignores the ICY 200 OK and writes HTTP headers, will winamp still try to read the metadata or ignore it?
Then when I stream the data, I'm trying to echo just "0" to get that right first, so that eventually I can echo actual metadata:
| Code: |
while (!feof($s)) {
echo fread($s, 4096);
//$metadata = "StreamTitle='Cool Music'";
$metadata = "0";
$metadata = string_to_ascii($metadata);
echo $metadata;
flush();
@ob_flush();
} |
Where string_to ascii is:
| Code: |
function string_to_ascii($string){
$ascii = NULL;
for ($i = 0; $i < strlen($string); $i++)
{
$ascii += ord($string[$i]);
}
return($ascii);
} |
Question 2. Is string to ASCII even necessary?
Finally, the problem is that the audio being spitted out is corrupted, the music plays but with blips and static in the intervals where the metadata (i guess) is being passed.
Any ideas workarounds/ comments welcome. |
|
| Back to top |
|
 |
|