dongshi2588 2017-11-27 02:53
浏览 230
已采纳

getid3:从远程服务器下载完整的mp3数据

I'm using getid3 to get the file size and the time duration from a remote URL. getid3 does not work with remote URLs so the work-around is to download the mp3 to a temporary location, read the data and then delete it.

Code:

<?php $filename = tempnam('/tmp','getid3');
if (file_put_contents($filename,file_get_contents('http://feeds.soundcloud.com/stream/336401044-scott-johnson-27-tms-1314-pm.mp3', false, null, 0, 32768))) {
if (require_once('id3/getid3.php')) {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
echo '<pre>'.print_r($ThisFileInfo, true).'</pre>';
}
unlink($filename);
};?>

My problem I have is that it only downloads the first 32768kb of the mp3 file and it doesn't show the correct filesize (shows as the max 32768) or the correct time duration of the file. If I increase the max size, the code will crash.

Is there a way to download either the full mp3 or find a way to get the appropriate header size without download the full file?

  • 写回答

1条回答 默认 最新

  • doujiyan0971 2017-11-27 17:06
    关注

    ID3v1 tags are at the end of the file, not at the beginning. Therefore, you won't be able to read them until you either download a chunk of the end of the file (with range requests done with cURL), or download the entire file.

    If you want ID3v2, those will be at the beginning of the file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)