View Source Membrane.FFmpeg.SWScale.Converter (Membrane FFmpeg SWScale plugin v0.16.2)

This element performs video scaling and conversion between pixel formats of raw video, using SWScale module of FFmpeg library.

Following options that can be specified when creating Scaler:

  • format - desired pixel format of the output video.
  • output_width - desired scaled video width. Needs to be an even number.
  • output_height - desired scaled video height. Needs to be an even number.
  • use_shm? - indicator if native scaler will use shared memory (via Shmex.t/0) for storing frames. Default to false.

Only the following pixel formats are supported, both as input and output:

  • I420
  • I422
  • I444
  • RGB
  • BGRA
  • RGBA
  • NV12
  • NV21
  • AYUV
  • YUY2

If format is not specyfied, output video will have the same format as input.

If neither output_width nor output_height is specyfied, video frames will not be scaled.

If only one dimension is specified (either output_width or output_height), the other dimension is calculated on handle_stream_format callback based on input dimensions.

Scaling consists of two operations:

  • scaling itself - resizing video frame with keeping original ratio. After that operation at least one of the dimensions of the input frame match the respective dimension of the desired output size. The second one (if does not match) is smaller than its respective dimension.
  • adding paddings - if one dimension does not match after scaling, paddings have to be added. They are put on both sides of the scaled frame equally. They are either above and below the frame or on the left and right sides of it. It depends on the dimension that did not match after scaling.

Membrane.FFmpeg.SWScale.Converter requires getting stream format with input video width and height. To meet all requirements either Membrane.Element.RawVideo.Parser or some decoder (e.g. Membrane.H264.FFmpeg.Decoder) have to precede Membrane.FFmpeg.SWScale.Converter in the pipeline.

Element options

Passed via struct Membrane.FFmpeg.SWScale.Converter.t/0

  • output_width

    non_neg_integer() | nil

    Default value: nil
    Width of the scaled video.

  • output_height

    non_neg_integer() | nil

    Default value: nil
    Height of the scaled video.

  • use_shm?

    boolean()

    Default value: false
    If true, native scaler will use shared memory (via Shmex.t/0) for storing frames

  • format

    RawVideo.pixel_format() | nil

    Default value: nil
    Desired pixel format of output video.

Pads

:input

Accepted formats:

%RawVideo{aligned: true, pixel_format: pixel_format} when pixel_format in @supported_pixel_formats
Direction::input
Availability::always
Flow control::auto

:output

Accepted formats:

%RawVideo{aligned: true, pixel_format: pixel_format} when pixel_format in @supported_pixel_formats
Direction::output
Availability::always
Flow control::auto

Summary

Types

t()

Struct containing options for Membrane.FFmpeg.SWScale.Converter

Functions

Returns description of options available for this module

Types

@type t() :: %Membrane.FFmpeg.SWScale.Converter{
  format: Membrane.RawVideo.pixel_format() | nil,
  output_height: non_neg_integer() | nil,
  output_width: non_neg_integer() | nil,
  use_shm?: boolean()
}

Struct containing options for Membrane.FFmpeg.SWScale.Converter

Functions

@spec options() :: keyword()

Returns description of options available for this module