[Ffmpeg-devel] [Ffmpeg-devel-old] how to get the previous frame
Michel Bardiaux
mbardiaux
Wed Apr 27 13:29:59 CEST 2005
Claude Joseph-Angelique wrote:
> Michel Bardiaux wrote:
>
>> Thomas Koninckx wrote:
>>
>>> On Tue, 2005-04-26 at 11:38 +0200, Claude Joseph-Angelique wrote:
>>>
>>>> Hi,
>>>> I'm trying to make a backward frame-by-frame on a video stream. But
>>>> av_read_frame() works sequencialy. How must I use av_seek_frame to
>>>> get the last frame without image degradation.
>>>
>>>
>>>
>>> I needed to do the same a while ago. What I did --but it might be that
>>> there is a much better solution-- is to make a small jump backward
>>> (av_seek_frame current pts-1 sec), and then read frames until I'm back
>>> at the current pts. I store always 2 frames in a small buffer. This way
>>> I always got the previous frame, undistorted also if it is not a key
>>> frame.
>>> If somebody has a better solution.
>>>
>>> Regards,
>>> Thomas
>>>
>> It is probably the only solution, at least with MPEG-something codecs.
>> But it will have to be even more complicated:
>>
>> (1) You have to check to be sure you encounter a key frame.
>>
>> (2) In MPEG-4 you can have very large GOPs, of several seconds, so a
>> jump of -1 sec is not enough to be before the key frame
>>
>> HaND,
>
>
> Ok,
> First thanks for your explanations. I'll try to seek to the last key
> frame in order to read frame from it to the current pts (always having
> the previous frame). But how can I know if a frame is a key frame? The
> "key_frame" field of the "AVFrame" structure seems to be always set to 0.
It's pkt->flags & PKT_FLAG_KEY where pkt is the AVPacket argument of
av_read_frame.
>
> Thanks
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/ffmpeg-devel
--
Michel Bardiaux
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41
More information about the ffmpeg-devel
mailing list