Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PTS and DTS are same in my stream?

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?

like image 407
MayurK Avatar asked Mar 28 '17 14:03

MayurK


People also ask

What is DTS PTS?

The PTS (Presentation Time Stamp) or DTS (Decode Time Stamp) is the time stamp of the packet being received and these will be different for each packet in the stream so will not be a fixed value.

What is PTS and DTS in ffmpeg?

PTS and DTS Instead, packets from the stream might have what is called a decoding time stamp (DTS) and a presentation time stamp (PTS). To understand these two values, you need to know about the way movies are stored. Some formats, like MPEG, use what they call "B" frames (B stands for "bidirectional").

What is PTS video?

Presentation timestamp (PTS) is a number indicating the moment when an elementary stream unit (video/audio/DVB subtitles) should be played. It is one of the most important parameters that determines if the video plays correctly.


2 Answers

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.

like image 139
aergistal Avatar answered Sep 28 '22 07:09

aergistal


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.

like image 44
MayurK Avatar answered Sep 28 '22 05:09

MayurK