Skip to main content

Browser as the only source

This example streams a web page directly: the page is the entire frame, with no underlying video feed and no compositor. The page's own audio is captured and encoded alongside it, and both are published over RTMP.

This suits fully web-rendered output: data dashboards, results boards, auction and betting displays, generated slate or holding pages, and browser-based playout of HTML graphics.

note

The browser source runs in a separate Packager image. Contact Vindral support for access.

Configuration​

Because nothing is composited, the pipeline is a straight line: one source, one transcoder that encodes both video and audio, one sink.

Set YOUR_BROWSER_URL to the page to render, as a public http:// or https:// URL (see Network access from browser pages). Replace YOUR_INGEST_HOST and YOUR_STREAM_KEY with your RTMP publishing destination; use its full URL if the service requires a different path.

Download browser-source.toml.

toml
# Vindral Bridge Packager example
# A web page as the only source, encoded on the GPU and published over RTMP.

version = "3"

[[sources]]
id = "browser"
source_type = "browser"

[sources.protocol_options.url]
type = "string"
value = "YOUR_BROWSER_URL"

[sources.demuxer_options.width]
type = "u_int"
value = 1920

[sources.demuxer_options.height]
type = "u_int"
value = 1080

# There is no base video to composite onto, so render the page opaque with
# its own background rather than emitting an alpha channel that the YUV
# encoder would only flatten.
[sources.demuxer_options.transparent_background]
type = "bool"
value = false

[sources.demuxer_options.frame_rate]
type = "u_int"
value = 50

# Give the page time to load and lay out before the first frame is emitted.
[sources.demuxer_options.startup_delay_ms]
type = "u_int"
value = 500

# Capture the page's audio as a second stream.
[sources.demuxer_options.audio_capture]
type = "bool"
value = true

# One transcoder handles both tracks: the page's BGRA frames are uploaded to
# CUDA and converted in the filter graph before NVENC, and the captured PCM
# audio is encoded to AAC.
[[transcoders]]
id = "transcoder"
source_ids = ["browser"]
device = "nvidia"

[[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 = 2000
bit_rate = 6_000_000

[transcoders.tracks.renditions.size]
scale_factor = 1.0

[[transcoders.tracks]]
type = "audio"
id = "output-audio"

[transcoders.tracks.track_selector]
type = "track-kind"
kind = "audio"

[[transcoders.tracks.renditions]]
id = "aac-output"
codec = "aac"
bit_rate = 128_000

[[sinks]]
id = "rtmp-sink"
sink_type = "flv"
source_ids = ["transcoder"]
wait_for_all_sources = true

[sinks.protocol_options.url]
type = "string"
value = "rtmps://YOUR_INGEST_HOST/publish/YOUR_STREAM_KEY"

Running on CPU​

Set device = "cpu" on the transcoder and drop the [transcoders.tracks.processing] block (or set hw_filtering_enabled = false). Nothing else changes. There is no compositor here, so none of the pixel-format settings that the overlay example needs applies.

Notes​

Set transparent_background = false. It defaults to true, which is right for overlays but wrong here: with no base layer underneath, the alpha channel has nothing to blend with and is discarded by the YUV encoder anyway. Leaving it on generally means the page renders against black instead of its own background.

Match frame_rate and the viewport to your output, and no more. These two settings dominate the cost of a browser source: every frame is rendered by a full browser engine and then moved through the pipeline as raw BGRA, so both the render cost and the bandwidth scale with resolution and frame rate. A dashboard that updates once a second does not need 50 fps, and rendering at 720p costs well under half of 1080p. frame_rate defaults to 30 and accepts 1–60; the source paces itself at this rate and does not need realtime_pacing.

Use startup_delay_ms for pages that need to fetch data. Frames are held back for this long after the page is created, which avoids publishing a partly-rendered first frame. It defaults to 0 and accepts up to 60000.

The viewport is capped at 3840×2160. Neither edge may exceed 3840 pixels and the total may not exceed 3840×2160 pixels, in either orientation.

WebGL works, in software. Pages render without a GPU; WebGL 1 and 2 run on the SwiftShader software rasterizer and cost CPU accordingly.

Audio still needs audio_capture = true. Without it the source advertises no audio track at all, and a sink configured to expect one will not start. A silent page is not a problem. The source fills its timeline with silence, so the track is present either way. If the page's audio context is not 48 kHz stereo, the source resamples it automatically.

Autoplay does not require a user gesture. The browser is started with autoplay permitted, so a page with audio begins playing on its own.

See also​