ExFLV.Tag.VideoData.AVC (FLV muxer and demuxer v0.4.0)
View SourceModule describing an AVCVIDEOPACKET tag.
Summary
Types
@type packet_type() :: :sequence_header | :nalu | :end_of_sequence
@type t() :: %ExFLV.Tag.VideoData.AVC{ composition_time: integer(), data: iodata(), packet_type: packet_type() }
Functions
@spec new(iodata(), packet_type(), integer()) :: t()
Creates a new AVCVIDEOPACKET tag.
Examples
iex> ExFLV.Tag.VideoData.AVC.new(<<1, 2, 3>>, :nalu, 0)
%ExFLV.Tag.VideoData.AVC{
packet_type: :nalu,
composition_time: 0,
data: <<1, 2, 3>>
}
Parses the binary into an AVCVIDEOPACKET tag.
iex> ExFLV.Tag.VideoData.AVC.parse(<<1, 0, 0, 0, 1, 2, 3>>)
{:ok,
%ExFLV.Tag.VideoData.AVC{
packet_type: :nalu,
composition_time: 0,
data: <<1, 2, 3>>
}}
iex> ExFLV.Tag.VideoData.AVC.parse(<<0, 0, 0, 0, 4, 5, 6>>)
{:ok,
%ExFLV.Tag.VideoData.AVC{
packet_type: :sequence_header,
composition_time: 0,
data: <<4, 5, 6>>
}}
iex> ExFLV.Tag.VideoData.AVC.parse(<<2, 255, 255, 255>>)
{:ok,
%ExFLV.Tag.VideoData.AVC{
packet_type: :end_of_sequence,
composition_time: -1,
data: ""
}}
iex> ExFLV.Tag.VideoData.AVC.parse(<<3, 0, 0, 0, 7, 8, 9>>)
{:error, :invalid_data}
Same as parse/1 but raises on error.
iex> ExFLV.Tag.VideoData.AVC.parse!(<<1, 0, 0, 0, 1, 2, 3>>)
%ExFLV.Tag.VideoData.AVC{
packet_type: :nalu,
composition_time: 0,
data: <<1, 2, 3>>
}