Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Function to get MP3 duration

Tags:

php

mp3

Is there any PHP function that will give me the MP3 duration. I looked at ID 3 function but i don't see any thing there for duration and apart from this,id3 is some kind of tag,which will not be there in all MP3 so using this will not make any sense.

like image 456
ram Avatar asked Aug 21 '12 10:08

ram


People also ask

How to get mp3 file duration in php?

php class MP3File { protected $filename; public function __construct($filename) { $this->filename = $filename; } public static function formatTime($duration) //as hh:mm:ss { //return sprintf("%d:%02d", $duration/60, $duration%60); $hours = floor($duration / 3600); $minutes = floor( ($duration - ($hours * 3600)) / 60); ...

How to get audio file duration in php?

php $mp3file = new MP3File("npr_304314290. mp3");//http://www.npr.org/rss/podcast.php?id=510282 $duration1 = $mp3file->getDurationEstimate();//(faster) for CBR only $duration2 = $mp3file->getDuration();//(slower) for VBR (or CBR) echo "duration: $duration1 seconds".

How can I get video duration in php without ffmpeg?

How to use the function above? ## first, define video file and location $video_file = "somedirectory/video. flv"; ## call out the function echo getDuration($video_file);


1 Answers

This should work for you, notice the getduration function: http://www.zedwood.com/article/127/php-calculate-duration-of-mp3

like image 193
Richard Askew Avatar answered Oct 09 '22 02:10

Richard Askew