[Libav-user] Why does av_seek_frame() not seek to a keyframe?

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Jul 19 20:42:50 CEST 2012


Michael Bradshaw <mbradshaw at ...> writes:

> >> But when I seek, the first packet returned out of the demuxer is
> >> not a keyframe packet, and I have to read several (~45ish) packets
> >> until I encounter a keyframe.
> >
> > Could you provide a sample that does not seek to a keyframe with
> > ffmpeg -ss x -i input out.png
> > (I tested this yesterday on random mpeg2video samples and afaict,
> > it did work.)
> 
> Sure, here's a link to a sample video I'm testing with

Thank you!
I tested the following (while still downloading):
ffmpeg -ss x -i 704x480-m2v-ac3.mpg.part out.png
I tested many values for x and always received a recognisable frame.
That does afaict mean that seeking only reaches keyframes for this 
stream, because if you test with older (or known broken) versions 
of FFmpeg you will get grey frames (as you do for mpeg4 asp content).
Please note that the current behaviour (while iiuc it is what you 
ask for and many users asked for before) is not uncontroversial 
amongst FFmpeg developers:
Afair, Reimar believes the seek function should not try hard to find 
a keyframe because seeking faster is more important.

I honestly cannot comment on the flags-value, I can only confirm 
that FFmpeg only seeks to keyframes for your sample here.

Carl Eugen



More information about the Libav-user mailing list