[Libav-user] Seeking in a video with interframes
jstrecker at kosada.com
Wed Jun 1 20:15:08 CEST 2011
If you want to seek to an arbitrary frame in a video with interframes, what are your options?
As I understand it, you should be able to:
(1) seek to the previous keyframe and then enter a read/decode loop until you reach the frame you want, or
(2) pass AVSEEK_FLAG_ANY to the seek function (av_seek_frame or avformat_seek_file).
Does (2) work? I've tried it with both seek functions, and with various configurations of avcodec_flush_buffers (flush before seeking, after seeking, or not at all) -- but, at best, it results in frames with artifacts. If it makes a difference, I'm working with H.264 videos.
So, right now I'm using (1) but the read/decode loop is slow. Is there a faster way to seek?
More information about the Libav-user