0015: The server captures from PipeWire and encodes with libavcodec
- Status: Accepted (owner, 2026-11-15: "let's proceed" on one library, libavcodec)
- Date: 2026-11-15
Context
ADR 0012 planned GStreamer for the server's encode, as Wolf does. Measured on the host's GPU at 1080p60 (2026-11-15): both GStreamer H.264 encoders (vah264enc, vaapih264enc) stop near 32 fps whatever the settings, while ffmpeg's h264_vaapi holds 63 fps; HEVC is fine in both. Wolf needs GStreamer for what we do not have: a compositor element per app and pipelines typed into its config. Sunshine and Apollo capture with their own code and encode with libavcodec; Moonshine uses Vulkan Video directly (newer GPUs only).
Decision
One library: libavcodec encodes video (VAAPI for AMD and Intel, NVENC for NVIDIA; Vulkan encoders later through the same API) and Opus audio. Capture reads the screen's Gamescope node with libpipewire directly; several clients on one screen are several readers of that node. Wolf's rtpmoonlightpay packetizer and FEC (MIT, about 640 lines written around GStreamer buffers) are ported to plain buffers, credited. HEVC is offered first; the client still picks the codec in Moonlight.
Consequences
- No GStreamer in the server; no raw pipeline strings for users (a Couchdogs setting can still force H.264 or cap the bitrate).
- We own the capture loop, including repeating the last frame when Gamescope sends none.
- Supersedes the encode sentence of ADR 0012; the rest of 0012 stands.
- ADR 0017 replaces CBR with VBR at the same peak (a still screen stayed blocky after a busy scene).