[MPlayer-dev-eng] mencoder start position

The Wanderer inverseparadox at comcast.net
Sun Dec 5 00:28:11 CET 2004


D Richard Felker III wrote:

> On Sat, Dec 04, 2004 at 01:24:40PM -0500, The Wanderer wrote:
> 
>> D Richard Felker III wrote:

>>> For mpeg1/2 it's a totally different problem. The format sucks
>>> really bad, so it's impossible to do accurate seeking without
>>> being VERY SLOW (i.e. reading the whole file). For other file
>>> types the problem is mainly that you can only seek to keyframes.
>> 
>> Actually, unless my understanding is off, it should in principle be
>> possible to seek to non-keyframes in other formats if you're
>> willing to accept a trade-off in CPU time; the basic notion would
>> be to seek to the immediately preceding keyframe and then decode
>> (but not output) frames as needed to get to the requested point.
> 
> Yes of course. Go code it.. :)

That's probably beyond my skill at present, but I figure, why not give
it a shot? This probably needs to be implemented on a per-format basis,
but might be readily ported from one demuxer to another once complete.
AVI to begin with, of course, because it's still the most commonly used
and is probably as good a place to start as any. The initial steps seem
easy enough, but I figure it'll start to get complicated once I get into
decoding but not outputting frames.

In the course of looking over the code to try to figure out where to get
started, I've noticed something which seems a little odd. In
demux_avi.c, when finding a keyframe close(st) to the desired location
(lines 656 thourgh 675), the test for forward seeking is "if
(--rel_seek_frames<0)" and for backward seeking "if
(++rel_seek_frames>0)". Why less-than/greater-than? It would seem to me
that this would always result in seeking, at minimum, just one frame
farther than was actually requested; is there some reason it needs to be
this way, or would it actually make more sense to check for
rel_seek_frames [<>]= 0? Doing it that way would probably make (this
part of) the job a little easier...

-- 
       The Wanderer

Warning: Simply because I argue an issue does not mean I agree with any
side of it.

A government exists to serve its citizens, not to control them.




More information about the MPlayer-dev-eng mailing list