Assuming your file contains MPEG audio, there are three ways to calculate the
total playing time:
1. If the file has a constant bitrate, you can divide the file size by the
bitrate.
2. If the file has a variable bitrate and a Xing VBR header, you can multiply
the playing time of one frame (calculated from the layer and sample rate)
by the number of frames (obtained from the VBR header).
3. In any case, you can sum the playing time of every frame by scanning the
frame headers of the entire file.
At the very least you will have to decode the bitrate, layer, and/or sample
rate from at least one frame header.
Comment