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 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器