Skip to content

Retire the global VideoConvertMode and the remaining producer-side memory-format choices #969

Closed

Description

@srperens

Summary

What is left of #682. The convention (a block emits its native memory type, and the consumer adapts) is written down in docs/BLOCK_GUIDELINES.md, and gst::video_adapt::decide() holds the adapter rules. Three things still decide the memory format somewhere other than the consumer's view of its negotiated caps.

1. The global VideoConvertMode

gpu::detect_gpu_capabilities() picks one converter for the whole process at startup: autovideoconvert when NVENC and CUDA-GL interop are present, plain videoconvert otherwise. Call sites on main:

  • videoenc.rs and videoformat.rs: the block's input front
  • ndi.rs: four call sites
  • devicesrc.rs
  • vision_mixer/builder/pipeline_cpu.rs

The choice belongs to each link, not to the process. Today it mostly works because the linker's GL-download retry (#802) catches a refused GL link. That retry only fires on a format refusal, though. A videoconvert with video/x-raw(ANY) templates accepts GL memory and passes it on, so the dead end appears one element further down. BLOCK_GUIDELINES also says to avoid autovideoconvert in new code. The NVIDIA branch still hands it to every one of these blocks.

Direction: give each call site an input front that decides from the negotiated caps through decide(), extending decide() where it does not yet cover a case. Retire VideoConvertMode once no call site is left. Threading (gpu::configure_video_convert, n-threads) stays on the converter a site ends up with. One block per PR.

2. WHIP Input's unconstrained videoconvert

whip.rs builds a videoconvert per video slot between decodebin and the output tee, with no capsfilter after it. It negotiates passthrough, so it does no useful work. When it does convert, it does so silently on the CPU, frame by frame. Test whether it can be removed across real flows: WHIP to Vision Mixer on GL, WHIP to Video Encoder to WHEP, WHIP to recorder, WHIP to thumbnail. The audio branch's audioconvert and audioresample raise the same question at lower stakes.

3. gl_output (Compositor) and gl_download (Vision Mixer)

These are producer-side switches that make the operator guess what is downstream. They are the same decision with opposite polarity. Since #802 a consumer adapts to GL memory without them. Compositor is deprecated, so only Vision Mixer matters. Hide the property from the block definition but keep tolerating it in stored flows (the parser falls back to the default), or keep it only as a diagnostics override. Check whether block property schemas are part of the OpenAPI snapshot before removing it.

Tests

Each converted block gets a guard test that builds the block and links it behind a video/x-raw(memory:GLMemory) producer, and that fails if the caps-aware front is reverted. The GL elements the test needs must be in the CI package list (.github/workflows/ci.yml).

Related

Activity

  1. wagenet commented on Oct 6, 2026

    @wagenet
    Contributor

    Another trigger for item 1, this time with a race that makes it intermittent.

    Setup: macOS, GStreamer 1.28.6, Strom 68632494. An MPEG-TS/SRT Input receives H.264 (1280x720) and AAC from an SRT caller. A recorder is set to transcode on that input.

    What happens: about 2 s after the caller's first data, srtsrc stops with streaming stopped, reason not-negotiated (-4). The input's picture freezes downstream. The input's audio recorder links, but its video recorder never does.

    Why (GST_DEBUG decodebin:6,vtdec:5,basetransform:5):

    1. decodebin plugs vtdechw and calls autoplug-query for its pad before that pad is linked to anything. With nothing downstream constraining it, vtdec negotiates video/x-raw(memory:GLMemory), format=NV12.
    2. The recorder's video encoder front is a videoconvert. It accepts the GLMemory caps (accept-caps result: 1).
    3. That videoconvert then can't find a peer for them: FAILED to get peer of <…venc…:videoconvert:src> to accept video/x-raw(memory:GLMemory). Next comes could not send sticky events on the recorder's queue, then vtdec.c:499 pausing output task because of downstream: not-negotiated.

    The mixer branch takes GLMemory, so only the recorder branch refuses. The refusal comes after linking, so the #802 GL-download retry never fires.

    Why it's intermittent: it fails only when vtdec negotiates before decodebin exposes and links its pad. When the pad links first, the caps query reaches the encoder and vtdec picks system memory. Every test fed real H.264 at 20 and 30 fps, with and without B-frames, and every caller start-up pacing tried failed. One 30 fps B-frame clip passed twice. Turning recording off for the input avoids it, and the input then survives caller reconnects.

    Directions: the item 1 fix (a caps-aware input front on videoenc.rs) would cover this. Separately, the input block could answer decodebin's autoplug-query from its real downstream, so the decoder can't pick a memory type before it's linked.

    Posted by Claude (Claude Code) on Peter's behalf.

  2. srperens commented on Oct 19, 2026

    @srperens
    CollaboratorAuthor

    Area: Video memory formats, consumer-side adaptation

    About: Three things still choose a memory format away from the consumer's negotiated caps: the process-wide VideoConvertMode, WHIP Input's unconstrained videoconvert, and Vision Mixer's gl_download. Comments add a macOS not-negotiated race the #802 retry misses.

    Relates to: #1021 (open; item 1, Video Encoder only). #1091 (open; Media Player refuses GL at its clip appsink, since a GL context cannot cross pipelines; the author asks to keep it). #1099 (the same cross-pipeline GL problem as an issue). #747 (open; grows the global mode this retires). #1085 (open; WHEP Input passes decoder memory through, the stance item 2 asks of WHIP Input). Merged #1093, #1033, #802, #951; closed #682.

    Thoughts: One block per PR, as the issue says. Treat cross-pipeline bridges (#1091, #1099) as a separate case from the producer-side choices listed here.

  3. wagenet commented on Oct 21, 2026

    @wagenet
    Contributor

    Posted by Claude on behalf of the author.

    PR #1091 adds one justified producer-side memory choice: the Media Player's clip video appsink refuses GL memory (it accepts CUDA, D3D and system memory). The consumer cannot adapt GL there: caps queries stop at the appsink/appsrc boundary, and a GL context does not show in caps. glupload passes GL memory through when contexts can share, but glcolorconvert needs the very same context, which the player's pipeline never has in common with the flow's. Please do not retire it as a producer-side choice when working through this list.

  4. srperens commented on Oct 27, 2026

    @srperens
    CollaboratorAuthor

    The Video Encoder case is released in v0.7.2: #1111 (fix(videoenc): adapt the input memory to what the encoder takes) puts a caps-aware input front, using video_adapt::decide(), on the encoder in place of VideoConvertMode.

    Still open here:

    • VideoConvertMode in Local Input (devicesrc), Video Format and NDI,
    • WHIP Input's unconstrained videoconvert,
    • Vision Mixer's gl_download.

    🤖 Generated with Claude Code

  5. 8 remaining items

  6. added a commit that references this issue on Oct 27, 2026
    1e9b9c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions