<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-12-23 17:29 GMT+02:00 Gabriele Greco <span dir="ltr"><<a href="mailto:gabriele.greco@wyscout.com" target="_blank">gabriele.greco@wyscout.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm trying to find a consistent way to seek backward with an avcodec/avformat based player, supporting different codec and containers.<div><br></div><div>What I do at the moment is:</div><div><br></div><div>av_seek_frame(ictx, video_track, dest_pts, 0);</div><div>avcodec_flush_buffers(vctx);</div><div>avcodec_flush_buffers(actx);</div><div><br></div><div>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:</div><div><br></div><div><div>performing seek to 2046 (51149999) actual pts:51200000</div><div>got frame pts:51200000</div></div><div><div><br></div><div>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.</div><div><br></div><div>There is some advanced method (also with some encoding overhead) to perform this being almost sure to go to the desired position?</div><div><br></div><div>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...</div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_5904954785642471529gmail_signature"><div dir="ltr"><div dir="ltr"><div><div><b>Bye, </b></div></div><div><b>Gabry</b></div></div></div></div>
</font></span></div></div>
<br>______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Why not specifying AVSEEK_FLAG_BACKWARD?<br><br></div></div>