PTS,DTS,CTS和I,P,B帧的关系

本文详细解析了I帧、P帧和B帧的工作原理及其依赖关系,同时介绍了DTS和PTS的区别及应用场景,帮助读者深入理解音视频编解码的基础知识。

今天终于弄懂以上几个关系。

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    

    else

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 ... 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值