Why PTS and DTS are same in my stream?
Asked Answered
D

2

8

I am testing a mp4 file with H264 video using ffprobe. I am using the following command to get frame information.

ffprobe -i <input_mp4_file> -show_frames -select_streams v

I get the following output.

[FRAME]
media_type=video
stream_index=0
key_frame=1
pkt_pts=0
pkt_pts_time=0.000000
pkt_dts=0
pkt_dts_time=0.000000
best_effort_timestamp=0
best_effort_timestamp_time=0.000000
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=48
pkt_size=513516
width=1920
height=1920
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=I
coded_picture_number=0
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=512
pkt_pts_time=0.033333
pkt_dts=512
pkt_dts_time=0.033333
best_effort_timestamp=512
best_effort_timestamp_time=0.033333
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=513564
pkt_size=3299
width=1920
height=1920
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=P
coded_picture_number=1
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=1024
pkt_pts_time=0.066667
pkt_dts=1024
pkt_dts_time=0.066667
best_effort_timestamp=1024
best_effort_timestamp_time=0.066667
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=823989
pkt_size=40971
width=1920
height=1920
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=B
coded_picture_number=4
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=1536
pkt_pts_time=0.100000
pkt_dts=1536
pkt_dts_time=0.100000
best_effort_timestamp=1536
best_effort_timestamp_time=0.100000
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=784312
pkt_size=38785
width=1920
height=1920
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=B
coded_picture_number=3
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=2048
pkt_pts_time=0.133333
pkt_dts=2048
pkt_dts_time=0.133333
best_effort_timestamp=2048
best_effort_timestamp_time=0.133333
pkt_duration=512
pkt_duration_time=0.033333
pkt_pos=516886
pkt_size=267344
width=1920
height=1920
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=P
coded_picture_number=2
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]

My mp4 file has I, P and B frames. I understand that DTS is decode time stamp and it will be in incrementing order in decoder input stream. PTS is presentation time stamp and it will be in incrementing order in decoder output stream.

I do not understand why I am getting same PTS and DTS values for all frames. I think they should be different when B frames are present in the stream.

Somebody please help me in understanding this?

Doloroso answered 28/3, 2017 at 14:14 Comment(1)
If you have a B frames in your video then DTS and PTS can not be same as B frames can not be decoded before I and P frame due to the bi-directional dependency.Womera
A
6

The values are not the DTS/PTS you expect, note the pkt_ prefix. See here.

pkt_pts

PTS copied from the AVPacket that was decoded to produce this frame.

pkt_dts

DTS copied from the AVPacket that triggered returning this frame.

If you do a -show_packets you should see different values.

Arun answered 28/3, 2017 at 15:13 Comment(5)
Is there a way to get PTS and DTS using ffmpeg?Doloroso
Yes, use ffmpeg -i in.mp4 -dump -map 0:v -f null -Dodecanese
@Mulvya: Thanks! I got it. I need to press D and it will show pts and dts. I have one more question. Can I print "coded_picture_number" or "display_picture_number" also with this print?Doloroso
@argistal: Can you please explain briefly what are "pkt_pts" and "pkt_pts"? What are they used for?Doloroso
@Doloroso The frame pkt_pts and pkt_dts apply to the decoded frame and are both presentation timestamps used for display. DTS means in this case a presentation timestamp based on the decoding time of the original packet. See here: trac.ffmpeg.org/ticket/2375Arun
D
3

This is what I finally found.

ffmpeg -i -dump -map 0:v -f null –

Then press “D” to get PTS and DTS prints. It prints the PTS and DTS of frames in decode order.

Doloroso answered 4/10, 2017 at 8:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.