Skip to content

feat(moq-video): opt-out nvenc/vaapi features (default-on) + correct libva docs#1860

Merged
kixelated merged 3 commits into
devfrom
claude/vaapi-libva-link-docs
Jun 21, 2026
Merged

feat(moq-video): opt-out nvenc/vaapi features (default-on) + correct libva docs#1860
kixelated merged 3 commits into
devfrom
claude/vaapi-libva-link-docs

Conversation

@kixelated

@kixelated kixelated commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two related changes around how the Linux hardware encoders (NVENC / VAAPI) pull in system deps. Came out of the #1837 "VAAPI driver-probe" box.

1. Default-on nvenc / vaapi features (the opt-out)

#1819 made NVENC/VAAPI always-on for Linux, which also made libva a hard runtime dependency of every Linux moq-video binarymoq-vaapi 0.0.2 links libva (NEEDED libva.so.2 / libva-drm.so.2), so a libva-less host can't even load the binary. We're keeping that default (libva is near-universal on Linux GPU boxes), but giving self-compilers a way to drop the CUDA / libva deps.

  • moq-video: reintroduce nvenc and vaapi features (the Linux deps become optional), both in default. Backend modules + candidates gated with #[cfg(all(target_os = "linux", feature = ...))]. openh264 stays the always-compiled software fallback; V4L2 capture is unaffected. Features are no-ops off Linux.
  • Consumers: the workspace moq-video dep is now default-features = false (mirroring the existing moq-native pattern), so each binary opts in. libmoq / moq-boy enable both; moq-cli exposes default-on nvenc/vaapi passthroughs so a capture build can drop them:
    cargo build -p moq-cli --no-default-features --features "iroh quinn websocket capture"
    

Default builds everywhere are byte-for-byte the same as before — this is purely additive (a new way to turn things off).

2. Correct the libva docs (no code change)

The vaapi.rs + Cargo.toml comments and DESIGN-native-codecs.md claimed moq-vaapi dlopens libva ("builds without system libva-dev", "loads on machines without libva"). That's false for moq-vaapi 0.0.2, which links it. Corrected to describe the real behavior + the now-default-on feature.

Evidence (podman, rust:latest)

  • moq-vaapi 0.0.2 without libva-dev → build fails at pkg-config ... libva; with it, the binary carries NEEDED libva.so.2 + libva-drm.so.2 (readelf -d). So it links, not dlopens.
  • cargo check -p moq-video --no-default-featuressucceeds without libva-dev (the opt-out works); the default (nvenc+vaapi) compiles with libva-dev.

Why this isn't the NVENC-style "driver-probe" from #1837

moq-vaapi links libva and its Encoder::new returns a Result (no panic), so — unlike NVENC (which dlopens + panic!s, hence the #1844 probe) — a libva-less box fails at process load, before any probe could run, and the no-GPU case already falls back cleanly. The real "dlopen libva" fix lives in the moq-dev/vaapi crate; this PR makes the dep optional in the meantime. Issue #1837 reframed accordingly.

Test plan

  • macOS: cargo check for moq-video / moq-cli (default + --features capture) / libmoq / moq-boy all pass; cargo test -p moq-video green.
  • Linux (container): moq-video --no-default-features builds with no libva-dev; default builds with it.
  • cargo tree confirms feature resolution: moq-cli --features capture → moq-video nvenc,vaapi; --no-default-features ... capture → none; ... capture nvencnvenc only; libmoq/moq-boy → nvenc,vaapi.
  • cargo fmt + taplo format --check clean (via nix).

Cross-package sync

No JS mirror (native-only). Docs touched: DESIGN-native-codecs.md. The moq-cli flags doc may want a note about the new --no-default-features opt-out, but no example invocation changed.

(Written by Claude)

The VAAPI backend comments (vaapi.rs, Cargo.toml) and DESIGN-native-codecs.md
claimed moq-vaapi dlopens libva, so a VAAPI-enabled Linux binary "builds
without system libva-dev" and "loads on machines without libva, falling back
to software." That is false for the published moq-vaapi 0.0.2 we depend on.

Verified in a Linux (rust:latest) container:
- Building a crate that depends on moq-vaapi 0.0.2 WITHOUT libva-dev fails at
  `pkg-config ... libva` ("system library `libva` required by crate `moq-vaapi`
  was not found"). So it does NOT build without libva-dev.
- With libva-dev, the linked binary carries `NEEDED libva.so.2` and
  `NEEDED libva-drm.so.2` (readelf -d). So a libva-less host fails to load the
  binary, before `backend::open` can fall back to openh264.

moq-vaapi 0.0.2's build.rs uses `pkg_config::probe("libva")` /
`probe("libva-drm")` (a hard link), and there is no dlopen anywhere in its
source. The dlopen design documented for the old cros-codecs `vaapi_dlopen`
git dep was lost when moq-vaapi was extracted to a published crate.

Correct the three spots to describe the current behavior and flag the dlopen
restoration as tracked in #1837. The no-GPU case (libva present, no usable VA
driver) still falls back cleanly: `Encoder::new` returns an error that
`backend::open` skips past. No code behavior change.

This reframes the "VAAPI driver-probe" box on #1837: the NVENC-style probe
does not apply (moq-vaapi links rather than dlopens, and its init returns a
`Result` rather than panicking), so the real fix is making moq-vaapi dlopen
libva.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
#1819 made the NVENC/VAAPI hardware encoders always-on for Linux, which also
made libva a hard runtime dependency of every Linux moq-video binary
(moq-vaapi 0.0.2 links libva: NEEDED libva.so.2 / libva-drm.so.2). Give
self-compilers a way to drop the CUDA / libva deps without changing the
default.

moq-video: reintroduce `nvenc` and `vaapi` features (the Linux deps become
optional), both in `default`, gating the backend modules + candidates with
`#[cfg(all(target_os = "linux", feature = ...))]`. Default builds are
unchanged; `--no-default-features` (or dropping one feature) builds without
the corresponding dep. openh264 stays the always-compiled software fallback
and V4L2 capture is unaffected.

Consumers: the workspace moq-video dep is now `default-features = false`
(mirroring moq-native), so each binary opts in. libmoq and moq-boy enable
both encoders; moq-cli exposes default-on `nvenc`/`vaapi` passthroughs so a
`capture` build can drop them:
  cargo build -p moq-cli --no-default-features --features "iroh quinn websocket capture"

Verified: macOS builds all affected crates (features are no-ops off Linux);
a Linux container compiles `moq-video --no-default-features` WITHOUT libva-dev
and the default (nvenc+vaapi) WITH it; `cargo tree` confirms the feature
resolution for every consumer scenario.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kixelated kixelated changed the title docs(moq-video): VAAPI links libva (not dlopen); correct comments + reframe #1837 feat(moq-video): opt-out nvenc/vaapi features (default-on) + correct libva docs Jun 21, 2026
…UDA/libva)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kixelated kixelated merged commit 6868f96 into dev Jun 21, 2026
1 check passed
@kixelated kixelated deleted the claude/vaapi-libva-link-docs branch June 21, 2026 22:32
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.

1 participant