View Source Xav.Decoder (xav v0.6.0)
Audio/video decoder.
Summary
Types
@type codec() :: :opus | :vp8
Supported codecs.
@type opts() :: [ out_format: Xav.Frame.format(), out_sample_rate: integer(), out_channels: integer() ]
Opts that can be passed to new/2
.
@type t() :: reference()
Functions
@spec decode(t(), binary(), pts: integer(), dts: integer()) :: :ok | {:ok, Xav.Frame.t()} | {:error, atom()}
Decodes an audio/video frame.
Some video frames are meant for decoder only and will not
contain actual video samples.
Some audio frames might require more data to be converted
to the desired output format.
In both cases, :ok
term is returned and more data needs to be provided.
Creates a new decoder.
opts
can be used to specify desired output parameters.
E.g. if you want to change audio samples format just pass:
[out_format: :f32]
Video frames are always returned in RGB format. This setting cannot be changed.
Audio samples are always in the packed form - samples from different channels are interleaved in the same, single binary:
<<c10, c20, c30, c11, c21, c31, c12, c22, c32>>
An alternative would be to return a list of binaries, where each binary represents different channel:
[
<<c10, c11, c12, c13, c14>>,
<<c20, c21, c22, c23, c24>>,
<<c30, c31, c32, c33, c34>>
]