rtmp协议详解

RTMP协议 05 时间戳

2017-07-05  本文已影响313人  FlyingPenguin

RTMP时间戳

基本介绍
timestamp

Message时间戳

Message时间戳
Timestamp:
Four-byte field that contains a timestamp of the message.
The 4 bytes are packed in the big-endian order.
Chunk时间戳
Chunk Format
Chunk Format

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

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

通常情况下 -- 3字节
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
Extended Timestamp

References:

rtmp_specification_1.0.pdf

上一篇 下一篇

猜你喜欢

热点阅读