今天终于弄懂以上几个关系。
I frame 的解码不依赖于任何的其它的帧.
p frame的解码则依赖于其前面的I frame或者P frame.
B frame的解码则依赖于其前的最近的一个I frame或者P frame 及其后的最近的一个P frame.
解码顺序:
I P B B B P B B B ...显示顺序
I B B B P B B B P ...
DTS和PTS的不同:
DTS主要用于视频的解码,在解码阶段使用.
PTS主要用于视频的同步和输出.在display的时候使用.
在没有B frame的情况下.DTS和PTS的输出顺序是一样的.(这点很重要)
compositionTime = (PTS - DTS) / 90.0
AVCVIDEOPACKET
CompositionTime SI24 if AVCPacketType == 1
Composition time offset
0
由于我做的是直播流,为了减少延时,没有使用B帧。故CompositionTime为00 00 00.
特此记录
而x264.h里面x264_picture_t两个成员
int64_t i_pts;
/* Out: frame dts. When the pts of the first frame is close to zero,
* initial frames may have a negative dts which must be dealt with by any muxer */
int64_t i_dts;
/* In: custom encoding parameters to be set from this frame forwards
(in coded order, not display order). If NULL, continue using
parameters from the previous frame. Some parameters, such as
aspect ratio, can only be changed per-GOP due to the limitations
of H.264 itself; in this case, the caller must force an IDR frame
if it needs the changed parameter to apply immediately. */
解码顺序:
I P B B B P B B B ...显示顺序
I B B B P B B B P ...
本文详细解析了I帧、P帧和B帧的工作原理及其依赖关系,同时介绍了DTS和PTS的区别及应用场景,帮助读者深入理解音视频编解码的基础知识。
969

被折叠的 条评论
为什么被折叠?



