ExFLV.Tag.ExVideoData (FLV muxer and demuxer v0.4.0)

View Source

Module describing an FLV enhanced video data tag.

Summary

Functions

Parses the binary into an ExVideoTag tag.

Same as parse/1 but raises on error.

Types

codec_id()

@type codec_id() :: :h264 | :h265 | :vp8 | :vp9 | :av1

packet_type()

@type packet_type() ::
  :sequence_start
  | :coded_frames
  | :sequence_end
  | :coded_frames_x
  | :metadata
  | :mpeg2_ts_sequence_start
  | :multi_track
  | :mod_ex

t()

@type t() :: %ExFLV.Tag.ExVideoData{
  codec_id: codec_id(),
  composition_time_offset: integer(),
  data: iodata(),
  frame_type: ExFLV.Tag.VideoData.frame_type(),
  packet_type: packet_type()
}

Functions

parse(arg1)

@spec parse(binary()) :: {:ok, t()} | {:error, :invalid_tag}

Parses the binary into an ExVideoTag tag.

iex> ExFLV.Tag.ExVideoData.parse(<<144, 104, 118, 99, 49, 1, 2, 3, 4, 5>>)
{:ok,
%ExFLV.Tag.ExVideoData{
  frame_type: :keyframe,
  packet_type: :sequence_start,
  codec_id: :h265,
  composition_time_offset: 0,
  data: <<1, 2, 3, 4, 5>>
}}

iex> ExFLV.Tag.ExVideoData.parse(<<161, 97, 118, 99, 49, 255, 255, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255>>)
{:ok,
%ExFLV.Tag.ExVideoData{
  frame_type: :interframe,
  packet_type: :coded_frames,
  codec_id: :h264,
  composition_time_offset: -10,
  data: <<0, 0, 0, 0, 0, 0, 0, 0, 0, 255>>
}}

iex> ExFLV.Tag.ExVideoData.parse(<<163, 97, 118, 99, 49, 1, 2, 3, 4>>)
{:ok,
%ExFLV.Tag.ExVideoData{
  frame_type: :interframe,
  packet_type: :coded_frames_x,
  codec_id: :h264,
  composition_time_offset: 0,
  data: <<1, 2, 3, 4>>
}}

iex> ExFLV.Tag.ExVideoData.parse(<<150, 97, 118, 48>>)
{:error, :invalid_tag}

iex> ExFLV.Tag.ExVideoData.parse(<<150, 97, 118, 48, 49>>)
{:error, :invalid_tag}

parse!(data)

@spec parse!(binary()) :: t()

Same as parse/1 but raises on error.

iex> ExFLV.Tag.ExVideoData.parse!(<<144, 104, 118, 99, 49, 1, 2, 3, 4, 5>>)
%ExFLV.Tag.ExVideoData{
  frame_type: :keyframe,
  packet_type: :sequence_start,
  codec_id: :h265,
  composition_time_offset: 0,
  data: <<1, 2, 3, 4, 5>>
}