[FFmpeg-devel] [RFC] Frame accurate seeking

Reimar Döffinger Reimar.Doeffinger
Wed Dec 30 15:46:38 CET 2009

On Wed, Dec 30, 2009 at 03:08:35PM +0100, Artur Bodera wrote:
> > Also, feature requests do not belong on this list, and even for a
> > feature request this lacks an exact description of _what_ you want.
> >
> Sure, unless I provide a solution, which I did:
> http://github.com/lbrandy/ffmpeg-fas

Which doesn't seem to have anything to do with the feature you describe.

> > And no, "frame accurate seeking" without any further details certainly
> > is not a description, [...]
> There's a link in my post. That's frame accurate seeking.
> Also:
> -ss hh:mm:ss:ff   - this is frame accurate seeking.
> -skip_frames 433000    - this is frame accurate seeking
> -range 300000-1023320   - this is frame accurate seeking and partitioning

So this is about the FFmpeg program, not the libraries.
The project you linked to only provides a library interface.

> I guess about half the implementations that I
> > could suggest that match that term wouldn't be useful to you at all.
> > (in particular on is "it's already implemented, just decode the file
> > normally and drop the first n decoded frames).
> >
> How?

No idea if it is possible with FFmpeg but it should be obvious how to do
it with any program using libavcodec by changing the source code.

> The use case is described here:
> http://archives.free.net.ph/message/20091228.114853.066bc91b.en.html
> I'm looking for a way to split a stream into parts without decoding it to
> rawvideo or transcoding 2 times. I thought it would be feasible using
> gop/fps calculations, but it seems that the time seeking is a bit "jerky"
> and -vframes does not help either when you need 2 matching chunks (the
> second one needs to start where the first one ended, frame-wise, and you can
> not seek by frames = dead in the water).

Which now again has nothing at all to do with frame-accurate seeking,
since that is only possible with decoding (which ffmpeg-fas does, too,
and which you do not want to do).

> Because on the en/decoder level ffmpeg knows EXACTLY where and when
> b/i-frames occur it's much simpler to implement it there - hence the
> ffmpeg-fas project.

Either the ffmpeg-fas project has some completely hidden features that
are not mentioned anywhere or it has nothing to do with what you
described that you wanted above.
Particularly since for .mp4 file seeking is "frame accurate" as far as
possible due to missing key frames (i.e. for an all-I-frame video it
should be frame accurate).
Allowing frame-accurate when decoding IIRC should be possible by putting
the -ss behind the input file name (never tested it though, and I
suspect it could be much improved).
frame-accurate without decoding simply is not possible, the closest you
could probably get is finding a tool that tells you where the keyframes
are and then using those values with FFmpeg. I don't know of such a tool
though and it doesn't belong on this list anyway.

More information about the ffmpeg-devel mailing list