6
votes

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?

2
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. ā€“ Raghvendra Kumar

2 Answers

4
votes

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.

3
votes

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.