Skip to content

feat: Spout and NDI output and input, verified in OBS (D569-D574, M-06, M-07) - #123

Draft
lnorton89 wants to merge 11 commits into
masterfrom
feat/m06-ndi-spout
Draft

lnorton89 wants to merge 11 commits into
masterfrom
feat/m06-ndi-spout

Conversation

@lnorton89

@lnorton89 lnorton89 commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #116. Backlog M-06 (output) and M-07 (input).

What this does

Output: the finished picture leaves Strobe over Spout and NDI.

  • strobe-output is the seam (D569). It holds the frame, the layouts (RGBA, UYVY 4:2:2), one Output per named destination following the show's failure policy, and the senders.

  • Spout shares the picture's own texture with zero copies (D570). It calls the installed 64-bit SpoutLibrary.dll through Spout 2.007's real vtable slots, read from the shipped binary (D571). UpdateSender handles a resize, Release runs on drop, and nothing is read back.

  • NDI goes through grafton-ndi 3.0, with the NDI 6 runtime loaded at run time and no SDK needed at build time. The picture is packed to UYVY on the GPU and read back through a fenced three-buffer ring, so the frame thread never waits. It is sent asynchronously, and nothing is done while no receiver is connected (D572).

  • Sharing works the way the surveyed tools do (D572). Settings > Output > Sharing is saved and offers:

    • editable names
    • NDI groups and a frame-rate cap
    • a shared size: the picture's own, or fixed from 720p to 4K
    • a status line with receivers and rate
    • NDI's licence lines

    The same options exist as one-run flags: --spout, --ndi, --ndi-groups, --ndi-fps and --share-size. The survey (Resolume, TouchDesigner, MadMapper, OBS, vMix, Millumin, Synesthesia) is in docs/research/m06-ndi-spout.md.

  • Blackout blackens what goes out. While no scene plays, black goes out, so a receiver that connects first shows black rather than nothing.

  • Clean feed (D573). A second Spout sender carries the picture before the output's look and mirrors, under its own name. Blackout leaves it alone. Set it in Settings or with --spout-clean.

  • Cost: strobe-bench --share times every path. On the RX 580 at 1080p, the NDI path costs the frame 0.54 ms of CPU. The first cut's synchronous readback cost 5.8 ms (45 ms worst).

Input: a Spout sender or an NDI source as the scene's media (D574, M-07).

  • Use spout:<name> or ndi:<name> beside camera:<name>. They can be chosen in the Inspector's Media row, with --media, by a cue or by a preset. --list-spout and --list-ndi print the names.
  • Input runs on the webcam's capture supervisor: it reconnects by name, a failure is said once, and the picture goes black when the source is lost.

Verified on LIGHTNING (Windows 10, RX 580)

  • In OBS Studio 33 (win-spout 1.15.0, DistroAV 6.2.2), all three feeds show side by side, upright: Spout main, Spout clean and NDI.
    • On a still test card (75% colour bars over an eight-step grey ramp), OBS's NDI picture matches its Spout picture within one level on every patch, with exact values (191, 0, 255).
    • Blackout over OSC turns the main Spout and NDI feeds black and leaves the clean feed alone.
    • The output's invert changes the main and NDI feeds, not the clean one.
  • With independent receivers:
    • NDI (grafton-ndi): first 1280x720 frame 0.43 s after connecting, then the show's rate.
    • Spout (Spout SDK ReceiveImage): both feeds' pixels.
    • Groups hide a stream from the default group.
    • After a clean exit, every sender is gone.
  • Spout input: a second Strobe received the first one's picture upright and exact.
  • Without an NDI runtime, --ndi gives one line linking NDI Tools, and the show runs on.
  • Headless GL, both dialects on Mesa: the UYVY pack matches its BT.709 reference byte for byte.

Not verified

There was no research behind M-06's "deferred research": PLAN.md held a crate
name, and nothing had evaluated licensing, pixel formats, frame cost or
failure handling. docs/research/m06-ndi-spout.md does that now, and records
what it changes: neither output needs an SDK at build time (an NDI 6 runtime
is loaded at runtime, Spout's library by the loader), NDI's licence asks for a
link beside every place NDI is chosen, UYVY is half of BGRA's bytes and Spout
copies nothing through the CPU.

strobe-output is the tested core the senders plug into: the output frame, BGRA
and UYVY 4:2:2 packing, one destination per Output with the show's failure
policy (one line per outage, sink closed and dropped, frames dropped rather
than queued), and probes that find the runtime without loading it.

Spout sends the renderer's texture with nothing read back: it loads the
installed SpoutLibrary.dll through libloading and calls the four mangled
exports its C++ ABI exposes, each a private safe leaf with one unsafe block
(D570). NDI is behind the `ndi` feature, sending RGBA from the existing
readback. strobe-gfx lends the texture from the post stage, the compositor or
the player, and the app taps it after the post stage on the picture rather
than the letterboxed window: `--spout NAME` and `--ndi NAME`, or the new
Sharing group in Settings > Output.

Neither output is bundled, and neither has been seen on a receiver: this
machine's only SpoutLibrary.dll is 32-bit and refused by the 64-bit loader,
no x64 NDI runtime is installed, and the readback's frame cost is unmeasured
(M-06).
…ut (D571)

The only SpoutLibrary.dll on the development machine was the 32-bit copy
inside Synesthesia, so the loader refused it and no frame was ever shared.
Spout's own 64-bit library could not have worked through D570 either: 2.007
exports only GetSpout and hands out an object whose methods live in a vtable,
with no mangled exports at all. The sender now takes ReleaseSender (2),
SendTexture (4), IsInitialized (6), GetName (8), GetWidth/GetHeight (9/10),
GetFps (11) and CreateSender (70) from that vtable, numbers read from the
offsets the vendor's own compiled calls dispatch to, because the shipped
header is one slot out from the shipped binary.

The sender also gives a size on the first frame (Spout fixes a sender's size
when it is created), and reports Spout's own view of the result: that it is
live, under which name and at what size, and the frame rate Spout measures.

Verified here with the 64-bit 2.007.018 library beside the executable:
--spout logs a live 960x540 sender and 75.0 fps, and a separate process built
against the vendor's header and .lib lists StrobeProbe at 960x540 BGRA with a
live share handle. No receiver application was attached, and NDI has still
not run: this machine has no NDI 6 runtime.
…, UYVY on the GPU (D572, M-06)

A survey of how Synesthesia, Resolume, TouchDesigner, MadMapper, OBS, vMix
and Millumin expose Spout and NDI (now in docs/research/m06-ndi-spout.md)
set the feature list, and a review of the first cut found its faults.

Settings > Output > Sharing is saved: Spout and NDI on or off with editable
names, NDI groups and a frame-rate cap, and a shared size that follows the
picture or stays fixed. --spout, --ndi, --ndi-groups, --ndi-fps and
--share-size override it for one run without being written back. The final
picture is shared and blackout now blackens it, reversing D569. A status
line gives names, size, NDI receivers and rate; each sender's failure is
said on its own row; NDI's trademark line and links sit beside the choice
and in About.

strobe_gfx::share::ShareStage scales or blacks out the picture and, for
NDI, packs UYVY 4:2:2 on the GPU and reads it back through a fenced ring,
so the frame never waits. NDI submits asynchronously from a borrowed frame
and does nothing while no receiver is connected. Spout shares the picture's
own texture at its own size.

Fixed from the first cut: the Spout object was never released and its DLL
was unloaded under it (Release, slot 174, now runs on drop, and a resize
uses UpdateSender); NDI made three full-size allocations and a synchronous
readback a frame; toggling one sender rebuilt both; three strings had
broken line continuations; grafton-ndi sat in the Windows-only table and
broke the Linux build; Texture::share broke the wasm build. D571's slot
reason was wrong: MSVC groups a virtual's overloads, which shifts the
slots, and every slot is now the one cl itself emits.

Verified on LIGHTNING: --spout at --share-size 1280x720 is listed at that
size by a receiver-side probe and is gone after a clean exit; --ndi with no
runtime gives one line with the NDI Tools link. The UYVY packing matches
its BT.709 reference in both dialects on Mesa. Not verified: a receiver
application on screen, NDI with a runtime, the T480's frame cost.
…--share (D573, M-06)

Issue #116 asks for several named Spout senders, and Resolume, MadMapper
and OBS each offer more than one. A second sender is only useful with a
different picture, so the clean feed carries the scene before the post
stage (master, colour, mirrors) and blackout leaves it alone: a mixer can
apply its own look, or keep a picture while the projector is dark. It has
its own name (refused if it matches the main sender's), its own share stage
for the shared size, a switch and name field in Settings > Output > Sharing
(saved), and --spout-clean NAME for one run.

strobe-bench --share times each sharing path on the context it opens. On
the RX 580 at 1080p the NDI path (UYVY pack plus asynchronous readback)
costs the frame 0.54 ms of CPU against the first cut's synchronous readback
at 5.8 ms (45 ms worst), and paced at 60 Hz it delivers a picture every
frame from the third with none dropped. Recorded in BENCHMARKS.md.

Verified on LIGHTNING: --spout StrobeMain --spout-clean StrobeRaw at
--share-size 1280x720 lists two senders at 1280x720 on the receiver-side
probe, and both are gone after a clean exit.
…once (M-06)

A receiver that connected before a scene was chosen listed the source but
got no frames; both senders now send black at the output's size until a
scene plays. When the main and clean Spout feeds fail for the same reason,
the note says it once. The NDI cap's timing is a function with tests.

Verified on LIGHTNING with independent receivers: Spout pixels on both
feeds, blackout over OSC on the main feed only, Spout and NDI upright and
alike, NDI groups, idle black, and senders gone after exit.
…ame> (D574, M-07)

The input half of issue #116. A Spout sender or an NDI source is a live
media choice beside camera:<name>, from the Inspector's Media row (Spout,
NDI), --media, a cue or a preset; --list-spout and --list-ndi print the
names. Both run on strobe-capture's supervisor as two more backends, so
reconnect by name, the watchdog and a failure said once (black, type 0)
are the webcam's. One upload a frame into one reused texture,
syn_MediaType 3 (Q22). Spout reads on the capture thread through Spout's
own hidden GL context, with receiver vtable slots read from cl's listing;
NDI asks for RGBX/RGBA. An idle sender keeps its last picture.

Verified on LIGHTNING Strobe to Strobe over Spout: upright and exact,
lost said once and black, back by itself when the sender starts.
@lnorton89 lnorton89 changed the title feat: NDI and Spout output, researched, with the frame seam built (D569, M-06) feat: Spout and NDI output and input, verified in OBS (D569-D574, M-06, M-07) Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Spout integration

1 participant