[Libav-user] pts/dts validation

Strahinja Radman dr.strashni at gmail.com
Mon Jul 4 10:26:25 EEST 2022

> On 4. 7. 2022., at 08:04, Jake Eastwood <cheloveck2.0 at gmail.com> wrote:
> How should I validate pts/dts after demuxing and then after decoding?
> For me it is significant to have valid pts all the time for days and possibly weeks of continuous streaming.
> After demuxing I check:
> 1) dts <= pts
> 2) prev_packet_dts < next_packet_pts
> 3) I also discard packets with AV_NOPTS_VALUE and wait for packets with proper pts, because I don't know video duration at this case.
> * pts of packets can be not increasing because of I-P-B frames
> Is it all right?
> What about decoded AVFrames?
> 1) Should 'pts' be increasing all the time?
> 2) Why at some point 'pts' could lag behind 'dts'?
> 3) Why pict_type is a parameter of AVFrame? Should be at AVPacket, because AVPacket is a compressed frame, not the opposite?
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe”.

Hello Jake,

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.

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.

Kind regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220704/52a45cf8/attachment.htm>

More information about the Libav-user mailing list