Timestamp:
Four-byte field that contains a timestamp of the message.
The 4 bytes are packed in the big-endian order.
【学习地址】:FFmpeg/WebRTC/RTMP/NDK/Android音视频流媒体高级开发
【文章福利】:免费领取更多音视频学习资料包、大厂面试题、技术视频和学习路线图,资料包括(C/C++,Linux,FFmpeg webRTC rtmp hls rtsp ffplay srs 等等)有需要的可以点击1079654574加群领取哦~
![]()
用wireshark转包分析发现,rtmp流的chunk视频流(或音频流)除第一个视频时间戳为绝对时间戳外,后续的时间戳均为timestamp delta,即当前时间戳与上一个时间戳的差值。
比如帧率为25帧/秒的视频流,timestamp delta基本上都为40ms。
通常情况下,Chunk的时间戳(包括绝对时间戳和Timestamp delta)是3个字节。
但时间戳值超过0xFFFFFF时,启用Extended Timestamp(4个字节)来表示时间戳。
三字节的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来表示时间戳。