Re: Find out how long an MP3 is
| From: | Andrew Elliston | Date: | Wed, 22 Nov 2000 04:05:29 +0000 |
| Subject: | Re: Find out how long an MP3 is | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-26576@lists.php.net to get a copy of this message | ||
> >I guess there's no way, at least that I know of, of finding the length of
> >the mp3 without simply playing it.
>
> There must be SOME way, because Napster, Gnutella and others list the
> length and bitrate of all the MP3 files you find in a search.
>
> I'm sure they're not playing every track on every hard drive in the world.
Actually, they list the _size_ and bitrate (among other things).
MP3 players actually estimate the length of the song. If the MP3 is encoded in CBR (constant bit
rate) format, that's a straightforward endeavor, because the entire file is composed of frames
(think of them as images on a movie reel) that are read at a steady rate (similar to 32 frames per
second, for example).
The VBR (variable bit rate) format actually threw some players for a loop before it became a
standard. Because the encoder determines the optimal rate at which frames should be read based on
the sound in that section of the song, there is no way to estimate the length of the song by reading
a frame or two of the resulting MP3 (which is what the original players did - it meant that the
"time remaining" jumped up and down as the song played, and remained an inaccurate
estimate until they took VBR MP3s into account).
I hope this made at least a little sense. It's possible that the length of the song is actually
listed within the MP3 file, but I don't think this is the case.
The earlier suggestion of 1 MB / 1 minute is a good guideline. You could even estimate the length of
the MP3 file pretty accurately by calculating it from the size and bitrate of the file.
Regards,
Andrew Elliston
------------------------------------------------
Mac Digital Audio
-- news and info for your ears
<http://www.macdigitalaudio.com>
------------------------------------------------