NDI input and output
Packager can receive NDI sources on the local network and publish its own
output as an NDI source. Use the ndi source to bring a vision mixer, camera or
graphics machine into a pipeline, and the ndi sink to send a stream from SRT,
RTMP, MoQ or a file to NDI receivers in a studio.
Install the NDI runtime
The NDI runtime is not included in Packager images; its licence does not allow
redistribution. Download the NDI SDK or runtime for Linux from
ndi.video and make libndi.so available
to Packager. NDI 5 and 6 runtimes are supported.
Packager looks for the library at startup in this order and uses the first match:
- the working directory (
/appin the images); - the directory in
NDI_RUNTIME_DIR_V3, thenNDI_RUNTIME_DIR_V6, thenNDI_RUNTIME_DIR_V5; - the system library path (
LD_LIBRARY_PATH,ldconfig).
In each place it tries libndi.so, libndi.so.6 and libndi.so.5. When the runtime
loads, the log shows ndi runtime loaded with its version. Without it, the ndi
source and sink types do not exist and tasks using them fail to start.
NDI discovery uses mDNS on UDP port 5353; media uses TCP ports from 5960 upward,
one per stream. On Linux, discovery by name also needs avahi-daemon running on the host.
Run with Docker
Multicast discovery does not work on Docker's default bridge network. Use host networking and mount the runtime and the host's Avahi and D-Bus sockets:
docker run -d --name packager-ndi \
--network host \
--security-opt apparmor=unconfined \
-v /opt/ndi/lib:/opt/ndi/lib:ro \
-e NDI_RUNTIME_DIR_V3=/opt/ndi/lib \
-v /var/run/dbus:/var/run/dbus \
-v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket \
-v "$PWD/config.toml:/etc/packager/config.toml:ro" \
"${PACKAGER_IMAGE:?Set PACKAGER_IMAGE}" start
Replace /opt/ndi/lib with the directory that holds libndi.so on the host. Do not
run avahi-daemon inside the container. Where multicast does not cross between
networks or VLANs, run an NDI Discovery Server and set
NDI_DISCOVERY_SERVER=<host> on the Packager container, or connect to senders by
address with url (below).
Under Docker's default AppArmor profile the container cannot reach Avahi over D-Bus,
so senders are not found or advertised by name. Run with
--security-opt apparmor=unconfined and the host's D-Bus mounted, as above, or
connect by url.
Receive an NDI source
Download ndi-input.toml. It receives
the NDI source STUDIO-PC (Camera 1), deinterlaces it if it is interlaced,
encodes H.264 and AAC, and serves the result as an SRT listener on port 9000.
This example encodes with libx264, so use an image variant that includes x264; see Validation.
# Vindral Bridge Packager example
# Receive an NDI source, encode it and send it over SRT.
version = "3"
[api]
bind = "127.0.0.1:4040"
[[sources]]
id = "ndi"
source_type = "ndi"
protocol_options = { name = "STUDIO-PC (Camera 1)" }
[[transcoders]]
id = "encode"
source_ids = ["ndi"]
device = "cpu"
[[transcoders.tracks]]
id = "video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }
processing = { deinterlace = "every_field" }
[[transcoders.tracks.renditions]]
id = "video-h264"
codec = "h264"
encoder_name = "libx264"
bit_rate = 4_000_000
gop_size_ms = 1000
[[transcoders.tracks]]
id = "audio"
type = "audio"
track_selector = { type = "track-kind", kind = "audio", is_required = true }
[[transcoders.tracks.renditions]]
id = "audio-aac"
codec = "aac"
sample_rate = 48_000
channels = 2
bit_rate = 128_000
[[sinks]]
id = "srt"
sink_type = "srt"
source_ids = ["encode"]
protocol_options = { url = "srt://0.0.0.0:9000?mode=listener" }
Find the exact source names on the network with the same mounts and a
configuration file, as for start:
docker run --rm --network host --security-opt apparmor=unconfined -v /opt/ndi/lib:/opt/ndi/lib:ro -e NDI_RUNTIME_DIR_V3=/opt/ndi/lib \
-v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket \
-v "$PWD/config.toml:/etc/packager/config.toml:ro" \
"$PACKAGER_IMAGE" sources discover ndi
Every 5 seconds it prints name and url for each source it finds, or No sources found, until you stop it. If nothing is found, check that avahi-daemon runs on the
host, or use the sender's address as url.
Source options
All options are strings in protocol_options.
| Option | Default | Meaning |
|---|---|---|
name | Empty | NDI source name exactly as shown on the network, such as STUDIO-PC (Camera 1). Found through discovery. |
url | Unset | Sender address as host:port, such as 192.0.2.50:5961. Connects directly without discovery. Takes precedence over name. |
field_mode | weave | How field-based (interlaced) senders are received; see below. |
timestamp_source | timestamp | Which sender clock timestamps are built from: timestamp or timecode. |
The source receives at full bandwidth. It outputs raw video as uyvy422 for YUV
senders, or as bgra, bgr0, rgba or rgb0 for RGB senders, and 16-bit PCM audio
at the sender's channel count and sample rate. For video with alpha, send RGBA: the
alpha of a UYVA sender is not carried. Frames in other formats, such as 16-bit P216,
are skipped with a warning. It carries video and audio; NDI
metadata, tally and PTZ are not forwarded.
Interlaced senders
Many NDI senders transmit 1080i as separate fields. With field_mode = "weave", the
default, Packager pairs the two fields into one interlaced frame. The transcoder's
deinterlace setting then decides the output:
processing.deinterlace | Output from a 1080i25 sender |
|---|---|
every_field | 1080p50: full motion. |
every_frame | 1080p25. |
disabled | 1080i25 with combing on motion; for diagnostics. |
Weaving adds one field of latency (20 ms at 50 fields per second). Progressive senders are not affected.
field_mode = "sdk" lets the NDI runtime deinterlace instead. That produces
the sender's frame rate only (1080p25 from 1080i25) and uses less CPU; the
transcoder's deinterlace setting then has no effect.
The source logs one ndi video track line when it connects, with the frame format,
size, frame rate and field order it detected. Check it when the output is not what
you expect.
Timestamps
Packager builds a continuous timeline for each connection, starting near 1 second, and keeps the sender's audio/video offset. It smooths sender jitter, never steps backwards, and bridges clock jumps of more than a second.
timestamp_source = "timestamp" (default) uses the time at which the sender
submitted each frame. timecode uses the content timecode, which advances exactly
with the media and suits senders that set it reliably, such as playout servers
and vision mixers. Changing the option starts a new timeline.
Publish an NDI source
The ndi sink makes Packager appear on the network as the NDI source
HOSTNAME (name). NDI carries uncompressed video, so the sink takes raw tracks
only: put a transcoder in front that produces a rawvideo rendition and
pcm_f32le or pcm_s16le audio (a DeckLink source captured at 32 bits needs this
transcoder too). An ndi source can be connected directly without a
transcoder.
Download ndi-output.toml. It
publishes the test signal as HOSTNAME (Packager test signal).
Replace the source with any input to republish it on NDI:
# Vindral Bridge Packager example
# Publish a test signal as an NDI source on the local network.
version = "3"
[api]
bind = "127.0.0.1:4040"
[[sources]]
id = "signal"
source_type = "test-signal"
[sources.protocol_options]
width = { type = "u_int", value = 1280 }
height = { type = "u_int", value = 720 }
fps = { type = "u_int", value = 25 }
[[transcoders]]
id = "raw"
source_ids = ["signal"]
device = "cpu"
[[transcoders.tracks]]
id = "video"
type = "video"
track_selector = { type = "track-kind", kind = "video", is_required = true }
[[transcoders.tracks.renditions]]
id = "video-raw"
codec = "rawvideo"
format = "uyvy422"
[[transcoders.tracks]]
id = "audio"
type = "audio"
track_selector = { type = "track-kind", kind = "audio", is_required = true }
[[transcoders.tracks.renditions]]
id = "audio-pcm"
codec = "pcm_f32le"
sample_rate = 48_000
channels = 2
[[sinks]]
id = "ndi"
sink_type = "ndi"
source_ids = ["raw"]
[sinks.protocol_options]
name = "Packager test signal"
latency_ms = { type = "u_int", value = 300 }
The sink logs ndi output started when the source appears on the network, and
ndi receivers connected whenever the number of receivers changes.
Sink options
| Option | Type | Default | Meaning |
|---|---|---|---|
name | string | Required | Source name after the host name. Two sinks in one Packager cannot share a name. |
groups | string | Default group | Comma-separated NDI groups. |
latency_ms | u_int | 300 | How long each frame is held before sending, so bursts of input go out evenly. 0–2000. It must cover the largest burst the input delivers. |
Input requirements
| Accepted | |
|---|---|
| Video | One rawvideo track in uyvy422, nv12, yuv420p, bgra, bgr0, rgba or rgb0, with a frame rate. uyvy422 is NDI's native format. nv12 avoids a conversion after NVIDIA decoding. |
| Audio | At most one pcm_f32le or pcm_s16le track, packed. |
| Interlaced | Whole interlaced frames, sent as interlaced, top field first. Deinterlace bottom-field-first sources in the transcoder. |
| Other tracks | Subtitles and data tracks are skipped with a warning. |
An encoded track, a second video or audio track, or an unsupported pixel format fails the sink at start with a message naming the problem. Select one track of each kind with track selectors when the input has several.
Behaviour
The sink paces frames itself at their timestamps plus latency_ms, and keeps audio
and video in sync. A video frame the NDI runtime has not taken 200 ms after it was due
is dropped and counted as late. When the input's tracks change, the sink restarts but keeps the NDI source
on the network for up to 5 seconds, so receivers stay connected. If the input
stops, nothing is sent and receivers typically hold the last frame.
The sink sends full-bandwidth NDI: the NDI runtime compresses video with SpeedHQ, at roughly 100–150 Mbit/s per receiver at 1080p, as NDI quotes it.
Metrics
All names carry the vindral_packager_ prefix. See Monitoring.
| Metric | Labels | Meaning |
|---|---|---|
ndi_receive_connections | id | 1 while the source is connected to its sender. |
ndi_receive_frames_total | id, media | Frames received. |
ndi_receive_dropped_frames_total | id, media | Frames the NDI runtime dropped because they were not read in time. |
ndi_receive_queued_frames | id, media | Frames waiting in the receive queue. |
ndi_timeline_corrections_total | id, media, event | Timeline corrections: resync_forward, resync_backward, held, dropped, undefined, clock_jump. |
ndi_timeline_audio_lateness_ticks | id | How far audio runs behind the sender's stamps, in 100 ns ticks. |
ndi_timeline_skipped_seconds_total | id, media | Media skipped by forward resyncs. |
ndi_send_connections | name | Receivers connected to the sink. |
ndi_send_dropped_frames_total | name, media, reason | Frames the sink dropped: queue_full, late or invalid. |
Rising ndi_receive_dropped_frames_total means Packager is not keeping up with
the sender; check CPU load. Rising late or queue_full drops on the sink mean the
NDI runtime is not keeping up with sending; check CPU load. Input that arrives in bursts
larger than latency_ms makes the output pause briefly, not drop frames.