• 六、RTMP协议 时间戳


    RTMP时间戳

    基本介绍

    • RTMP中时间戳的单位为毫秒(ms)
    • 时间戳为相对于某个时间点的相对值
    • 时间戳的长度为32bit,不考虑回滚的话,最大可表示49天17小时2分钟47.296秒
    • Timestamp delta单位也是毫秒,为相对于前一个时间戳的一个无符号整数; 可能为24bit或32bit

    Message时间戳

    Timestamp:
    Four-byte field that contains a timestamp of the message.
    The 4 bytes are packed in the big-endian order.
    • RTMP Message的时间戳 4个字节
    • 大端存储

    【学习地址】:FFmpeg/WebRTC/RTMP/NDK/Android音视频流媒体高级开发
    【文章福利】:

    免费领取更多音视频学习资料包、大厂面试题、技术视频和学习路线图,资料包括(C/C++,Linux,FFmpeg webRTC rtmp hls rtsp ffplay srs 等等)有需要的可以点击1079654574加群领取哦~

      

    Chunk时间戳

    Chunk Format

    wireshark转包分析发现,rtmp流的chunk视频流(或音频流)除第一个视频时间戳为绝对时间戳外,后续的时间戳均为timestamp delta,即当前时间戳与上一个时间戳的差值
    比如帧率为25帧/秒的视频流,timestamp delta基本上都为40ms。

    通常情况下,Chunk的时间戳(包括绝对时间戳和Timestamp delta)是3个字节。
    但时间戳值超过0xFFFFFF时,启用Extended Timestamp(4个字节)来表示时间戳

    通常情况下 -- 3字节

    三字节的timestamp可能为绝对timestamp或timestamp delta。

    timestamp delta (3 bytes):
    For a type-1 or type-2 chunk, the difference between the previous chunk’s timestamp and the current chunk’s timestamp is sent here.
    If the delta is greater than or equal to 16777215 (hexadecimal 0xFFFFFF), this field MUST be16777215, indicating the presence of the Extended Timestamp field to encode the full 32 bit delta. Otherwise, this field SHOULD be the actual delta.

    timestamp delta的值超过16777215 (即16进制的0xFFFFFF)时,这时候这三个字节必须被置为: 0xFFFFFF,以此来标示Extended Timestamp(4字节)将会存在,由Extended Timestamp来表示时间戳。

    时间戳超过0xFFFFFF时 -- 4字节

    • Extended Timestamp为4个字节。

    • 当Chunk Format中Message Header中的三字节时间戳的值为0xFFFFFF,即时间戳或timestamp delta超过16777215 (0xFFFFFF)时,Extended Timestamp才存在。
  • 相关阅读:
    数据仓库【博学谷学习记录】
    性能测试操作流程
    MySQL事务隔离级别
    【机器学习】模型评估
    STARK中的FRI代码解析
    C - Minimize The Integer
    JUC06-读写锁ReentrantReadWriteLock
    驱动点灯实验
    【无标题】
    树、二叉树、斜树、满二叉树、完全二叉树、二叉排序树、平衡二叉搜索树(AVL树) 、哈夫曼树(Huffman tree)、B树、B+Tree、B*树
  • 原文地址:https://blog.csdn.net/irainsa/article/details/127888861