Mixes multiple video inputs to a single output using ffmpeg filters.
def deps do
[
{:video_mixer, "~> 2.0.0"}
]
endVideoMixer 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):single_fit(roles:primary):hstack(roles:left,right):vstack(roles:top,bottom):xstack(roles:top_left,top_right,bottom_left,bottom_right):primary_sidebar(roles:primary,sidebar)
Use these role keys for both specs and frames:
:single_fit→primary:hstack→left,right:vstack→top,bottom:xstack→top_left,top_right,bottom_left,bottom_right:primary_sidebar→primary,sidebar
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)pixel_format(defaults to:I420)
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.
- Output dimensions must be even for all layouts (required by
:I420). :hstackrequires output width divisible by 2.:vstackrequires output height divisible by 2.:xstackrequires output width and height divisible by 2.:primary_sidebarsplits output width into 2/3 + 1/3, both even; widths that can’t be evenly split will be rejected.
- ffmpeg >= 6.0 (libraries:
libavfilter,libavutil) pkg-config(used to locate ffmpeg headers and libs)
brew install ffmpeg pkg-configsudo apt-get update
sudo apt-get install -y ffmpeg pkg-configCopyright 2022, KIM Keep In Mind GmbH Licensed under the Apache License, Version 2.0