[Libav-user] Why does av_seek_frame() not seek to a keyframe?
Carl Eugen Hoyos
cehoyos at ag.or.at
Mon Jul 23 20:50:24 CEST 2012
Hendrik Leppkes <h.leppkes at ...> writes:
> > Anyone have any answers on these two things? If the answer to the
> > above would be "yes" can anyone else verify that "ffmpeg -dump
> > -loglevel debug -ss 38 -i 704x480-m2v-ac3.mpg -vframes 1 out.jpg" does
> > not seek to a keyframe?
>
> As said, afaict it does seek to a keyframe.
> (But I may of course be wrong.)
>
> I am quite sure neither MPEG-PS nor MPEG-TS has the ability to
> seek to a keyframe. Its been a problem for me for a while and
> i've been over this code many times.
> All they do is a binary search for the timestamp, and when
> they arrive close enough, they are done.
>
> To compensate for this, decoders like MPEG-2 will simply discard
> frames until they see a keyframe to start decoding from, so
> visual corruption is avoided.
> If you run those codecs with AVCodeContext.flags2 set to
> CODEC_FLAG2_SHOW_ALL, you'll probably get plenty of corrupted
> frames before a real frame is shown, however i do not know how
> to do that via ffmpeg commandline to demonstrate.
(MPlayer should allow that.)
You are probably right, I assumed that from a users' perspective,
the only relevant question is if above command line returns a gray
frame or the next keyframe. Afaiu our discussion, the libraries
allow both possibilities, so at least many use cases should be
covered.
But please don't take my opinion too severe in this case, I just
wanted to point out that users did report the gray frames previously,
that this has been fixed and that Reimar preferred the previous
behaviour (that MPlayer still requests with CODEC_FLAG2_SHOW_ALL
iirc).
Carl Eugen
More information about the Libav-user
mailing list