[Ffmpeg-devel] Trouble with av_seek_frame() and av_read_frame()
Devin Lane
lists
Thu May 4 07:57:33 CEST 2006
ffmpeg-devel:
I'm having some trouble using av_seek_frame(). I want to use it to
seek both forwards and backwards, both by frame and keyframe.
Right now, my strategy is to seek to a position ahead of my current
one, flush the codec buffers, then read the next frame using
av_read_frame(). I can't say I'm having much luck in getting that to
work.
Here's where my confusion lies:
1. I'm getting the current timestamp from the last displayed packet's
pts value. I figure if I add, say, 10 to that and seek to that
position I should get to the next keyframe, but it appears to go to
just the next frame. I'm using the following call:
av_seek_frame(formatContext, -1, (cur_pts+10), 0);
What am I doing wrong? I suspect it has a lot to do with the
timestamp units -- I can't seem to figure out which units they should
be in. I don't understand what units the packet's pts value is in, so
I don't know how to convert it to something acceptable for
av_seek_frame()
2. I can't seem to seek backward in the video at all. Even when I
seek to a timestamp of 0, I end up going forward.
3. I can't find a way to get the total number of frames in the movie.
I call formatContext->streams[videoStream]->nb_frames; but get a
value of 0.
Thank you very much,
Devin Lane
More information about the ffmpeg-devel
mailing list