What is the simplest way to determine the length (in seconds) of a given mp3 file, without using outside libraries? (python source highly appreciated)
You might count the number of frames in the file. Each frame has a start code, although I can't recollect the exact value of the start code and I don't have MPEG specs laying around. Each frame has a certain length, around 40ms for MPEG1 layer II.
This method works for CBR-files (Constant Bit Rate), how VBR-files work is a completely different story.
From the document below:
For Layer I files us this formula:
FrameLengthInBytes = (12 * BitRate / SampleRate + Padding) * 4
For Layer II & III files use this formula:
FrameLengthInBytes = 144 * BitRate / SampleRate + Padding
Information about MPEG Audio Frame Header