If you want to use a higher-level language like c++
to implement a custom MP3 decoder, take a look a this question, time length of an mp3 file.
Otherwise, there are other libraries that do just what you need:
PyMad -
import madmf = mad.MadFile("foo.mp3")track_length_in_milliseconds = mf.total_time()
audio = audioread.audio_open('/path/to/mp3')print f.channels, f.samplerate, f.duration
Mutagen -
from mutagen.mp3 import MP3audio = MP3("example.mp3")print audio.info.length
There are many more, but for now you can start with these.