<HTML><BODY><div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16726694701859999260_BODY"><div class="cl_762972"><div><div>On Mon, Jan 2, 2023 at 3:13 PM wolverin via Libav-user <<a href="//e.mail.ru/compose/?mailto=mailto%3alibav%2duser@ffmpeg.org">libav-user@ffmpeg.org</a>> wrote:</div> <div class="gmail_quote_mr_css_attr"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote_mr_css_attr"><div><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><div id="m_-404747493619054020_mr_css_attr"><div><div><div id="m_-404747493619054020style_16726605471556409646_BODY_mr_css_attr"><div><div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div id="m_-404747493619054020m_-7615466201307963749style_16726579780851210439_mr_css_attr"><div id="m_-404747493619054020m_-7615466201307963749style_16726579780851210439_BODY_mr_css_attr"><div><div><div><div><div><div><em>Output #0, rtsp, to 'rtsp://<a href="http://127.0.1.1:555" target="_blank">127.0.1.1:555</a>':</em></div><div><em>  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown), 1280x720, q=2-31, 500 kb/s, 15 tbr, 90k tbn</em></div></div></div><div> </div><div> </div><div>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.</div></div></div></div></div></div></div></div></blockquote><div> </div><div>You can not use 15 from video frame rate to calculate PTS when video is variable frame rate.</div></div></div></div></div></div></div></div></blockquote><div> </div><div>ok, but then how do I calculate the pts/dts of each frame correctly???</div></div></blockquote><div> </div><div>PTS is represented as relative time starting from 0 for start of file.</div><div> </div><div>PTS is just a int64_t number that tells relative time.</div><div>To know time resolution one use timebase.num/den, so they are actually tied together with pts timestamp.</div><div> </div><div>If video is VFR than there are gaps e.g. non-monotonous increasing of pts from older to newer ones.</div><div> </div><div>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.</div><div>5.5 seconds would then be 5*90000 + 0.5*90000.</div><div> </div><div>Hope that you can conclude from this demonstration how to solve your problem.</div><div> </div><div>To rescale PTS from one timebase resolution to another one use av_rescale_q().</div></div></div></div></div></div></div></div></blockquote><div> </div><div>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?</div><div> </div><div>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.</div><div> </div><div>Thank you so much for your help!</div></div></BODY></HTML>