[Ffmpeg-devel] question: problem by seeking and counting video frames
Fred Rothganger
fred
Tue Nov 28 15:17:14 CET 2006
cybercake wrote:
> So the question is, is there any general way or what people usually do to set up a track bar and an error-free seeking function?
>
I wrote code to seek to exact frames in MPEG files for my PhD research
(which you are welcome to if you want it). The method you describe is
generally correct. I wouldn't bother with trying to note which frames
are I-frames, or with using LOW_DELAY, hurry_up, or any frame_number
value returned by FFMPEG. (I also wouldn't bother building an index if
you video has a constant frame rate.) Basically, just seek to a
timestamp sufficiently ahead of the desired frame to catch the I-frame
before it, then decode through the frames until the one you want comes
up. I believe that the DTS of the frame you pass into the decoder is
the PTS of the picture that comes out. There is generally a few frames
of latency in the decoder. If your seek isn't sufficiently early, then
seek earlier. :) ffplay.c should have an example of basic slider-bar
style seeking, though it doesn't actually present a slider bar but
rather uses the position of the mouse pointer on the window. Also,
ffplay.c isn't written to be frame-exact like we need for research.
-- Fred
More information about the ffmpeg-devel
mailing list