mp3info and python

Brett g Porter BgPorter at NOartlogicSPAM.com
Wed Dec 5 15:36:59 EST 2001


"Dave Pawson" <DaveP at dpawson.freeserve.co.uk> wrote in message
news:Xns916EC841E89E8davePdpawsonfreeserv at 195.92.195.157...
> My need is to read the header info from an mp3 file,
> to determine its play time. (This is stuff we've encoded ourselves)
>
> Finally managed to get mp3info.py, and it appears
> to work OK, except it always shows a 00:00 length.
>
> Reading the associated documentation, I'm unsure if
> an mp3 file tells the whole tale in its header,
> or whether the blocks which make up the file actually
> sum to the total time of the whole file.
>
> Has anyone used this please, and could share
> experience?
>
> All I need is to pull the length from 50 or so files
> in sequence and add the times, nothing fancy inside
> the files.
I can't get the mp3info.tar file that's on the Vaults to expand correctly,
so I can't venture how they handle things, but I do have a lot of experience
with MP3 data.

Can you get the bit rate from mp3info? Assuming that you can, and it's a
constant bit rate file, the length in seconds is filesize / (bitrate / 8).

If there's ID3 data at the end of the file, subtract that from the filesize
before calculating.

If it's a variable bit rate file, you will need to scan through the file and
count frames, multiplying by the constant # of milliseconds per frame.






More information about the Python-list mailing list