[MPlayer-users] mpeg file seek bug!

D Richard Felker III dalias at aerifal.cx
Fri Apr 9 14:41:59 CEST 2004


On Fri, Apr 09, 2004 at 11:05:32AM +0200, Tomasz Bury wrote:
> 
> ajing wrote:
> 
> > When I play mpeg file with ?Css option, the player always seeks to a
> > wrong time position!
> >
> > For example, if I execute: mplayer ?Css 30:00 test.mpg
> >
> > The time position should seek to 30 minute, but in fact seek to wrong
> > position! 
> 
> 
> AFAIK the -ss is a quick-and-dirty solution.
> Mplayer actually uses -sb and finds the byte offset like this:
> 
> seek_byte = seek_time * bitrate
> 
> so it will always be inacurate for variable bitrate streams.
> 
> Most MPEG-2 and MPEG-4 streams are variable bitrate.
> Some encoders store average bitare in the header,
> so seeking is more or less accurate,
> but some encoders store maximum bitrate. In this case
> mplayer will always overshoot the taget position.
> 
> BTW: are there any plans to implement precise seeking,
> (demultiplexing and counting frames)?

The problem is that precide seeking in mpeg container format is O(N),
which really sucks. It means you have to read the entire file up to
the point you want to seek to in order to seek (because timestamps can
be discontinuous and nonunique). Good container formats drop this to
O(log N) (very fast) by requiring timestamps to be correct, or O(1) by
having an index.

Rich




More information about the MPlayer-users mailing list