<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 5:48 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">Thanks for you reply.</p>
<p style="margin:0px">So these lines of code:</p>
<br><p style="margin:0px">int64_t pts= av_rescale(pAVFrame->pts, pAVCodecContextVideo->framerate.den, pAVCodecContextVideo->framerate.num);</p>
<p style="margin:0px">printf("pts, %d\n", pts);</p>
<br><p style="margin:0px">Should print the timestamp (as time_t) of each frame? Is the pts value calculated correctly?</p></div></blockquote><div> </div><div>To use usleep, you need to convert the PTS interval to a number of microseconds using something like</div><div><br></div><div>int64_t usecs = av_rescale_q( pts - prev_pts, video_timebase, us_timebase )</div><div><br></div><div>where "video_timebase" is the timebase of the video PTS values and "us_timebase" is the microsecond timebase: num = 1, den = 1000000.</div><div><br></div><div>- Richard Hussong</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 data lunedì 21 agosto 2023 11:15:06 CEST, Paul B Mahol ha scritto:</p>
<p style="margin:0px">> On Mon, Aug 21, 2023 at 10:30 AM Denis Gottardello</p>
<p style="margin:0px">> <<a href="mailto:info@denisgottardello.it" target="_blank">info@denisgottardello.it</a>></p>
<p style="margin:0px">> wrote:</p>
<p style="margin:0px">> > In order to implement a sleep function and wait the right time to display</p>
<p style="margin:0px">> > a frame I have written this code:</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > int framerate= pAVCodecContextVideo->framerate.num /</p>
<p style="margin:0px">> > pAVCodecContextVideo->framerate.den;</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > if (previous!= 0) {</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> >     av_usleep((pAVFrame->pts - previous) / framerate);</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > }</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > previous= pAVFrame->pts;</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > but the value passed to av_usleep() is wrong.</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > How have I to calculate it?</p>
<p style="margin:0px">> </p>
<p style="margin:0px">> If you really want to do it that way you need to use floating point</p>
<p style="margin:0px">> calculations, or use fixed point arithmetic (av_rescale*)</p>
<p style="margin:0px">> to convert seconds to microseconds.</p>
<p style="margin:0px">> </p>
<p style="margin:0px">> > Best regards.</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > --</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > +39.347.4070897</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > <a href="http://www.labcsp.com" target="_blank">http://www.labcsp.com</a></p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > <a href="http://www.denisgottardello.it" target="_blank">http://www.denisgottardello.it</a></p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > GMT+1</p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > Skype: mrdebug</p>
<p style="margin:0px">> > _______________________________________________</p>
<p style="margin:0px">> > Libav-user mailing list</p>
<p style="margin:0px">> > <a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a></p>
<p style="margin:0px">> > <a href="https://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a></p>
<p style="margin:0px">> > </p>
<p style="margin:0px">> > To unsubscribe, visit link above, or email</p>
<p style="margin:0px">> > <a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>-- </p>
<p style="margin:0px"><span style="color:rgb(35,38,41)"><span><span style="background-color:rgb(255,255,255)">+39.347.4070897</span></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>