[Ffmpeg-devel] [Ffmpeg-devel-old] how to get the previous frame
Wed Apr 27 11:15:54 CEST 2005
Thomas Koninckx wrote:
> On Tue, 2005-04-26 at 11:38 +0200, Claude Joseph-Angelique wrote:
>>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
> If somebody has a better solution.
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
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41
More information about the ffmpeg-devel