<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Thanks for you reply.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">So these lines of code:</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">int64_t pts= av_rescale(pAVFrame->pts, pAVCodecContextVideo->framerate.den, pAVCodecContextVideo->framerate.num);</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">printf("pts, %d\n", pts);</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Should print the timestamp (as time_t) of each frame? Is the pts value calculated correctly?</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">In data lunedì 21 agosto 2023 11:15:06 CEST, Paul B Mahol ha scritto:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> On Mon, Aug 21, 2023 at 10:30 AM Denis Gottardello</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> <info@denisgottardello.it></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> wrote:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > In order to implement a sleep function and wait the right time to display</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > a frame I have written this code:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > int framerate= pAVCodecContextVideo->framerate.num /</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > pAVCodecContextVideo->framerate.den;</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > if (previous!= 0) {</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> >     av_usleep((pAVFrame->pts - previous) / framerate);</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > }</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > previous= pAVFrame->pts;</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > but the value passed to av_usleep() is wrong.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > How have I to calculate it?</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> If you really want to do it that way you need to use floating point</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> calculations, or use fixed point arithmetic (av_rescale*)</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> to convert seconds to microseconds.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > Best regards.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > --</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > +39.347.4070897</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > http://www.labcsp.com</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > http://www.denisgottardello.it</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > GMT+1</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > Skype: mrdebug</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > _______________________________________________</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > Libav-user mailing list</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > Libav-user@ffmpeg.org</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > https://ffmpeg.org/mailman/listinfo/libav-user</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > To unsubscribe, visit link above, or email</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> > libav-user-request@ffmpeg.org with subject "unsubscribe".<br />-- </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#232629;"><span style="font-size:-0.083em;"><span style="background-color:#ffffff;">+39.347.4070897</span></span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="http://www.labcsp.com">http://www.labcsp.com</a><span style="color:#232629;"> </span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="http://www.denisgottardello.it">http://www.denisgottardello.it</a><span style="color:#232629;"> </span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#232629;"><span style="background-color:#ffffff;">GMT+1</span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#232629;"><span style="background-color:#ffffff;">Skype: mrdebug</span></span></p>
</body>
</html>