VideoMixer

Mixes multiple video inputs to a single output using ffmpeg filters.

Installation

def deps do
  [
    {:video_mixer, "~> 2.0.0"}
  ]
end

Usage

VideoMixer provides a safe, layout-driven filter graph generator. Inputs are named to avoid index mistakes, and mix/2 expects a keyword list keyed by those names.

specs = [
  primary: primary_spec,
  sidebar: sidebar_spec
]

{:ok, mixer} = VideoMixer.init(:primary_sidebar, specs, out_spec)

{:ok, output} = VideoMixer.mix(mixer, primary: primary_frame, sidebar: sidebar_frame)

Supported Layouts

Role Reference

Use these role keys for both specs and frames:

Custom Filter Graphs

You can bypass the layout generator and provide your own filter graph string with init_raw/4. This is useful for advanced ffmpeg graphs or nonstandard layouts.

filter_graph = {"[0:v]null[out]", [0]}
input_order = [:primary]

{:ok, mixer} = VideoMixer.init_raw(filter_graph, [primary_spec], input_order, out_spec)

{:ok, output} = VideoMixer.mix(mixer, primary: primary_frame)

Layout Options

primary_sidebar is intended for layouts where the main content should dominate and a secondary feed (like a sign interpreter or thumbnail speaker) sits on the side.

Layout Constraints

Compile-time Dependencies

macOS (Homebrew)

brew install ffmpeg pkg-config

Debian/Ubuntu

sudo apt-get update
sudo apt-get install -y ffmpeg pkg-config

Copyright and License

Copyright 2022, KIM Keep In Mind GmbH Licensed under the Apache License, Version 2.0