Compose video and audio
A compositor combines decoded media from named inputs. The compositor decodes its inputs itself, so they can be sources or transcoders;
a transcoder in front can produce raw video (wrapped_avframe) first, and one after
it encodes the composed output. Follow the task graph and
filter reference for the full structure.
Start with a video grid
Download video-grid.toml. Use the
quickstart fixture and Docker mounts, replacing its config
with this file. It reads the same fixture twice so no external input is needed,
scales each input to 320 pixels wide, and uses xstack to place them side by
side. The expected output is a 640×180 H.264 video-only SRT stream.
Connect a receiver as described in the quickstart.
To use different inputs, change the two source URLs and keep the desired sizes
and frame rates compatible. The node's source_ids refer to compositor input
IDs (left-frame, right-frame); each input's source_id refers to an upstream
task (left-decode, right-decode). Downstream encoders read the compositor ID.
# Vindral Bridge Packager example
# Two copies of a file side by side, sent over SRT.
version = "3"
[[sources]]
id = "left"
source_type = "file"
realtime_pacing = true
protocol_options = { url = "/media/input.mp4" }
[[transcoders]]
id = "left-decode"
source_ids = ["left"]
device = "cpu"
[[transcoders.tracks]]
id = "left-video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[transcoders.tracks.renditions]]
id = "left-raw"
codec = "wrapped_avframe"
format = "yuv420p"
size = { width = 320 }
[[sources]]
id = "right"
source_type = "file"
realtime_pacing = true
protocol_options = { url = "/media/input.mp4" }
[[transcoders]]
id = "right-decode"
source_ids = ["right"]
device = "cpu"
[[transcoders.tracks]]
id = "right-video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[transcoders.tracks.renditions]]
id = "right-raw"
codec = "wrapped_avframe"
format = "yuv420p"
size = { width = 320 }
[[compositors]]
id = "grid"
[[compositors.video.sources]]
id = "left-frame"
source_id = "left-decode"
track_selector = { type = "track-kind", kind = "video" }
[[compositors.video.sources]]
id = "right-frame"
source_id = "right-decode"
track_selector = { type = "track-kind", kind = "video" }
[[compositors.video.nodes]]
id = "layout"
type = "xstack"
source_ids = ["left-frame", "right-frame"]
grid = "2x1"
[[transcoders]]
id = "encode"
source_ids = ["grid"]
device = "cpu"
[[transcoders.tracks]]
id = "grid-video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[transcoders.tracks.renditions]]
id = "h264"
codec = "h264"
encoder_name = "libx264"
bit_rate = 800_000
gop_size_ms = 1000
[[sinks]]
id = "srt"
sink_type = "srt"
source_ids = ["encode"]
wait_for_all_sources = true
protocol_options = { url = "srt://0.0.0.0:10000?mode=listener&latency=120000" }
Overlay and mix
The complete browser overlay recipe
contains NVIDIA and CPU guidance. For a complete local CPU example, download
browser-overlay-cpu.toml
and the overlay page. Save the page
as media/overlay.html, use the quickstart MP4 as media/input.mp4, and mount
media as in the quickstart. Select a CEF-enabled image.
The browser source refuses file:// pages by default (see
Network access from browser pages). For this local
test, add -e VINDRAL_BROWSER_UNRESTRICTED_NETWORK=1 to the docker run command. In
production, leave the restriction on and serve the page from a public https:// URL.
The SRT output contains base video with a clock graphic, base audio, and a quieter 880 Hz browser tone. Connect the quickstart receiver to watch it. The page is local so its availability does not depend on a public demonstration service.
For transparency, preserve alpha in the overlay input (yuva420p for the CPU
path) and use the CPU overlay's format = "auto". Encode the final output in a
format the destination supports. The overlay_cuda NVIDIA node has a separate
configuration; it blends in 8-bit yuv420p and outputs 8-bit video. On Intel GPUs, the overlay_qsv node blends the overlay without
leaving GPU memory; see Browser overlay on QSV.
amix adds signals together. Its first source is the timing master; subsequent
inputs are resampled to follow it. Weights follow source_ids order; when
provided, their count must match the source count. normalize = false preserves
the specified levels, so added inputs can clip. amerge combines channels
rather than mixing them into the same channels. channelmap reorders, drops,
duplicates or relabels the channels of a single input, for example
map = ["FR-FL", "FL-FR"] to swap left and right; see the
audio filter reference. Use volume nodes when an
individual branch needs live gain adjustment.
# Vindral Bridge Packager example
# A browser overlay on a file, composited on the CPU and sent over SRT.
version = "3"
[logging]
level = "debug"
[[sources]]
id = "main"
source_type = "file"
realtime_pacing = true
[sources.protocol_options.url]
type = "string"
value = "/media/input.mp4"
[[sources]]
id = "browser-overlay"
source_type = "browser"
# file:// pages load only when the container runs with
# VINDRAL_BROWSER_UNRESTRICTED_NETWORK=1 (local testing only). In production,
# serve the page from a public https:// URL.
[sources.protocol_options.url]
type = "string"
value = "file:///media/overlay.html"
[sources.demuxer_options.width]
type = "u_int"
value = 450
[sources.demuxer_options.height]
type = "u_int"
value = 450
[sources.demuxer_options.transparent_background]
type = "bool"
value = true
[sources.demuxer_options.frame_rate]
type = "u_int"
value = 30
[sources.demuxer_options.startup_delay_ms]
type = "u_int"
value = 500
# Enable audio capture from the browser page. The source will emit both a
# video stream (stream 0) and an audio stream (stream 1).
[sources.demuxer_options.audio_capture]
type = "bool"
value = true
[[transcoders]]
id = "main-decoder"
source_ids = ["main"]
device = "cpu"
[[transcoders.tracks]]
type = "video"
id = "main-video"
[transcoders.tracks.track_selector]
type = "track-kind"
kind = "video"
[[transcoders.tracks.renditions]]
id = "main-raw"
codec = "wrapped_avframe"
gop_size_ms = 1000
bit_rate = 400_000
format = "yuv420p"
[[transcoders.tracks]]
type = "audio"
id = "main-audio"
passthrough = true
[transcoders.tracks.track_selector]
type = "track-kind"
kind = "audio"
[[transcoders]]
id = "overlay-decoder"
source_ids = ["browser-overlay"]
device = "cpu"
[[transcoders.tracks]]
type = "video"
id = "overlay-video"
[transcoders.tracks.processing]
hw_filtering_enabled = false
[transcoders.tracks.track_selector]
type = "track-kind"
kind = "video"
[[transcoders.tracks.renditions]]
id = "overlay-raw"
codec = "wrapped_avframe"
gop_size_ms = 1000
bit_rate = 400_000
format = "yuva420p"
# Pass the browser audio through this task unchanged so it travels alongside
# the decoded video under source_id "overlay-decoder".
[[transcoders.tracks]]
type = "audio"
id = "overlay-audio"
passthrough = true
[transcoders.tracks.track_selector]
type = "track-kind"
kind = "audio"
[[transcoders]]
id = "transcoder"
source_ids = ["compositor"]
device = "cpu"
[[transcoders.tracks]]
type = "video"
id = "output-video"
[transcoders.tracks.track_selector]
type = "track-kind"
kind = "video"
[[transcoders.tracks.renditions]]
id = "h264-output"
codec = "h264"
gop_size_ms = 1000
bit_rate = 1_200_000
[transcoders.tracks.renditions.size]
scale_factor = 1.0
[[transcoders]]
id = "audio-transcoder"
source_ids = ["compositor"]
device = "cpu"
[[transcoders.tracks]]
type = "audio"
id = "mixed-audio"
[transcoders.tracks.track_selector]
type = "track-kind"
kind = "audio"
[[transcoders.tracks.renditions]]
id = "aac-output"
codec = "aac"
bit_rate = 128_000
[[compositors]]
id = "compositor"
[[compositors.video.sources]]
id = "base"
source_id = "main-decoder"
[compositors.video.sources.track_selector]
type = "track-kind"
kind = "video"
[[compositors.video.sources]]
id = "overlay"
source_id = "overlay-decoder"
[compositors.video.sources.track_selector]
type = "track-kind"
kind = "video"
[[compositors.video.nodes]]
type = "overlay"
id = "browser-overlay"
source_ids = ["base", "overlay"]
x = "20"
y = "20"
format = "auto"
output_format = "yuv420p"
# Mix base audio (timing master, weight=1.0) with browser audio (weight=0.3).
# The base audio is passed through untouched; the browser audio is
# async-resampled to the base audio's clock and rate. normalize=false keeps
# the base audio at its true level.
[[compositors.audio.sources]]
id = "base-audio"
source_id = "main-decoder"
[compositors.audio.sources.track_selector]
type = "track-kind"
kind = "audio"
[[compositors.audio.sources]]
id = "browser-audio"
source_id = "overlay-decoder"
[compositors.audio.sources.track_selector]
type = "track-kind"
kind = "audio"
[[compositors.audio.nodes]]
type = "amix"
id = "audio-mix"
source_ids = ["base-audio", "browser-audio"]
weights = [1.0, 0.3]
normalize = false
[[sinks]]
id = "srt"
sink_type = "srt"
source_ids = ["transcoder", "audio-transcoder"]
wait_for_all_sources = true
protocol_options = { url = "srt://0.0.0.0:10000?mode=listener&latency=120000" }
Network access from browser pages
A browser source loads only http:// and https:// page URLs. file:// URLs are refused
at start with browser source URL must be http or https; javascript:, data: and
chrome: page URLs are always refused. Inside the page, requests may use http, https,
ws, wss, data, blob and about.
All page traffic goes through a proxy in the Packager that resolves names itself and refuses connections to:
- loopback, private, link-local (including cloud metadata), CGNAT, multicast and other non-global addresses, IPv4 and IPv6
- the host's own interface addresses
- addresses owned by the first network hop (not probed by default on hosts with a public IPv4 address; see
VINDRAL_BROWSER_FIRST_HOP_PROBE) - networks listed in
VINDRAL_BROWSER_DENIED_NETWORKS
A page on localhost or on a LAN server is therefore blocked; serve overlay pages from a
public host. Filtering is by address, not hostname. QUIC is off and WebRTC uses only
proxied traffic. A refused request logs a warning (browser overlay request denied or
browser overlay connection denied), rate-limited per source.
These environment variables control the policy. They are not source options, so a configuration pushed through the API cannot change them:
| Variable | Effect |
|---|---|
VINDRAL_BROWSER_UNRESTRICTED_NETWORK | 1 lifts the whole policy, including the http/https rule, so file:// pages and local addresses work. For demos and tests only. |
VINDRAL_BROWSER_DENIED_NETWORKS | Comma-separated IP addresses or CIDR ranges to refuse in addition, for example 203.0.113.0/24,2001:db8:1::/48. |
VINDRAL_BROWSER_FIRST_HOP_PROBE | auto (default), on or off. auto probes the first hop only when no interface has a public IPv4 address. |
VINDRAL_BROWSER_RENDERER_MEMORY_MB | Data-segment limit for each page renderer, in MB. Default 2048. A page that exceeds it gets allocation failures. |
There is no allowlist for private ranges short of the unrestricted switch. A malformed value stops browser sources from starting.
Browser resource limits
- The viewport is at most 3840 pixels on either edge and at most 3840×2160 pixels in total, in either orientation. Larger sizes fail at start.
frame_ratemust be between 1 and 60.- Page renderers run at reduced CPU priority. There is no hard CPU cap; use a cgroup or container CPU limit for that.
- Pages render in software. WebGL 1 and 2 and GPU canvas work through the SwiftShader software rasterizer, so heavy WebGL content costs CPU.
Chromium's own log output is off by default; see browser_log_level under
[logging]. Browser sources export these metrics, with
the vindral_packager_ prefix:
| Metric | Labels |
|---|---|
browser_requests_total | id |
browser_requests_denied_total | id, reason (scheme or egress) |
browser_response_bytes_total | id |
browser_egress_connections_total | outcome (allowed, denied_address or unreachable) |
browser_egress_bytes_total | direction (sent or received) |
Change a filter at runtime
A volume node with ID music-level in compositor mix can be adjusted with:
curl --fail-with-body -X POST \
-H "Content-Type: application/json" \
-d '{"volume":0.2}' \
http://localhost:4040/api/compositors/mix/music-level/command
Add your bearer header if API authentication is enabled. Only filters listed
in the command API support runtime
commands. 200 acknowledges dispatch, so inspect the output to confirm the
change. A batch validates all targets before dispatch but is not a synchronized
media transaction.
Preserve unrelated tracks
Use compositors.passthrough.sources for tracks that should bypass decoding and
filtering, such as subtitles. Their timestamps are normalized to the composed
timeline. A passthrough source with enabled = false drops its packets. Switch it at
runtime through the command API by sending {"enabled": false} or {"enabled": true} to
the passthrough source's id:
curl --fail-with-body -X POST \
-H "Content-Type: application/json" \
-d '{"enabled":false}' \
http://localhost:4040/api/compositors/compositor/subs/command
Keep output selection explicit so raw intermediate video does not accidentally reach a publishing sink.
If output stalls, inspect each upstream input and required selector, then the compositor and output encoder. Browser startup, alpha-format problems, and mixing multiple clocks can fail at different stages; see Troubleshooting.
More complete recipes
- Split screen and four-camera multiview includes fixed program audio.
- Logo and live text composes an image and an API-controlled caption.
- Camera switching cuts the picture through the API while a separate audio input continues.
- Commentary mixing and live volume controls demonstrate audio composition.
A filter node consumes local compositor inputs, not other node IDs. To chain filters, connect separate compositor tasks as shown in the volume and text recipes.