<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_16726759490099879502_BODY"><div class="cl_941070"><div><div class="gmail_quote_mr_css_attr"><div class="gmail_attr_mr_css_attr">On Mon, Jan 2, 2023 at 4:51 PM wolverin via Libav-user <<a href="//e.mail.ru/compose/?mailto=mailto%3alibav%2duser@ffmpeg.org">libav-user@ffmpeg.org</a>> wrote:</div><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><div><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><div id="m_-2238968379547552665_mr_css_attr"><div><div><div id="m_-2238968379547552665style_16726707970753945901_BODY_mr_css_attr"><div><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>Nope.</div><div>PTS is just timebase * seconds represented as int64 number</div><div> </div><div>There are no additions with next/prev pts values.</div><div> </div></div></div></div></div></div></div></div></blockquote></div><div> </div><div>Then pts is the time of one frame?</div></div></blockquote><div> </div><div>Yes, when used with tied time_base AVRational.</div><div> </div></div></div></div></div></div></div></div></blockquote></div><div>Thank you very much, you helped me a lot, it significantly improved the smoothness of playback, but I still see 1 or 2 incomprehensible pauses at the beginning when watching live video in VLC.</div><div><div> </div><div>Currently, only the output AVStream->time_base is used to calculate pts/dts.</div></div><div>But then what is the outgoing AVCodecContext->time_base needed for and what values? Do I need to initialize AVStream->avg_frame_rate or AVStream->r_frame_rate? Their change does not affect almost the video, but for some reason it increases traffic.</div><div> </div><div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div><div class="cl_941070"><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><div>avcodec_send_packet(pCdcCtxInp, pPktInp);</div><div><div><div><div>avcodec_receive_frame(pCdcCtxInp, pFrm);</div></div><div><div>pFrm->pts = av_rescale_q(pPktInp->pts, pFmtCtxInp->streams[0]->time_base, pCdcCtxInp->time_base);</div><div> </div><div><div><div>avcodec_send_frame(pCdcCtxOut, pFrm);</div></div><div>avcodec_receive_packet(pCdcCtxOut, pPktOut);</div><div>pPktOut->pts = av_rescale_q(pFrm->pts, pCdcCtxInp->time_base, pCdcCtxOut->time_base);</div><div>pPktOut->dts = pPktOut->pts;</div></div></div></div></div></div></blockquote><div> </div><div>Inspect values of input/output pts and used timebases(with printfs or other ways...) and you can figure it where PTS becomes nonsense.</div></div></div></div></div></div></div></div></blockquote></div><div> </div><div><div>As I understand it, the input stream from the usb camera has a constant FR, transcoded I get a variable FR + <div><div>I can start reading earlier<span style="font-family: var(--vkui--octavius_font_family_global,var(--vkui--font_family_base,Helvetica,Arial,sans-serif)); letter-spacing: var(--vkui--font_text--letter_spacing--regular,normal);"> frames from the camera</span><span style="font-family: var(--vkui--octavius_font_family_global,var(--vkui--font_family_base,Helvetica,Arial,sans-serif)); letter-spacing: var(--vkui--font_text--letter_spacing--regular,normal);"> additionally for writing to disk, so I can't scale timestamps directly.</span></div></div></div><div><br> </div></div></BODY></HTML>