mp3 file length in time

J

Jay

In python, I know there are a couple of modules for getting id3 info,
but what about the length of an mp3 file in time? Is there a way to
aquire that info? Most of my MP3s don't have id3 tags. I don't care
for them. But I need to use python to get their file lengths. How?
 
P

Paul Rubin

Jay said:
In python, I know there are a couple of modules for getting id3 info,
but what about the length of an mp3 file in time? Is there a way to
aquire that info? Most of my MP3s don't have id3 tags. I don't care
for them. But I need to use python to get their file lengths. How?

You have to count the frames. Lots of mp3 files use variable bit
rates, so you can't go by the file length.
 
T

Tim Heaney

Jay said:
Any tips on how to do that?

Just as there are modules to help you read ID3 tags, there are modules
to help you read the data. For example, MAD

http://www.underbit.com/products/mad/

can be used from Python

http://spacepants.org/src/pymad/

so that you could get the length of a track in milliseconds with
something like

import mad
print mad.MadFile("a_track.mp3").total_time()

There are other modules for other libraries as well.

I hope this helps,

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top