rtmp视频包结构
类型 | 长度 | 值 |
---|---|---|
FrameType | 4bit | 1表示关键帧,2表示非关键帧,3表示一次性帧,4为服务器保留,5表示视频信息或命令帧 |
CodecID | 4bit | 1表示JPG,2表示Sorenson H263,3表示屏幕录像,4表示VP6 ON2,,5表示带alphat通道的VP6 ON2,6表示版本2的屏幕录像,7表示avc,即h264 |
VideoData | 视频数据,根据CodecID的不同,此处字段内容不同,例如CodecID为2时,此处为H263包结构,当CodecID为7时,此处为AVC视频包结构 |
实际使用当中,经常用的是发送h264或者h265的包
对于h265, CodecID为7,对于h265,一般扩展的CodecID都是12
因此,对于h264视频包来说,第一个字节一般是0x17或0x27,
对于h265, 第一个字节一般是0x1c或0x2c
对于VideoData
字段,当CodecID为7时,结构是AVC视频包
AVC视频包结构
类型 | 长度 | 值 |
---|---|---|
AVCPacketType | 8bit | 0表示AVC Sequence头,1表示nalu, 2一般不支持较低level的h264 |
Composition time | 3 byte | 如果AVCPacketType为1表示Composition time offset, 其他值是全为0 |
Data | n byte | 如果AVCPacketType为0,此处是AVCDecoderConfigurationRecord,如果AVCPacketType,此处是视频数据,如果AVCPacketType为2, 此处为空 |
明显的,前2个字段比较明确,Composition time一般都填0
下面看下AVCDecoderConfigurationRecord
h264 AVCDecoderConfigurationRecord
参数名 | 长度 | 值 |
---|---|---|
configureVersion | 1 byte | 版本号,默认为1 |
AVCProfileIndication | 1 byte | pr |