RTMP allows connection to multiples message in chunks. Each chunk has a unique chunk stream id so that receiver can use this id to reassemble the chunk into message.
Chunk size is configurable with maximum 65536 and minimum 128 bytes in size.
In general, chunk has the following format
The Basic Header is 1 to 3 bytes
fmt field is important to identify the chunk message header format to be use. There are 4 types of chunk message header format
Type 0 is 11 bytes long. It must be used for start of the chunk stream.
Type 1 is 7 bytes long. This should be used for message that have variable message size (ie, video data) after Type 0 message is sent.
Type 2 is 3 bytes long. This should be used for message that have fix message size (ie, audio and data) after Type 0 message is sent.
Type 3 has no header. This should be used when message a split into multiple chunks. For example, message with same timestamp after Type 0 and message with same id, size and timestamp.
The field description is as follow. Specifically, you should take note that message stream id is stored in Little Endian format. Also, timestamp is in millisecond.
Extended timestamp is used only when timestamp in chunk message header is set to 0x00FFFFFF. The usage of this field is to handle timestamp that is larger than 0xFFFFFF. If timestamp is larger than 0xFFFFFF, a 4 bytes extended timestamp should be used
Reference: Adobe Official RTMP Specification