Skip to main content

Module flv

Module flv 

Source
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 the DataOffset.
  • Tag (§E.4.1): an 11-byte header (TagType UI8, DataSize UI24, Timestamp UI24 + TimestampExtended UI8, StreamID UI24 = 0), the body, and the UI32 PreviousTagSize (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§

AudioTagHeader
The AudioTagHeader (§E.4.2) and, for AAC, the packet header of its AACAUDIODATA body (§E.4.2.2).
FlvHeader
The FLV file header (§E.2), including the PreviousTagSize0 that always follows it.
FlvTag
One FLV tag (§E.4.1): its header fields, body, and the PreviousTagSize that follows it, so a single value is a self-contained slice of an FLV stream.
FlvTagHeader
The 11-byte tag header of a tag whose body may not have arrived yet (§E.4.1): TagType, DataSize, Timestamp + TimestampExtended and StreamID, 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 onMetaData script tag states, typed.
PublishTargettarget
The app and stream key an RTMP publish URL names: the inverse of crate::target::RtmpTarget::tc_url.
ResyncWalk
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.
VideoTagHeader
The VideoTagHeader (§E.4.3) and, for the codecs that carry one, the packet header of its VIDEODATA body.

Enums§

AacPacketType
AACPacketType of an AAC AACAUDIODATA (§E.4.2.2).
AvcPacketType
AVCPacketType of an AVC AVCVIDEOPACKET (§E.4.3.2).
CodecId
FLV video CodecID (§E.4.3, Table E.5).
FrameType
FLV video FrameType (§E.4.3, Table E.4).
PublishMessage
One message of the opening plan (RTMP §7.1.2, §7.1.4, §7.1.5).
PublishTrack
One track a publish describes, as the opening messages state it.
ResyncDecision
What an incremental caller should do with the bytes at the front of its buffer — see resync_decision.
SoundFormat
SoundFormat of an AudioTagHeader (§E.4.2, Table E.6).
SoundRate
SoundRate of an AudioTagHeader (§E.4.2, Table E.7).
SoundSize
SoundSize of an AudioTagHeader (§E.4.2, Table E.8).
SoundType
SoundType of an AudioTagHeader (§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 AVCVIDEOPACKET header (§E.4.3.2).
COMPOSITION_TIME_MAX
Largest CompositionTime representable as the signed 24-bit SI24 field (§E.4.3.2).
COMPOSITION_TIME_MIN
Smallest CompositionTime representable as the signed 24-bit SI24 field (§E.4.3.2).
FLV_DATA_OFFSET
The DataOffset this crate writes: the header is exactly FLV_HEADER_LEN bytes (§E.2).
FLV_FLAG_AUDIO
TypeFlags bit 0 — audio tags present (§E.2).
FLV_FLAG_VIDEO
TypeFlags bit 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 PreviousTagSize0 field that follows the file header (§E.2) and of the PreviousTagSize field after every tag (§E.4.1).
FLV_SIGNATURE
FLV file header Signature field (§E.2): "FLV".
FLV_STREAM_ID
StreamID value 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 millisecond Timestamp (§E.4.1).
FLV_VERSION
FLV file header Version field this crate writes (§E.2).
ON_METADATA_AUDIO_CODEC_ID_AAC
FLV audiocodecid for AAC (= SoundFormat::Aac’s code, §E.4.2).
ON_METADATA_VIDEO_CODEC_ID_AVC
FLV videocodecid for 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 with onMetaData directly). 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 publish and its first frame: the @setDataFrame/onMetaData stream 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_resync walks with.
strip_set_data_frame
body without a leading AMF0 @setDataFrame string, so the FLV script tag begins with onMetaData as §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.