VideoMixer (video_mixer v2.1.5)

View Source

Summary

Functions

Initializes the mixer using a constrained layout with safe defaults.

Initializes the mixer with a custom filter graph.

Types

filter_graph_t()

@type filter_graph_t() :: {String.t(), [non_neg_integer()]}

input_name()

@type input_name() :: atom()

spec_mapping_t()

@type spec_mapping_t() :: [VideoMixer.FrameSpec.t()]

t()

@type t() :: %VideoMixer{
  filter_indexes: [non_neg_integer()],
  input_order: [input_name()],
  mapping: spec_mapping_t(),
  ref: reference()
}

Functions

init(layout, specs_by_role, output_frame_spec, opts \\ [])

Initializes the mixer using a constrained layout with safe defaults.

init_raw(arg, mapping, input_order, output_frame_spec)

@spec init_raw(
  filter_graph_t(),
  spec_mapping_t(),
  [input_name()],
  VideoMixer.FrameSpec.t()
) ::
  {:ok, t()} | {:error, VideoMixer.Error.t()}

Initializes the mixer with a custom filter graph.

Filter graph gotchas

  • Each input becomes a buffersrc labelled [i:v] (0-indexed in input_order). The terminal pad must be labelled [out].

  • Input buffersrcs are configured with time_base=1/1, i.e. PTS is in seconds. Time-driven filters such as fade=st=…:d=… will interpret PTS in seconds, which rarely matches the upstream timing. Pre-bake animations into the input frames instead of relying on time-based filters.

  • Some filters parse their format option as an enum alias rather than as a pixel-format string. The overlay filter is the canonical example: use overlay=...:format=yuv420 (enum), not format=yuv420p (pix_fmt string). format as a standalone filter (e.g. [1:v]format=yuva420p[ovl]) does take pix_fmt strings.

  • Supported input/output pixel_format values are :I420, :I422, :I444, :RGBA, and :BGRA. RGBA/BGRA are useful as overlay sources with alpha; convert to a YUV planar format inside the graph (e.g. format=yuva420p) before feeding overlay.

mix(video_mixer, frames_by_name)

@spec mix(t(), keyword(VideoMixer.Frame.t()) | map()) ::
  {:ok, binary()} | {:error, VideoMixer.Error.t()}