feat(moq-video): opt-out nvenc/vaapi features (default-on) + correct libva docs#1860
Merged
Conversation
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>
24 tasks
#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>
…UDA/libva) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/vaapifeatures (the opt-out)#1819 made NVENC/VAAPI always-on for Linux, which also made libva a hard runtime dependency of every Linux
moq-videobinary —moq-vaapi 0.0.2links 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.nvencandvaapifeatures (the Linux deps becomeoptional), both indefault. 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.moq-videodep is nowdefault-features = false(mirroring the existingmoq-nativepattern), so each binary opts in.libmoq/moq-boyenable both;moq-cliexposes default-onnvenc/vaapipassthroughs so acapturebuild can drop them: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.tomlcomments andDESIGN-native-codecs.mdclaimed moq-vaapi dlopens libva ("builds without system libva-dev", "loads on machines without libva"). That's false formoq-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.2without libva-dev → build fails atpkg-config ... libva; with it, the binary carriesNEEDED libva.so.2+libva-drm.so.2(readelf -d). So it links, not dlopens.cargo check -p moq-video --no-default-features→ succeeds 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::newreturns aResult(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 themoq-dev/vaapicrate; this PR makes the dep optional in the meantime. Issue #1837 reframed accordingly.Test plan
cargo checkfor moq-video / moq-cli (default +--features capture) / libmoq / moq-boy all pass;cargo test -p moq-videogreen.moq-video --no-default-featuresbuilds with no libva-dev; default builds with it.cargo treeconfirms feature resolution:moq-cli --features capture→ moq-videonvenc,vaapi;--no-default-features ... capture→ none;... capture nvenc→nvenconly; libmoq/moq-boy →nvenc,vaapi.cargo fmt+taplo format --checkclean (via nix).Cross-package sync
No JS mirror (native-only). Docs touched:
DESIGN-native-codecs.md. Themoq-cliflags doc may want a note about the new--no-default-featuresopt-out, but no example invocation changed.(Written by Claude)