[Libav-user] Seek backward

Anton Shekhovtsov shekh.anton at gmail.com
Fri Dec 23 18:04:28 EET 2016


2016-12-23 17:29 GMT+02:00 Gabriele Greco <gabriele.greco at wyscout.com>:

> I'm trying to find a consistent way to seek backward with an
> avcodec/avformat based player, supporting different codec and containers.
>
> What I do at the moment is:
>
> av_seek_frame(ictx, video_track, dest_pts, 0);
> avcodec_flush_buffers(vctx);
> avcodec_flush_buffers(actx);
>
> And it works well if the dest_pts is "far" from the actual pts, but if I
> try to seek for instance 2 seconds before the actual position I often get
> as first frame the same pts of the actual position... here is a log
> fragment:
>
> performing seek to 2046 (51149999) actual pts:51200000
> got frame pts:51200000
>
> I think the problem is related to the keyframe distribution in the stream,
> since it works ok with some files and does not with other, also with the
> same codec/container but probabily with different keyframe intervals.
>
> There is some advanced method (also with some encoding overhead) to
> perform this being almost sure to go to the desired position?
>
> The only thing I can think is to jump backward 30 seconds and then decode
> 28 seconds of audio/video without displaying it, so that I can stop to -2
> secs, also if the frame is a B frame. This will fail anyway if the I frame
> distance is more than 30 secs... and it will be really heavy for the CPU
> with the 1080p streams I'm working usually with...
>
> --
> *Bye, *
> *Gabry*
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
Why not specifying AVSEEK_FLAG_BACKWARD?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20161223/41d8dc5e/attachment.html>


More information about the Libav-user mailing list