Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#3463 - 28/11/1999 11:14 Calculating MP3 time (under Linux)?
kremer
new poster

Registered: 22/11/1999
Posts: 10
Loc: Israel
Is there any tool to calculate how much playing time is contained in a particular MP3 file?

I use grip 2.7+lame 3.13 (Debian Potato) with variable bit rate and 160 bits. I suspect that the variable bit rate means that one must actually read each MP3 "packet" (whatever the MP3 terminology might be) in order to accumulate the total play time contained in it. Is this true?

In any case, I'd be very interested to know how much playing time is contained in my RIP'ed CD's so far, preferably under Linux but Lose98 will do as well.


Unit 119, 6Gb, Blue
_________________________
Unit 119, 6Gb, Blue

Top
#3464 - 28/11/1999 17:31 Re: Calculating MP3 time (under Linux)? [Re: kremer]
Verement
journeyman

Registered: 02/09/1999
Posts: 97
Loc: Boston, MA, US
The attached source code will compute the actual duration of one or more MPEG audio files. It works with any of the three standard layers (yes, MP3) at any sampling frequency and bitrate, including a variable bitrate.

To compile: gcc -O2 maduration.c -o maduration

To use: maduration [-s] file [...]
On a directory tree: find . -type f -print | xargs maduration

The hours:mins:secs displayed are rounded down to whole seconds, but full accuracy is maintained internally to compute the total. The -s flag shows only the sum total of all files.

It's not as fast as a direct computation from the file size since it reads all the audio frame headers, but it should be very accurate, especially with variable bitrate files.

I place this code under the GNU GPL. Share, modify, and enjoy.

Cheers,
-v



Top
#3465 - 21/12/1999 10:04 Re: Calculating MP3 time (under Linux)? [Re: Verement]
kremer
new poster

Registered: 22/11/1999
Posts: 10
Loc: Israel
Thanks for the code. It works great for me.
I found and fixed a small bug - it doesn't check for zero-size input files and bombs on mmap(2)
with that size. I'll mail you the patch if I had your e-mail.


Unit 119, 6Gb, Blue
_________________________
Unit 119, 6Gb, Blue

Top
#3466 - 21/12/1999 12:55 Re: Calculating MP3 time (under Linux)? [Re: kremer]
Verement
journeyman

Registered: 02/09/1999
Posts: 97
Loc: Boston, MA, US
Thanks. You could post the patch here, or mail it to me.


Top