Screen share 18: Linux hardware encoding (VAAPI; NVENC documented) (#165) #232
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-18-hw-encode-linux"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: screenshare-17-voice-livekit-video
What this builds
crates/fluxer-voice/src/rtc.rs): the codec probe now keeps its per-backend encoder lists (EncoderLists { software, hardware }), andpublish_screenpicks the SDK backend for the codec under "Encoder path" withEncoderLists::choose:Auto-> SDKAuto(hardware first where listed);PreferHardware->Hardwareif the hardware backend has the codec, elseSoftware;PreferSoftware->Softwareif software has it, elseHardware(H265); a codec no backend has ->Auto(the SDK publishes VP8).screen_video_optionstakes the chosen backend.hardware_encoders: vaapi/nvenc, fromVideoEncoderBackend::list_available(), as spikes §1.6 asks);voice: screen share publishedlogs the Encoder path, the backend chosen and whether it is hardware.CodecCap { H264, hardware: true }keeps coming from the hardware backend's run-time list (VAAPI or NVENC)..forgejo/workflows/ci.yaml,release.yaml): installlibva-devand fail early ifpkg-configcannot findlibva/libva-drm, sowebrtc-syscompiles its VAAPI H264 encoder. libva stays lazily loaded (dlopen("libva.so.2")after anIsSupported()check), so no new runtime dependency; thelinux-cleanjob still proves the AppImage starts without it.README.md"Hardware video encoding (Linux)" (VAAPI build/run-time conditions,LIBVA_DRIVER_NAME, how to build with NVENC viaCUDA_HOME+ clean target dir,LIVEKIT_PREFERRED_HW_ENCODER);crates/fluxer-voice/README.md; spikes §5.How it was tested
backend_mapping_from_encoder_mode(table over a VAAPI host, a host without hardware, an NVENC-like host),publish_options_from_paramsupdated.FLUXER_HW_ENCODER_TESTS=1, not in CI), on the developer machine: Ryzen 9 9950X, VAAPI H264 on the Radeon 610M iGPU (Mesa 26.2.6 radeonsi, renderD129), RTX 5090 present but decode-only through VAAPI, no CUDA toolkit, livekit-server 1.12.0 --dev on loopback,LIBVA_DRIVER_NAMEunset:vaapi_reports_hardware_and_publishespassed: H264 reported as hardware; Prefer hardware ->VAAPI H264 Encoder(hardware=true), Prefer software ->OpenH264(hardware=false); the viewer decodes the pattern from both.vaapi_against_software_costran at 2 and 6 bits of noise, 1080p30/60: table in spikes §5.2. VAAPI is 0.15-0.2 core at 1080p30 against 0.6-1.0 for VP9/AV1, with the same PSNR on screen-like content; the iGPU caps frame rate (1080p60 at 40-43 fps). The machine was loaded by other agents' builds, so the numbers are noisy.FLUXER_LIVEKIT_TESTS=1interop suite (15 tests) passed against the same server.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Deviations from the plan
libva-dev, and the SDK falls back on its own when a requested backend lacks the codec. The failing step was the unit test (new types). The value of the change is choosing the backend up front from the probe (no SDK fallback warning, correct hardware reporting in the log) plus the CI/release/docs side.FLUXER_HW_NOISE_BITS).README.mdholds the release-build docs (no separate release doc exists).CodecCapabilitiesmarks H264 hardware regardless of Encoder path, so with Prefer software the ranking would still put H264 (now OpenH264) first.illegal short term buffer state detectedon VAAPI streams (mostly 1080p60); frames still decode. Recorded in spikes §5.2, not acted on.Closes #165
🤖 Generated with Claude Code
Independent review: Screen share 18 (hw-encode-linux)
Scope:
git diff 9e7acfb8..origin/screenshare-18-hw-encode-linux(4f416a3), read cold.Checks
backend_mapping_from_encoder_mode(rtc.rs) covers Auto / PreferHardware / PreferSoftware against VAAPI, no-hardware and NVENC lists, including the H265 hardware-only and "no backend encodes it" cases. Realvaapi_reports_hardware_and_publishes(tests/hw_encoder.rs,#[ignore]+FLUXER_HW_ENCODER_TESTS=1) assertsCodecCap { codec: H264, hardware: true }is reported, that "Prefer hardware" publishes through VAAPI with the hardware flag set, that "Prefer software" does not, and that a viewer decodes the pattern both times. OK.libva-devin ci.yaml and release.yaml, with a pkg-config guard that fails the build early (libva libva-drm; webrtc-sys build.rs readslibvaincludedir and dlopens at run time). H264 is reported as hardware from the per-backend probe. "Encoder path" is honoured viaEncoderLists::choose. Spikes §5 has the CPU/quality table for 1080p30 and 1080p60. NVENC is documented in the README (CUDA_HOME, clean target dir). OK.EncoderLists,EncoderChoiceandProbeare private, and no LiveKit or libwebrtc type reaches a public signature. No new dependencies. The only key in the test is the publiclivekit-server --devpair, the same one livekit_interop.rs uses. No token in the logs: the new fields are the encoder path, the backend and the hardware flag. OK.capabilities_fromis unchanged.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a clean review worktree: all steps passed.backend_mapping_from_encoder_modeandpublish_options_from_paramsran and passed. The hw tests skip without the env var.Findings
encoder_lists()falls back to empty lists (everythingAuto) only if the blocking probe task panics. In that case "Prefer software" quietly becomes the SDK's hardware-first choice. This is an unlikely path, and the warning is logged. No action needed.Verdict: approve. No blocking findings, and local CI is green.