[Libav-user] Decode every 24-th frame. Cached decoded frames?

James Board jpboard2 at yahoo.com
Sat Oct 12 21:51:04 CEST 2013

I have a C program that is using libav in a video editor.  I want to decode
every 24th frame of the video (and nothing else).  I wrote a loop which
uses avformat_seek_file() to seek to frame 0, then frame24, then frame 48,
then frame 72, etc.  My input file is AVI container with the ffvhuff codec.

The problem is that whenever I seek to frame N, it also decodes the next
12 frames after N (which I don't want).  This is slowing things down
by a factor of 12 since I don't need those extra frames.  What is the name of
this 'feature'?  (so I can search for it in the documentation)?  How can I tell libAV
to only decode frame N when I seek to frame N?

The high-level psuedo-code looks like this
    for (int f = 0 ; f < LargeNumber; f+= 24) {
        avformat_seek_file(ctx, 0, f, f, f, AVSEEK_FLAG_FRAME, AVSEEK_FLAG_ANY);
In the above code, when I look at best_effort_timestamp for the decoded frame, it will equal the
seek position 'f' only for the first iteration of the loop, then the next decoded frame has
best_effort_timestamp of 1, then the next is 2, etc.  How can I tell libAV to turn off this

Thank you all.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131012/a5c258d1/attachment.html>

More information about the Libav-user mailing list