如何从mp3文件中获取元数据

Web*_*net 6 php mp3

任何人都可以推荐一个好的独立类(不是PEAR的一部分)或其他方法让我从大约1,400个MP3文件中获取一些基本元数据?

xel*_*o52 11

http://getid3.sourceforge.net/

适用于ID3 v1和V2.阅读不仅仅是id3,但应该符合要求.您还可以从http://www.htmlhelpcentral.com/messageboard/showthread.php?t=12006获取以下内容.


<? 
class CMP3File { 
 var $title;var $artist;var $album;var $year;var $comment;var $genre; 
 function getid3 ($file) { 
  if (file_exists($file)) { 
   $id_start=filesize($file)-128; 
   $fp=fopen($file,"r"); 
   fseek($fp,$id_start); 
   $tag=fread($fp,3); 
   if ($tag == "TAG") { 
    $this->title=fread($fp,30); 
    $this->artist=fread($fp,30); 
    $this->album=fread($fp,30); 
    $this->year=fread($fp,4); 
    $this->comment=fread($fp,30); 
    $this->genre=fread($fp,1); 
    fclose($fp); 
    return true; 
   } else { 
    fclose($fp); 
    return false; 
   } 
  } else { return false; } 
 } 
} 
?>
Run Code Online (Sandbox Code Playgroud)

  • sourceforge上的GetID3可以工作,但比人们可能需要的要多得多.你粘贴的CMP3File类对于ID3v1非常有用,但是现在大多数mp3都使用v2或v3.这是一个使用PHP + ID3v3标签在线发布的教程(http://www.script-tutorials.com/id3-tags-reader-with-php/) - 我将它与audiojs HTML5播放列表播放器(http:/ /kolber.github.io/audiojs/)它就像一场梦. (2认同)