RTMP.FLV.VideoTag (rtmp v0.1.0)

Copy Markdown View Source

Parses the body of an RTMP video message (an FLV video tag body).

H.264 (FLV codec id 7) is parsed:

  • The sequence header's AVCDecoderConfigurationRecord is decoded into %{profile: ..., compatibility: ..., level: ..., nalu_length_size: ..., sps: [binary], pps: [binary]}.
  • Media frames carry their composition time offset and are split into NAL units, using the NALU length size from the most recent sequence header (4 until one arrives).
  • End-of-sequence packets are skipped.

Other legacy FLV video codecs (Sorenson H.263, VP6, Screen Video, ...) are passed through unparsed. Video info/command frames (frame type 5) are skipped.

Enhanced RTMP video (the IsExHeader bit — HEVC, AV1, VP9 via FourCC) is not supported and is reported as {:unsupported, reason} so the connection can reject it cleanly.

Summary

Functions

Parses a video message payload into RTMP.Frame fields.

Decodes an AVCDecoderConfigurationRecord (ISO 14496-15, 5.2.4.1).

Splits length-prefixed (AVCC) NAL units. size is the prefix length in bytes.

Types

result()

@type result() :: {:ok, map()} | :skip | {:error, term()} | {:unsupported, term()}

Functions

parse(payload, nalu_length_size \\ 4)

@spec parse(binary(), 1..4) :: result()

Parses a video message payload into RTMP.Frame fields.

nalu_length_size is the length-prefix size from the stream's current AVCDecoderConfigurationRecord.

parse_avc_decoder_config(arg1)

@spec parse_avc_decoder_config(binary()) :: {:ok, map()} | {:error, term()}

Decodes an AVCDecoderConfigurationRecord (ISO 14496-15, 5.2.4.1).

split_nalus(data, size)

@spec split_nalus(binary(), 1..4) ::
  {:ok, [binary()]} | {:error, :invalid_nalu_length}

Splits length-prefixed (AVCC) NAL units. size is the prefix length in bytes.