[Libav-user] Fwd: Why is av_seek_frame() inaccurate in some cases ?

Alex Cohn alexcohn at netvision.net.il
Mon Apr 16 16:51:17 CEST 2012

On Mon, Apr 16, 2012 at 13:39, Lucas Soltic <soltic.lucas at gmail.com> wrote:
> Actually if I disable the audio stream seeking (ie. do not call
> av_seek_frame() for the audio stream), the AVSEEK_FLAG_* are correctly
> handled. And if I use AVSEEK_FLAG_ANY for the video stream, I exactly get
> the PTS I wanted (with artifacts in the image, but it's normal as I didn't
> seek to a keyframe), AND the audio PTS is also correct, although I didn't do
> any seeking for the audio stream. THUS I'm wondering why both streams are
> bound that way? Aren't they supposed to be independent ?

Your code sample did not mention seeking the audio stream, did it?
What audio codec is used? How were audio and video muxed together?

> Now, considering that I don't want to get artifacts, I suppose I still HAVE
> to *don't* use AVSEEK_FLAG_ANY and do avcodec_decode_video2() for up to 10
> seconds of video in order to get full images, wherever I seek to. Am I right?

If the purpose of your seek() is to start displaying video from that
point, then yes, you can only start decoding from a key frame.

> Regards,
> Lucas SOLTIC


More information about the Libav-user mailing list