<div dir="ltr">I have been coding my 'ffmpeg streaming project' for more than two years now, but still don't have full idea what changes happen with pts/dts. Every realization has edge cases when it won't work.<div><br></div><div>I do sometimes remuxing, sometimes transcoding. And 'pts' for me is very significant:</div><div>1) It represents the real time of stream working, like 2d3h35m24s. It impacts on my archive start and end boundaries. Which gives me subproblems:</div><div>1-1) packets show me that there is (start_pts_1 -> pts_end_1) working time, but frames give different numbers (start_pts_1 -> pts_end_2). So only start time matches. Maybe a few frame duration less (or more?), but maybe it will accumulate to bigger divergence.</div><div>2) I have some events happening during streaming. And I should be able to find a frame with specific 'pts' in my archive. Problems:</div><div>2-1) I have a paradox piece of code. I get pts of AVFrame and search for in the remuxing base archive, which boundaries are found on pts of source packets. But archive is not a single blob, but a bunch of small parts, so I believe there could be cases when I miss the right part.</div><div><br></div><div>For now I have a big misunderstanding which broke my logic:</div><div>I start decoding not from the start, only when I need it. I want to check decoder frames right after I get them, to be sure I can use it further at muxer. And sometimes the decoder starts to return frames with 'pts' < 'pkt_dts'. Why and what should I do with it?</div><div><div class="gmail-kiwi-messagelist-item" style="overflow:hidden;color:rgb(34,35,31);font-family:"Source Sans Pro",Helvetica,sans-serif"><div class="gmail-kiwi-messagelist-message gmail-kiwi-messagelist-message--modern gmail-kiwi-messagelist-message--authorrepeat gmail-kiwi-messagelist-message-privmsg gmail-kiwi-messagelist-message--own" style="padding:0px 10px;border-left:7px solid transparent;overflow:hidden;line-height:1.5em;margin:0px;border-top:none;display:flex"><div class="gmail-kiwi-messagelist-modern-right" style="margin-left:5px;padding-top:0px;width:1360.88px"><div class="gmail-kiwi-messagelist-body" style="min-height:0px;line-height:1.5em;margin:0px 0px 10px;padding:0px;white-space:pre-wrap">Example:</div></div></div></div><div class="gmail-kiwi-messagelist-item gmail-cye-lm-tag" style="overflow:hidden;color:rgb(34,35,31);font-family:"Source Sans Pro",Helvetica,sans-serif"><div class="gmail-kiwi-messagelist-message gmail-kiwi-messagelist-message--modern gmail-kiwi-messagelist-message--authorrepeat gmail-kiwi-messagelist-message-privmsg gmail-kiwi-messagelist-message--own gmail-cye-lm-tag" style="padding:0px 10px;border-left:7px solid transparent;overflow:hidden;line-height:1.5em;margin:0px;border-top:none;display:flex"><div class="gmail-kiwi-messagelist-modern-right gmail-cye-lm-tag" style="margin-left:5px;padding-top:0px;width:1360.88px"><div class="gmail-kiwi-messagelist-body gmail-cye-lm-tag" style="min-height:0px;line-height:1.5em;margin:0px 0px 10px;padding:0px;white-space:pre-wrap">source pts/dts: 255600/255600 decoded pts/dts 252000 255600 type: P</div><div class="gmail-kiwi-messagelist-body gmail-cye-lm-tag" style="min-height:0px;line-height:1.5em;margin:0px 0px 10px;padding:0px;white-space:pre-wrap">source pts/dts: 259200/259200 decoded pts/dts 255600 259200 type: P</div></div></div></div><div class="gmail-kiwi-messagelist-item" style="overflow:hidden;color:rgb(34,35,31);font-family:"Source Sans Pro",Helvetica,sans-serif"><div class="gmail-kiwi-messagelist-message gmail-kiwi-messagelist-message--modern gmail-kiwi-messagelist-message--authorrepeat gmail-kiwi-messagelist-message-privmsg gmail-kiwi-messagelist-message--own" style="padding:0px 10px;border-left:7px solid transparent;overflow:hidden;line-height:1.5em;margin:0px;border-top:none;display:flex"><div class="gmail-kiwi-messagelist-modern-right" style="margin-left:5px;padding-top:0px;width:1360.88px"><div class="gmail-kiwi-messagelist-body" style="min-height:0px;line-height:1.5em;margin:0px 0px 10px;padding:0px;white-space:pre-wrap">source pts/dts: 262800/262800 decoded pts/dts 259200 262800 type: P</div></div></div></div><div class="gmail-kiwi-messagelist-item" style="overflow:hidden;color:rgb(34,35,31);font-family:"Source Sans Pro",Helvetica,sans-serif"><div class="gmail-kiwi-messagelist-message gmail-kiwi-messagelist-message--modern gmail-kiwi-messagelist-message--authorrepeat gmail-kiwi-messagelist-message-privmsg gmail-kiwi-messagelist-message--own" style="padding:0px 10px;border-left:7px solid transparent;overflow:hidden;line-height:1.5em;margin:0px;border-top:none;display:flex"><div class="gmail-kiwi-messagelist-modern-right" style="margin-left:5px;padding-top:0px;width:1360.88px"><div class="gmail-kiwi-messagelist-body" style="min-height:0px;line-height:1.5em;margin:0px 0px 10px;padding:0px;white-space:pre-wrap">source pts/dts: 266400/266400 decoded pts/dts 262800 266400 type: P</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пн, 4 июл. 2022 г. в 13:26, Strahinja Radman <<a href="mailto:dr.strashni@gmail.com">dr.strashni@gmail.com</a>>:<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 style="overflow-wrap: break-word;"><br><div><br><blockquote type="cite"><div>On 4. 7. 2022., at 08:04, Jake Eastwood <<a href="mailto:cheloveck2.0@gmail.com" target="_blank">cheloveck2.0@gmail.com</a>> wrote:</div><br><div><div dir="ltr">How should I validate pts/dts after demuxing and then after decoding?<div><br></div><div>For me it is significant to have valid pts all the time for days and possibly weeks of continuous streaming.</div><div><br></div><div>After demuxing I check:</div><div>1) dts <= pts</div><div>2) prev_packet_dts < next_packet_pts</div><div>3) I also discard packets with <span style="color:rgb(144,139,37);background-color:rgb(43,43,43);font-family:"JetBrains Mono",monospace;font-size:9.8pt">AV_NOPTS_VALUE</span> and wait for packets with proper pts, because I don't know video duration at this case.</div><div>* pts of packets can be not increasing because of I-P-B frames</div><div>Is it all right?</div><div><br></div><div>What about decoded AVFrames?</div><div>1) Should 'pts' be increasing all the time?</div><div>2) Why at some point 'pts' could lag behind 'dts'?</div><div>3) Why <span style="color:rgb(147,115,165);background-color:rgb(43,43,43);font-family:"JetBrains Mono",monospace;font-size:9.8pt">pict_type</span> is a parameter of AVFrame? Should be at AVPacket, because AVPacket is a compressed frame, not the opposite?</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" 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></div></blockquote></div><div><br></div><div><br></div><div>Hello Jake,</div><div><br></div><div>PTS is a time when frame is presented to you, while DTS is a time when AVPacket is decoded into a frame so other AVFrames (P/B) can possibly be reconstructed using information from that AVFrame. PTS cannot be less then DTS, but it can be the same. Packets cannot be presented before they are decoded. Its possible that DTS has a negative value, which makes no difference in decoding.</div><br><div>But its not clear, at least for me, what exactly are you hoping to achieve by validating if they are correct or not, is there a specific player issue that you are experiencing? Players usually handle invalid PTS information by creating them using framerate of the video. Attempting to do this by yourself can be very tricky especially when you do it for days or months. For example it can introduce audio sync issues.</div><div><br></div><div>Kind regards,</div><div>Strahinja</div><div><br></div><div><br></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>