View Source Xav.Reader (xav v0.10.0)

Audio/video file reader.

Summary

Functions

Creates a new audio/video reader.

The same as new/1 but raises on error.

Reads and decodes the next frame.

Seeks the reader to the given time in seconds

Creates a new reader stream.

Types

@type t() :: %Xav.Reader{
  bit_rate: integer(),
  codec: atom(),
  duration: integer(),
  framerate: {integer(), integer()} | nil,
  in_channels: integer() | nil,
  in_format: atom(),
  in_sample_rate: integer() | nil,
  out_channels: integer() | nil,
  out_format: atom(),
  out_sample_rate: integer() | nil,
  reader: reference()
}

Functions

@spec new(String.t(), Keyword.t()) :: {:ok, t()} | {:error, term()}

Creates a new audio/video reader.

Both reading from a file and from a video camera are supported. In case of using a video camera, the v4l2 driver is required, and FPS are locked to 10.

Microphone input is not supported.

The following options can be provided:

  • :read - The type of the stream to read from the input, either video or audio The default value is :video.

  • :device? (boolean/0) - Whether the path points to the camera The default value is false.

  • :out_format - The output format of the audio samples. It should be one of the following values: u8, s16, s32, s64, f32, f64.

    For video samples, it is always :rgb24.

  • :out_sample_rate (pos_integer/0) - The output sample rate of the audio samples

  • :out_channels (pos_integer/0) - The output number of channels of the audio samples

@spec new!(String.t(), Keyword.t()) :: t()

The same as new/1 but raises on error.

@spec next_frame(t()) :: {:ok, Xav.Frame.t()} | {:error, :eof}

Reads and decodes the next frame.

Link to this function

seek(reader, time_in_seconds)

View Source
@spec seek(t(), float()) :: :ok | {:error, term()}

Seeks the reader to the given time in seconds

Link to this function

stream!(path, opts \\ [])

View Source
@spec stream!(String.t(), Keyword.t()) :: Enumerable.t()

Creates a new reader stream.

Check new/1 for the available options.