I'm working on mp3 player using java by reading the file, decoding frames and playback audio. However, I want to support my app with seeking. For CBR its easy because I can approximately calculate how much bytes I should skip. For example: seeking 50s with 128 kbps it's approximately (50/0.026)*417
. But that doesn't work with VBR because bitrate is not constant.
Is there any way or method to calculate how many bytes I should skip in VBR without decoding all the frames in the way?
I solved my problem by calculating the average bitrate for VBR files. That can be done by dividing the file length in bits on the song duration. avg = size*8/duration
then seek as CBR but with calculating the frame size with the average bitrate instead of constant bitrate.