简体   繁体   English

获取mp3文件的长度

[英]Get length of mp3 file

Users upload mp3 files and I need to get their length. 用户上传mp3文件,我需要获取它们的长度。 What is the least-effort way to do this in PHP? 在PHP中最省力的方法是什么? By least effort I mean whatever way requires the least amount of code and with as little non-native PHP functions as possible. 我的意思是,用最少的精力用最少的代码,用最少的非本地PHP函数。

I tried implementing the code suggested in the answer below: 我尝试实现以下答案中建议的代码:

<?PHP
$f = 'numbers/4.mp3';
$m = new mp3file($f);
$a = $m->get_metadata();

if ($a['Encoding']=='Unknown')
    echo "?";
else if ($a['Encoding']=='VBR')
    print_r($a);
else if ($a['Encoding']=='CBR')
    print_r($a);
unset($a);
?>

But I'm getting this error: 但我收到此错误:

Fatal error: Class 'mp3file' not found in /home/a1865444/public_html/save-audio.php on line 3

How do I get around this? 我该如何解决?

尝试使用此getduration函数: http ://www.zedwood.com/article/127/php-calculate-duration-of-mp3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM