[Ffmpeg-devel] Trouble with av_seek_frame() and av_read_frame()
Devin Lane
lists
Thu May 4 09:54:13 CEST 2006
Steve:
Thank you very much for your comments and code. I've been able to
get all of the functionality I want to work, except figuring out how
many frames there are in the movie.
Thanks,
On May 4, 2006, at 2:15 AM, Steve Lhomme wrote:
> Devin Lane wrote:
>> 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()
>
> I attach our QT VideoPreviewWidget code that mostly works to seek
> in video files. The timecode operations can be found there. (better
> than putting many lines of code here, out of context)
>
> Have a look in SetSource_internal() and on_buttonPrevFrame_clicked().
>
>> 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.
>
> You might try to seek by bytes, not time. It works better for some
> containers (MPEG and MP4).
>
>> 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
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at mplayerhq.hu
>> http://mplayerhq.hu/mailman/listinfo/ffmpeg-devel
> <snipped>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list