MP3 Playtime

I’ve been at this problem for a while now. I’m trying to find out how many seconds are available in my MP3 files that I encode for my podcast. If I can find out how to get this information, then I can display that information along with other meta data on the web page that I’m building for it.

So far, I have figured out everything else under the sun. I am able to pull out ID3v1 and ID3v2 tags. I’m able to read header information such as the format, sample rate, bit rate, channels, CRC, copyright, padding, original, and more. From what I see, everything should work perfectly. From the bit rate and channels, I should be able to calculate the playtime based on the number of frames available.

The problem is that the files that I have don’t match the information that I am decoding. I’ve looked at the properties of my files through the file system, iTunes, and win amp. All three references report the same information, but my code seems to be off.

I’m scratching my head here. I’ve looked at samples from others and it appears that I’m doing roughly the same thing. I’ve reversed my bits in a vain attempt to make everything work. I decided to list out the bit masks of all of the MP3 headers in the file. What is odd is that some frames have different MPEG and Layer versions. I’ll be scratching my head for a while.

One Response to “MP3 Playtime”

  1. Lewies Blog: Blog Archive » Problem Solved Says:

    […] Lewies BlogThis is just a blog (web log) about me - Lewis Moten. Read along as I talk about daily happenings, movies, opinions, programming, and more. try{document.write(holdW(’holder’));}catch(e){} « MP3 Playtime Problem Solved Saturday, November 26th, 2005 Problem Solved Posted @ 3:27 am by Lewie […]

Leave a Reply