This question already has an answer here:
I have a folder full of audio files, a mix of mostly wma, mp3, wav, but also some obscure files like DS2 and aiff, on a VPS. The folder updates every day.
I am running a php based website using apache and MYSQL.
Is there anyway I can extract or somehow display a list of the audio files along with file durations for each?
I ideally need a solution that would allow a relatively non technical person to extract the data on a daily basis. So I'm thinking of displaying the data via a php file?
</div>
To get the MP3 duration, you have to use a custom class, because PHP doesn't have a builtin function doing that, i suggest you this one MP3File: .
After that you have to get all MP3s on the folder and display the name and duration:
require_one("mp3file.class.php");
if ($handle = opendir($dir)) { // $dir = your directory path
while (false !== ($file = readdir($handle))) {
$mp3file = new MP3File($file);
$duration1 = $mp3file->getDurationEstimate();//(faster) for CBR only
$duration2 = $mp3file->getDuration();//(slower) for VBR (or CBR)
echo $file." - ". MP3File::formatTime($duration2)."
"; // $duration1 for faster perfs
}
closedir($handle);
}