[Libav-user] Can't read packets after seeking

Mark McKay mark at kitfox.com
Mon May 13 09:56:14 EEST 2019

I'm having trouble reading video packets after seeking within a video.
I seem to have no problem reading reading video packets if I just start
at the begining of the stream and scan every packet in order, but the
below code is not working.

I'm calling this from a timer that I want to
grab the video frame closest to the time timeMs. av_read_frame() is
returning the value -541478725 the third time it gets called, which
stops me from receiving and decoding the frame most of the time:

QImage FfmpegMediaSource::getVideoFrame(int timeMs)

 //Seek to our goal time

int64_t targetPts = timeMs * 1000;
 targetPts = av_rescale_q(targetPts,

 int err
= av_seek_frame(pFormatCtx, videoStream, targetPts,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190513/e2e409e4/attachment.html>

More information about the Libav-user mailing list