php解析音频文件的时长,以Laravel为例
一、安装getid3
composer require james-heinrich/getid3
二、引用
use getID3;
use getid3_lib;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
三、代码例子
$getID3 = new getID3; $ThisFileInfo = $getID3->analyze($fileUrl); $fileduration = $ThisFileInfo['playtime_seconds']; //这个获得的便是音频文件的时长 echo $fileduration;die;
原生php下载地址: https://codeload.github.com/JamesHeinrich/getID3/zip/master