Skip to main content

Add a logo and update text live

Add a static image and an API-controlled caption to a program while preserving its audio. Use the shared setup, including logo.png and font.ttf, and a Packager image with drawtext support. Connect the SRT receiver. Expect red 640×360 video, a teal logo at the upper left, “Program ready” near the bottom, and the original 440 Hz audio.

captions applies text before graphics overlays the logo. These are separate compositor tasks because node-to-node chaining inside a compositor is unsupported. The logo branch preserves alpha using yuva420p; replace the fixture with a transparent PNG as needed. The final opaque program is yuv420p.

Change the caption​

bash
curl --fail-with-body -X POST \
http://127.0.0.1:4040/api/compositors/captions/caption/command \
-H 'Content-Type: application/json' \
-d '{"text":"LIVE","font_color":"yellow"}'

The caption should become yellow “LIVE” while the logo and audio remain unchanged. The request targets compositor captions, filter caption. A 200 response only confirms dispatch; inspect the picture and logs. The initial TOML text returns when the graph is recreated. Missing fonts or missing drawtext build support prevent this branch from starting. The example text deliberately avoids FFmpeg expression/escaping characters; test escaping before accepting arbitrary captions. For HTML animation or web-driven graphics, use the browser overlay recipe.

Complete configuration​

Download logo-and-text.toml.

toml
# Vindral Bridge Packager example
# Add a logo and text you update through the API, sent over SRT.

version = "3"

[api]
bind = "0.0.0.0:4040"

[[sources]]
id = "program"
source_type = "file"
realtime_pacing = true
protocol_options = { url = "/media/camera-a.mp4" }

[[sources]]
id = "logo"
source_type = "image"
protocol_options = { url = "/media/logo.png" }

[sources.demuxer_options]
frame_rate = { type = "u_int", value = 30 }

[[transcoders]]
id = "decode"
source_ids = ["program"]
device = "cpu"

[[transcoders.tracks]]
id = "base-video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }

[[transcoders.tracks.renditions]]
id = "base-raw"
codec = "wrapped_avframe"
format = "yuv420p"
size = { width = 640, height = 360 }

[[transcoders]]
id = "logo-decode"
source_ids = ["logo"]
device = "cpu"

[[transcoders.tracks]]
id = "logo-video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }

[[transcoders.tracks.renditions]]
id = "logo-raw"
codec = "wrapped_avframe"
format = "yuva420p"
size = { width = 128, height = 64 }

[[compositors]]
id = "captions"
[[compositors.video.sources]]
id = "base"
source_id = "decode"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[compositors.video.nodes]]
id = "caption"
type = "drawtext"
source_ids = ["base"]
text = "Program ready"
fontfile = "/media/font.ttf"
font_size = 28
font_color = "white"
x = "16"
y = "h-th-16"

[[compositors]]
id = "graphics"
[[compositors.video.sources]]
id = "caption-frame"
source_id = "captions"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[compositors.video.sources]]
id = "logo-frame"
source_id = "logo-decode"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[compositors.video.nodes]]
id = "logo-overlay"
type = "overlay"
source_ids = ["caption-frame", "logo-frame"]
x = "16"
y = "16"
format = "auto"
output_format = "yuv420p"

[[compositors.passthrough.sources]]
id = "program-audio"
source_id = "program"
track_selector = { type = "track-kind", kind = "audio", is_required = true }

[[transcoders]]
id = "output"
source_ids = ["graphics"]
device = "cpu"

[[transcoders.tracks]]
id = "video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }

[[transcoders.tracks.renditions]]
id = "video-output"
codec = "h264"
encoder_name = "libx264"
bit_rate = 1_000_000
gop_size_ms = 1000
max_b_frames = 0
format = "yuv420p"
size = { width = 640, height = 360 }

[[transcoders.tracks]]
id = "audio"
type = "audio"
passthrough = true
track_selector = { type = "track-kind", kind = "audio", is_required = true }

[[sinks]]
id = "srt"
sink_type = "srt"
source_ids = ["output"]
wait_for_all_sources = true
protocol_options = { url = "srt://0.0.0.0:10000?mode=listener&latency=120000" }