View Source Membrane.RawVideo (Membrane: Raw video format v0.3.0)

This module provides a struct (Membrane.RawVideo.t/0) describing raw video frames.

Link to this section Summary

Types

Determines, whether buffers are aligned i.e. each buffer contains one frame.

Number of frames per second. To avoid using floating point numbers, it is described by 2 integers number of frames per timeframe in seconds.

Height of single frame in pixels.

Format used to encode the color of every pixel in each video frame.

t()

Width of single frame in pixels.

Functions

Simple wrapper over frame_size/3. Returns the size of raw video frame in bytes for the given caps.

Returns the size of raw video frame in bytes (without padding).

Convert back a native raw video to the Membrane.RawVideo counterpart.

Creates unifex-compatible struct from Membrane.RawVideo struct. Raises an error when RawVideo with an unsupported pixel format is provided.

Link to this section Types

@type aligned_t() :: boolean()

Determines, whether buffers are aligned i.e. each buffer contains one frame.

@type framerate_t() :: {frames :: non_neg_integer(), seconds :: pos_integer()}

Number of frames per second. To avoid using floating point numbers, it is described by 2 integers number of frames per timeframe in seconds.

For example, NTSC's framerate of ~29.97 fps is represented by {30_000, 1001}

@type height_t() :: pos_integer()

Height of single frame in pixels.

@type pixel_format_t() ::
  :I420
  | :I422
  | :I444
  | :RGB
  | :BGRA
  | :RGBA
  | :NV12
  | :NV21
  | :YV12
  | :AYUV
  | :YUY2

Format used to encode the color of every pixel in each video frame.

@type t() :: %Membrane.RawVideo{
  aligned: aligned_t(),
  framerate: framerate_t(),
  height: height_t(),
  pixel_format: pixel_format_t(),
  width: width_t()
}
@type width_t() :: pos_integer()

Width of single frame in pixels.

Link to this section Functions

@spec frame_size(t()) :: {:ok, pos_integer()} | {:error, reason}
when reason: :invalid_dimensions | :invalid_pixel_format

Simple wrapper over frame_size/3. Returns the size of raw video frame in bytes for the given caps.

Link to this function

frame_size(format, width, height)

View Source
@spec frame_size(pixel_format_t(), width_t(), height_t()) ::
  {:ok, pos_integer()} | {:error, reason}
when reason: :invalid_dimensions | :invalid_pixel_format

Returns the size of raw video frame in bytes (without padding).

It may result in error when dimensions don't fulfill requirements for the given format (e.g. I420 requires both dimensions to be divisible by 2).

Link to this function

from_native_raw_video(native_raw_video)

View Source
@spec from_native_raw_video(Membrane.Native.RawVideo.t()) :: t()

Convert back a native raw video to the Membrane.RawVideo counterpart.

Link to this function

to_native_raw_video(membrane_raw_video)

View Source
@spec to_native_raw_video(t()) :: Membrane.Native.RawVideo.t()

Creates unifex-compatible struct from Membrane.RawVideo struct. Raises an error when RawVideo with an unsupported pixel format is provided.