Music Playtime

Hello everyone,

So for a project I have to know all the playtimes of all the songs. The songs are on a µSD card inserted in a Sparkfun MP3 shield + µSD.

I tried:

Reading the ID3 tag, I was unable to do this. The SFEMP3SHIELD class does not support this. Get the filesize and bitrate. And I was unable to get the bitrate.

Does anyone know how to do this? Or should I just name the files the playtime?

Thanks in advance,


I don't know exactly how to do it...

You'll have to learn how to read the MP3 headers, and possibly how to read the ID3 tag. If you can read the file byte-by-byte, you should be able to read that information (after you learn how to find and interpret the information you're looking for).

There is an ID3 TLEN field, which holds the playing time in milliseconds. But ID3 tags are optional, and you can't always trust them so if you're going to use that it's best if you check & correct it on the computer in advance.

The bitrate is in the MP3 frame headers. If it's a constant bitrate file you can get it from the 1st frame. If it's variable bitrate you have to scan all of the frames and average.

Of course, you can also get the playing time by scanning through the frames. I think the time per frame is fixed, so it might just be a matter of counting-up the frames.

And, since bitrate is kilobits per second, you can estimate playing time from bitrate and file size. But, it's not perfect because there can be ID3 tags (including album artwork) that takes-up file space without affecting playing time or bitrate. Just remember... it's kilo*bits* not kilo*bytes*, and there are 8 bits in a byte.