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

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 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line