ffprobe 如何区分一个帧是IDR还是I帧

Instantaneous Decode Refresh frame

These are actually keyframes and each keyframe can either be IDR based or non-IDR based.
The difference between the two is that the IDR based keyframe works as a hardstop.
An IDR-frame prevents p-frames and b-frames from referencing frames that occurred before the IDR-frame.
A non-IDR keyframe will allow those frames to look further back for redundancies.

There’s some confusion in the marketplace about the difference between I-frames and IDR frames. The short answer is that every IDR frame is an I-frame, but not vice versa, so there can be I-frames that aren’t IDR frames. When you’re producing for streaming, that’s when you can run into problems.

NAL types

ffprobe 如何区分一个帧是IDR还是I帧_第1张图片

下边的方法感觉还是有问题 还是先不要看了
用https://trac.ffmpeg.org/attachment/ticket/6869/IDR%2CI%2CI%2CI%2CIDR.mkv 这个素材,
下边的方法区分不出来。。。

如何区分一个帧是IDR还是I帧 (无效方法)

ffprobe -v error -show_frames -select_streams v ca53.mp4

从pict_type=I可以看出这是个关键帧,然后key_frame=1 表示这是IDR frame,如果key_frame=0表示这是Non-IDR frame.

[FRAME]
media_type=video
stream_index=0
key_frame=1 # IDR帧
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=3600
pkt_duration_time=0.040000
pkt_pos=34674
pkt_size=12467
width=640
height=360
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=3600
pkt_pts_time=0.040000
pkt_dts=3600
pkt_dts_time=0.040000
best_effort_timestamp=3600
best_effort_timestamp_time=0.040000
pkt_duration=3600
pkt_duration_time=0.040000
pkt_pos=48884
pkt_size=25
width=640
height=360
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=7200
pkt_pts_time=0.080000
pkt_dts=7200
pkt_dts_time=0.080000
best_effort_timestamp=7200
best_effort_timestamp_time=0.080000
pkt_duration=3600
pkt_duration_time=0.040000
pkt_pos=48814
pkt_size=70
width=640
height=360
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=B
coded_picture_number=2
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=10800
pkt_pts_time=0.120000
pkt_dts=10800
pkt_dts_time=0.120000
best_effort_timestamp=10800
best_effort_timestamp_time=0.120000
pkt_duration=3600
pkt_duration_time=0.040000
pkt_pos=47141
pkt_size=1673
width=640
height=360
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]
...

References:

https://zhuanlan.zhihu.com/p/36109778
https://streaminglearningcenter.com/articles/everything-you-ever-wanted-to-know-about-idr-frames-but-were-afraid-to-ask.html
https://video.ibm.com/blog/streaming-video-tips/keyframes-interframe-video-compression/
https://video.stackexchange.com/questions/19250/how-to-identify-i-frame-from-idr-frame-in-the-ffprobe-show-frames-output
https://trac.ffmpeg.org/ticket/6869
https://superuser.com/questions/1344558/ffprobe-returns-that-all-i-frames-are-idr-frames-keyframe-1-in-a-ts-file
http://gentlelogic.blogspot.com/2011/11/exploring-h264-part-2-h264-bitstream.html

你可能感兴趣的:(ffprobe 如何区分一个帧是IDR还是I帧)