[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] duration of song



"Jason Coggins" <jcoggins828@xxxxxxxxxxx> wrote:
> I was wanting to use .mp3 files.

Perhaps this suits your needs:
http://py.vaults.ca/apyllo.py?i=6226313

>>> import mp3
>>> mp3.mp3info("you-spin-me-round.mp3")
{'STEREO': False, 'FREQUENCY': 44100, 'COPYRIGHT': 0L, 'MM': 3, 'LAYER':
2, 'SS' : 2, 'VERSION': 1L, 'MODE': 3L, 'BITRATE': 128}


The duration in seconds would be MM*60+SS - although, I'd be suspicious of
the reliability of the data it generates. For variable bit rate MP3 files,
it uses an average bit rate field in the header, which I suspect might not
always be there, and if it is, it may not be accurate.

It might be close enough for your needs, however.


-Dave LeCompte