<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 5, 2023 at 3:43 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_98309575080750255"><div><div><div id="m_98309575080750255style_16726759490099879502_BODY"><div><div><div><div>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" target="_blank">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"><div><div><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><div id="m_98309575080750255m_-2238968379547552665_mr_css_attr"><div><div><div id="m_98309575080750255m_-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 rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><div><div><div><div><div><div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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> frames from the camera</span><span> additionally for writing to disk, so I can't scale timestamps directly.</span></div></div></div></div></div></blockquote><div><br></div><div>If you use libx264 encoder, have you tried tune zerolatency compensation flag?</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><br> </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>