[Libav-user] How to calculate pts/dts ???

Paul B Mahol onemda at gmail.com
Mon Jan 2 18:17:17 EET 2023


On Mon, Jan 2, 2023 at 4:51 PM wolverin via Libav-user <
libav-user at ffmpeg.org> wrote:

> Did I understand you correctly that I need to multiply time_base and
> system time between adjacent frames and add the resulting time to the
> previous PTS?
>
> Nope.
> PTS is just timebase * seconds represented as int64 number
>
> There are no additions with next/prev pts values.
>
>
>
> Then pts is the time of one frame?
>

Yes, when used with tied time_base AVRational.


>
>
>
> I used av_rescale_q to scale time_base from an incoming MJPEG stream to an
> outgoing H264 one, but for some reason timestamps pts/dts are meaningless
> in this case.
>
>
> Show your code.
>
>
> I have greatly simplified it to understand how I am trying to use avscale,
> as it is done in different threads using buffers to use other ARM cores.
>
> avcodec_send_packet(pCdcCtxInp, pPktInp);
> avcodec_receive_frame(pCdcCtxInp, pFrm);
> pFrm->pts = av_rescale_q(pPktInp->pts, pFmtCtxInp->streams[0]->time_base,
> pCdcCtxInp->time_base);
>
> avcodec_send_frame(pCdcCtxOut, pFrm);
> avcodec_receive_packet(pCdcCtxOut, pPktOut);
> pPktOut->pts = av_rescale_q(pFrm->pts, pCdcCtxInp->time_base,
> pCdcCtxOut->time_base);
> pPktOut->dts = pPktOut->pts;
>

Inspect values of input/output pts and used timebases(with printfs or other
ways...) and you can figure it where PTS becomes nonsense.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20230102/227fcd5e/attachment.htm>


More information about the Libav-user mailing list