RE: [PHP] duration of mp3 file
| From: | Jim Moseby | Date: | Wed, 11 Jul 2007 13:54:49 +0000 |
| Subject: | RE: [PHP] duration of mp3 file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-258610@lists.php.net to get a copy of this message | ||
>
> Allow bunnies ...
>
> Any takers on this ... I JUST want the duration of the mp3
> file - with a
> small function if possible ... I honestly don't want to use a
> class like
> http://www.phpclasses.org/browse/package/112.html
>
> The coding is terrible and SERIOUSLY over inflated for what I want.
>
> Anyone know of a simple class / function ?
>
> S
>
Apparently, you can read the header of the file to find the bitrate, then
calculate the approximate play duration from that info and the filesize.
Here is information on the mp3 file format:
http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm
...and here is a discussion thread that provides the calculation and other
links:
http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.html
I've never done this, and apparently there is an issue with MP3s that have
variable bitrates, but maybe this will get you started in the right
direction.
HTH - JM <-- not anything like a bunny ;-)