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.

Structs§

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.
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.

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 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).

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.