Make in-process capture and encoding an opt-in feature

Address PR review:

- The FFmpeg 6 bindings (AVChannelLayout, ffmpeg-next 6.1) do not build on
  the 22.04 runners, which ship FFmpeg 4.4. The default build no longer
  depends on libav at all, so `cargo test --locked` and the release job on
  22.04 no longer compile that code.
- The release tarball no longer links the build machine's libav SONAMEs.
  Default builds use the FFmpeg child process for video and audio again.
- `UU_FFMPEG_ROOT` / config `ffmpeg_root` now selects the child-process path
  even in an inproc-av build, so a bundled FFmpeg with working NVENC is not
  silently bypassed.

Build with `--features inproc-av` (FFmpeg 6 dev packages, Ubuntu 24.04) to
get in-process capture, encoding and Opus. CI has a test-inproc job for it.
`UU_VIDEO_PIPELINE=process` still forces the child path for video.

Probes on ros2go-gpu (440 Hz tone, 5 s):
  default (ffmpeg child): 44.0 packets/s, 132 kbps, max gap 43 ms
  inproc-av:              49.7 packets/s, 133.5 kbps, max gap 22 ms
desktop-video-probe under inproc-av with UU_FFMPEG_ROOT=/usr uses the child
path (no `pipeline=in-process` in the log); without it, in-process.
This commit is contained in:
ferstar authored and VallierDev committed 2026-10-15 07:43:21 +08:00
1 parent dd5d6a6c13
commit 2355790e17
10 files changed
+106 -25

No files matched your search

+6 -2
View File
@@ -110,7 +110,9 @@ impl EncoderTask {
}
}
#[cfg(feature = "inproc-av")]
struct StopOnDrop(Arc<AtomicBool>);
#[cfg(feature = "inproc-av")]
impl Drop for StopOnDrop { fn drop(&mut self) { self.0.store(true, std::sync::atomic::Ordering::Relaxed); } }
async fn read_encoder(
@@ -131,6 +133,7 @@ async fn read_encoder(
}
/// Capture and encode inside this process; each packet is one access unit.
#[cfg(feature = "inproc-av")]
async fn read_inprocess(
config: crate::inproc_encoder::Config, latest: mpsc::Sender<Arc<CompleteFrame>>,
sequence: Arc<std::sync::atomic::AtomicU64>, idr: Arc<AtomicBool>,
@@ -165,10 +168,11 @@ fn rate_args(settings: &VideoSettings) -> (String, String) {
async fn read_encoder_with(
size: (u32,u32),display:String,portal:Option<Arc<crate::portal::PortalSession>>,latest:mpsc::Sender<Arc<CompleteFrame>>,gpu:bool,sequence:Arc<std::sync::atomic::AtomicU64>,
mut settings: VideoSettings, idr: Arc<AtomicBool>,
mut settings: VideoSettings, #[cfg_attr(not(feature = "inproc-av"), allow(unused_variables))] idr: Arc<AtomicBool>,
)->Result<(),String>{
let wayland=display.starts_with("wayland:");
if !wayland && portal.is_none() && !crate::inproc_encoder::disabled() {
#[cfg(feature = "inproc-av")]
if !wayland && portal.is_none() && crate::inproc_encoder::selected() {
let max_kbps = settings.max_kbps().unwrap_or(30_000) as i64;
let config = crate::inproc_encoder::Config {
display: display.clone(), input: size, output: settings.output, fps: u32::from(settings.fps),