【问题标题】:How to get meta data out of mp3 files如何从 mp3 文件中获取元数据
【发布时间】:2011-06-10 05:21:26
【问题描述】:

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

【问题讨论】:

标签: php mp3


【解决方案1】:

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; } 
 } 
} 
?>

【讨论】:

  • Sourceforge 上的 GetID3 可以工作,但远远超出人们的需要。您粘贴的 CMP3File 类非常适合 ID3v1,但现在大多数 mp3 都使用 v2 或 v3。这是一个在线发布的关于使用 PHP + ID3v3 标签 (script-tutorials.com/id3-tags-reader-with-php) 的教程——我将它与 audiojs HTML5 播放列表播放器 (kolber.github.io/audiojs) 结合使用,它就像一个梦一样工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 2012-07-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多