[Libav-user] How to calculate pts/dts ???
Paul B Mahol
onemda at gmail.com
Mon Jan 2 16:29:28 EET 2023
On Mon, Jan 2, 2023 at 3:13 PM wolverin via Libav-user <
libav-user at ffmpeg.org> wrote:
> *Output #0, rtsp, to 'rtsp://127.0.1.1:555 <http://127.0.1.1:555>':*
> * Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown),
> 1280x720, q=2-31, 500 kb/s, 15 tbr, 90k tbn*
> I compared such an approximate calculation of pts/dts in ffprobe for my
> code and ffmpeg and they match until the real fps becomes different from
> the calculated one, then I see either delays or frame losses in VLC.
> You can not use 15 from video frame rate to calculate PTS when video is
> variable frame rate.
> ok, but then how do I calculate the pts/dts of each frame correctly???
PTS is represented as relative time starting from 0 for start of file.
PTS is just a int64_t number that tells relative time.
To know time resolution one use timebase.num/den, so they are actually tied
together with pts timestamp.
If video is VFR than there are gaps e.g. non-monotonous increasing of pts
from older to newer ones.
Say time of frame is 5.5 seconds and timebase used is 1/90000 than time of
1 second would have value of 90000 stored in pts.
5.5 seconds would then be 5*90000 + 0.5*90000.
Hope that you can conclude from this demonstration how to solve your
To rescale PTS from one timebase resolution to another one use
> I want my SoC ARM to provide maximum transcoding speed, this is especially
> important for a resolution of 1920x1080 when fps is 8-11
> Libav-user mailing list
> Libav-user at ffmpeg.org
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user