Expand description
FLV (Flash Video) tag framing — Adobe Flash Video File Format Specification v10.1, Annex E: the file header of §E.2 and the tag of §E.4.1.
This is the one implementation of the FLV tag layer in the workspace (#2342): the
rtmp-runtime session engine hands its callers FLV bytes (RTMP Audio(8)/Video(9)/
Data-AMF0(18) message bodies are FLV tag bodies, Adobe RTMP 1.0 §7.1.4, §7.1.5,
§7.1.2), and transmux builds its FLV streams from the same values instead of a
second encoder. What a tag contains (codec headers, sequence headers, composition
time) is the caller’s business; this module only frames it.
§Layout (Annex E)
- Header (§E.2, 9 bytes) +
PreviousTagSize0(4 bytes, = 0):"FLV"signature,Version,TypeFlags(bit 0 audio, bit 2 video), and theDataOffset. - Tag (§E.4.1): an 11-byte header (
TagTypeUI8,DataSizeUI24,TimestampUI24 +TimestampExtendedUI8,StreamIDUI24 = 0), the body, and the UI32PreviousTagSize(11 +DataSize).
Spec: private/specs-verified/rtmp/rtmp-runtime/rtmp.md sections 6.6 and 9.
Structs§
- FlvHeader
- The FLV file header (§E.2), including the
PreviousTagSize0that always follows it. - FlvTag
- One FLV tag (§E.4.1): its header fields, body, and the
PreviousTagSizethat follows it, so a single value is a self-contained slice of an FLV stream. - FlvTag
Header - The 11-byte tag header of a tag whose body may not have arrived yet
(§E.4.1):
TagType,DataSize,Timestamp+TimestampExtendedandStreamID, without the body — what an incremental reader needs to know how many bytes the whole tag takes before it can decode one. - Resync
Walk - An FLV stream walked tolerantly: every tag, the damaged spans skipped, and
whether the input ended on a short tail — see
tags_resync. - Tags
- Iterator over an FLV stream’s tags — see
tags.
Enums§
- TagType
- FLV tag
TagType(§E.4.1), carrying the RTMP message type ids of a media tag: Audio (8), Video (9) and Data-AMF0 (18) are the same three values in both formats (RTMP §7.1.4, §7.1.5, §7.1.2).
Constants§
- FLV_
DATA_ OFFSET - The
DataOffsetthis crate writes: the header is exactlyFLV_HEADER_LENbytes (§E.2). - FLV_
FLAG_ AUDIO TypeFlagsbit 0 — audio tags present (§E.2).- FLV_
FLAG_ VIDEO TypeFlagsbit 2 — video tags present (§E.2).- FLV_
HEADER_ LEN - Byte width of the file header’s fixed part (§E.2):
Signature(3) +Version(1) +TypeFlags(1) +DataOffset(4). - FLV_
PREV_ TAG_ SIZE_ LEN - Byte width of the
PreviousTagSize0field that follows the file header (§E.2) and of thePreviousTagSizefield after every tag (§E.4.1). - FLV_
SIGNATURE - FLV file header
Signaturefield (§E.2):"FLV". - FLV_
STREAM_ ID StreamIDvalue of every tag this crate writes (§E.4.1).- FLV_
TAG_ HEADER_ LEN - Byte width of one tag’s fixed header (§E.4.1):
TagType(1) +DataSize(3) +Timestamp(3) +TimestampExtended(1) +StreamID(3). - FLV_
TIMESTAMP_ EXTENDED_ SHIFT - Bit position of
TimestampExtended, which carries the top 8 bits of the tag’s 32-bit millisecondTimestamp(§E.4.1). - FLV_
VERSION - FLV file header
Versionfield this crate writes (§E.2).
Functions§
- tags
- The tags of an FLV stream, in order, starting at
header’s first tag. - tags_
resync - Walk an FLV stream’s tags tolerantly, from
header’s first tag.