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