[MPlayer-users] Getting current track time

Loren Merritt lorenm at u.washington.edu
Sat Jul 24 06:32:21 CEST 2004


On Sat, 24 Jul 2004, Cameron McCormack wrote:

> I'm writing a program that will use mplayer as a backend for playing
> audio tracks.  I want to be able to ask mplayer how far along the track
> it has played.  There is a get_percent_pos command, but this only
> returns an integral percentage of the track length, and I want something
> more accurate (say, milliseconds).
>
> Poking around, I've noticed in demux_audio.c the demux_audio_control
> function has this line:
>
>   int audio_length = demuxer->movi_end / sh_audio->i_bps;
>
> I gather that this is just dividing the file size by the bps.  Will this
> be accurate?  For something like WAVs I can imagine it'd be ok, since
> the bps is constant throughout, but what about something like a VBR MP3?

No, it's not accurate in VBR streams. It's not possible to either seek or
calculate current position in a VBR MP3, other than by parsing the entire
stream up to the current point and counting samples.
See high_res_mp3_seek() in demux_audio.c

--Loren Merritt




More information about the MPlayer-users mailing list