<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 2, 2023 at 3:39 PM wolverin via Libav-user <<a href="mailto:libav-user@ffmpeg.org">libav-user@ffmpeg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><div id="m_-1306289914589990224"><div><div><div id="m_-1306289914589990224style_16726694701859999260_BODY"><div><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" target="_blank">libav-user@ffmpeg.org</a>> wrote:</div> <div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><div id="m_-1306289914589990224m_-404747493619054020_mr_css_attr"><div><div><div id="m_-1306289914589990224m_-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_-1306289914589990224m_-404747493619054020m_-7615466201307963749style_16726579780851210439_mr_css_attr"><div id="m_-1306289914589990224m_-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></blockquote><div><br></div><div>Nope.</div><div>PTS is just timebase * seconds represented as int64 number</div><div><br></div><div>There are no additions with next/prev pts values.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><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></blockquote><div><br></div><div>Show your code.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div> </div><div>Thank you so much for your help!</div></div></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div></div>