[Libav-user] Seeking in a video with interframes

Alex Cohn alexcohn at netvision.net.il
Wed Jun 1 22:01:30 CEST 2011


I am afraid you are out of luck there. You can use AVSEEK_FLAG_ANY
only if you are not interested in the decoded results. For example,
this way you can extract some metadata, or start read process to reach
the next I-frame.

There are some optimizations to consider for approach (1), though. For
example, make sure you request no color conversion or filtering for
the frames that you do not need.

Alex

On Wed, Jun 1, 2011 at 9:15 PM, Jaymie Strecker <jstrecker at kosada.com> wrote:
> 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?
>
> -Jaymie
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>


More information about the Libav-user mailing list