<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 21, 2023 at 10:30 AM Denis Gottardello <<a href="mailto:info@denisgottardello.it">info@denisgottardello.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div><br><p style="margin:0px">In order to implement a sleep function and wait the right time to display a frame I have written this code:</p>
<br><p style="margin:0px">int framerate= pAVCodecContextVideo->framerate.num / pAVCodecContextVideo->framerate.den;</p>
<p style="margin:0px">if (previous!= 0) {</p>
<p style="margin:0px">    av_usleep((pAVFrame->pts - previous) / framerate);</p>
<p style="margin:0px">}</p>
<p style="margin:0px">previous= pAVFrame->pts;</p>
<br><p style="margin:0px">but the value passed to av_usleep() is wrong.</p>
<p style="margin:0px">How have I to calculate it?</p></div></blockquote><div><br></div><div>If you really want to do it that way you need to use floating point calculations, or use fixed point arithmetic (av_rescale*)</div><div>to convert seconds to microseconds.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<br><p style="margin:0px">Best regards.</p>
<br><p style="margin:0px"><br>-- </p>
<p style="margin:0px"><span style="color:rgb(35,38,41)"><span style="background-color:rgb(255,255,255)">+39.347.4070897</span></span></p>
<p style="margin:0px"><a href="http://www.labcsp.com" target="_blank">http://www.labcsp.com</a><span style="color:rgb(35,38,41)"> </span></p>
<p style="margin:0px"><a href="http://www.denisgottardello.it" target="_blank">http://www.denisgottardello.it</a><span style="color:rgb(35,38,41)"> </span></p>
<p style="margin:0px"><span style="color:rgb(35,38,41)"><span style="background-color:rgb(255,255,255)">GMT+1</span></span></p>
<p style="margin:0px"><span style="color:rgb(35,38,41)"><span style="background-color:rgb(255,255,255)">Skype: mrdebug</span></span></p>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div></div>