<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-05-13 18:42 GMT+03:00 Gonzalo <span dir="ltr"><<a href="mailto:ggarra13@gmail.com" target="_blank">ggarra13@gmail.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"><br>
<br>
El 13/05/16 a las 11:25, Anton Shekhovtsov escribió:<span class=""><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks for reply.<br>
I decided I can loop through index_entries and if there is no 'keyframes' apply AVSEEK_FLAG_ANY.<br>
When it comes to seeking I do not select id, I just have it. The code deals with single stream (audio), other streams are AVDISCARD_ALL.<br>
For pos something like this, but why do you ask?<br>
int64_t pos = (destination_sample-discard_samples) * time_base.den / time_base.num;<br>
</blockquote></span>
I ask because the docs say:<br>
<br>
 * @param timestamp Timestamp in AVStream.time_base units<br>
<br>
And you are multiplying the denominator / numerator when in fact it should be the opposite.  With that, you should be able to multiply, say 1 sec, and get the right place in pos.<span class=""><font color="#888888"><br>
<br>
-- <br>
Gonzalo Garramuño<br>
<a href="mailto:ggarra13@gmail.com" target="_blank">ggarra13@gmail.com</a></font></span><div class=""><div class="h5"><br>
<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</div></div></blockquote></div><br>"and time_base is product of stream time_base and sample_rate"<br><br></div><div class="gmail_extra">I will expand this:<br>  AVRational tb = stream->time_base;<br>  av_reduce(&time_base.num, &time_base.den, codec->sample_rate*tb.num, tb.den, INT_MAX);<br><br></div><div class="gmail_extra">There is no mistake, it actually works. My problem was that seek failed with any pos (even plain 0) because avi has no 'keyframe' flags (maybe this is bug).<br></div></div>