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.
What a tag body is — VideoTagHeader+AVCVIDEOPACKET (§E.4.3),
AudioTagHeader+AACAUDIODATA (§E.4.2) and the onMetaData script body
(§E.4.1) — is defined beside this framing and re-exported here.
Structs§
- Audio
TagHeader - The
AudioTagHeader(§E.4.2) and, for AAC, the packet header of itsAACAUDIODATAbody (§E.4.2.2). - 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. - OnMetadata
- The informational properties an
onMetaDatascript tag states, typed. - Publish
Target target - The
appand stream key an RTMP publish URL names: the inverse ofcrate::target::RtmpTarget::tc_url. - 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. - Video
TagHeader - The
VideoTagHeader(§E.4.3) and, for the codecs that carry one, the packet header of itsVIDEODATAbody.
Enums§
- AacPacket
Type AACPacketTypeof an AACAACAUDIODATA(§E.4.2.2).- AvcPacket
Type AVCPacketTypeof an AVCAVCVIDEOPACKET(§E.4.3.2).- CodecId
- FLV video
CodecID(§E.4.3, Table E.5). - Frame
Type - FLV video
FrameType(§E.4.3, Table E.4). - Publish
Message - One message of the opening plan (RTMP §7.1.2, §7.1.4, §7.1.5).
- Publish
Track - One track a publish describes, as the opening messages state it.
- Resync
Decision - What an incremental caller should do with the bytes at the front of its
buffer — see
resync_decision. - Sound
Format SoundFormatof anAudioTagHeader(§E.4.2, Table E.6).- Sound
Rate SoundRateof anAudioTagHeader(§E.4.2, Table E.7).- Sound
Size SoundSizeof anAudioTagHeader(§E.4.2, Table E.8).- Sound
Type SoundTypeof anAudioTagHeader(§E.4.2, Table E.9).- 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§
- AAC_
PACKET_ DATA_ OFFSET - Byte offset of the raw AAC access unit (§E.4.2.2).
- AUDIO_
TAG_ HEADER_ LEN - Byte width of the
AudioTagHeader(§E.4.2):SoundFormat+SoundRate - AVC_
PACKET_ DATA_ OFFSET - Byte offset of the coded data after the
AVCVIDEOPACKETheader (§E.4.3.2). - COMPOSITION_
TIME_ MAX - Largest
CompositionTimerepresentable as the signed 24-bitSI24field (§E.4.3.2). - COMPOSITION_
TIME_ MIN - Smallest
CompositionTimerepresentable as the signed 24-bitSI24field (§E.4.3.2). - 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). - ON_
METADATA_ AUDIO_ CODEC_ ID_ AAC - FLV
audiocodecidfor AAC (=SoundFormat::Aac’s code, §E.4.2). - ON_
METADATA_ VIDEO_ CODEC_ ID_ AVC - FLV
videocodecidfor AVC (=CodecId::Avc’s code, §E.4.3). - SET_
DATA_ FRAME - The handler name RTMP publishers put before
onMetaData(§E.4.1; the FLV file form starts withonMetaDatadirectly). It addresses the server, not the FLV script tag. - VIDEO_
TAG_ HEADER_ LEN - Byte width of the
VideoTagHeader(§E.4.3):FrameType+CodecID.
Functions§
- publish_
open - The ordered messages a publisher sends between
publishand its first frame: the@setDataFrame/onMetaDatastream description, then every track’s sequence header, each at timestamp 0. - resync_
decision - Decide what to do with the bytes at the front of a streaming buffer, using
the same consistency rule
tags_resyncwalks with. - strip_
set_ data_ frame bodywithout a leading AMF0@setDataFramestring, so the FLV script tag begins withonMetaDataas §E.4.1 defines it.- 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.