mpegaudioparse: VBR mp3 files - query position not accurate
Submitted by Hans Oesterholt
Link to original bug (#692368)
Description
Currently I'm working on support for the banshee mediaplayer for playing of audio (also vbr mp3) files using cuesheets, i.e. one large audio file with an index of the tracks. This is great for e.g. classical music or livesets.
In order to support random play or playlists, I need to seek at the right moment, to another position. This can only be done accurately, when the current position is accurately reported. This is done for CBR files, but not for VBR files.
However, it should be possible to report an accurate position in time for a VBR mp3 file using gst_element_query_position(). If the plugin knows at what frame it is in the mp3 file, it can be calculated easy, but the mp3 plugin doesn't work like that. I think it estimates the time using the current byte position in the file * the average bitrate, something like that. This works for CBR files, but not accurate for VBR files. It mostly underestimates the time passed. So songs are ended to quickly.
However. All frames in an mp3 file are 26ms in length. See http://www.mp3-converter.com/mp3codec/frames.htm
So also for a VBR file it must be possible to calculate the corrent current position, if you know the current frame that is being processed. CurrentFrameNumber*26 would be the current position in ms.