[Libav-user] AVFrame pts and av_usleep funciton.

Paul B Mahol onemda at gmail.com
Mon Aug 21 12:15:06 EEST 2023


On Mon, Aug 21, 2023 at 10:30 AM Denis Gottardello <info at denisgottardello.it>
wrote:

>
> In order to implement a sleep function and wait the right time to display
> a frame I have written this code:
>
> int framerate= pAVCodecContextVideo->framerate.num /
> pAVCodecContextVideo->framerate.den;
>
> if (previous!= 0) {
>
>     av_usleep((pAVFrame->pts - previous) / framerate);
>
> }
>
> previous= pAVFrame->pts;
>
> but the value passed to av_usleep() is wrong.
>
> How have I to calculate it?
>

If you really want to do it that way you need to use floating point
calculations, or use fixed point arithmetic (av_rescale*)
to convert seconds to microseconds.


>
> Best regards.
>
>
> --
>
> +39.347.4070897
>
> http://www.labcsp.com
>
> http://www.denisgottardello.it
>
> GMT+1
>
> Skype: mrdebug
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20230821/5d5da13e/attachment.htm>


More information about the Libav-user mailing list