All multi-byte numbers in FLV are big-endian. Adobe’s specification, version 10.1, is published only as a PDF, which this reference did not open; the fields here are checked against the Enhanced RTMP specification and other public descriptions, and the one detail that could not be checked is marked.
File header
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 3 | UI8[3] | Signature | FLV. |
| 3 | 1 | UI8 | Version | 1. |
| 4 | 1 | UI8 | Flags | Bit 0x04: audio tags are present. Bit 0x01: video tags are present. The other bits are reserved and zero. |
| 5 | 4 | UI32 | DataOffset | Size of this header, 9. A reader uses it to skip a larger header in some future version. |
File body
After the header, the file alternates a 32-bit size and a tag.
PreviousTagSize0 is 0. Each later PreviousTagSize is the
size of the tag before it, including its 11-byte header, so a reader can walk the file
backwards.
Tag header
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 1 | UI8 | TagType | The type; see below. |
| 1 | 3 | UI24 | DataSize | Size of the data after this header. |
| 4 | 3 | UI24 | Timestamp | Time in milliseconds, the lower 24 bits. |
| 7 | 1 | UI8 | TimestampExtended | The upper 8 bits of the timestamp, making 32 bits. |
| 8 | 3 | UI24 | StreamID | Always 0. |
| 11 | DataSize | Data | The tag’s contents. |
| TagType | Contents |
|---|---|
| 8 | Audio |
| 9 | Video |
| 18 | Script data, AMF-encoded, usually onMetaData |
Unconfirmed: from memory of Adobe’s document, version 10 of the specification uses the
top two bits of TagType as reserved and the next as a filter flag for
encrypted content. Only the three types above occur in ordinary files. Wikipedia also
lists types used by RTMP control messages (1, 3, 15) and encapsulated video (24).
Worked example
The first 13 bytes of a file with audio and video:
| Bytes | Meaning |
|---|---|
46 4C 56 | FLV |
01 | Version 1 |
05 | Audio (04) and video (01) |
00 00 00 09 | Header size 9 |
00 00 00 00 | PreviousTagSize0 |