Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Write icy-metadata

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
satapi



Joined: 30 Nov 2009
Posts: 2

PostPosted: Mon Nov 30, 2009 8:52 am    Post subject: Write icy-metadata Reply with quote

[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(4Cool Laughing

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
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Mon Nov 30, 2009 6:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
satapi



Joined: 30 Nov 2009
Posts: 2

PostPosted: Tue Dec 01, 2009 9:54 am    Post subject: Reply with quote

Thanks Wink , 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 Rolling Eyes
Back to top
View user's profile Send private message
alefbetac



Joined: 09 Jan 2010
Posts: 1

PostPosted: Sat Jan 09, 2010 2:32 pm    Post subject: did you get it it work Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber