OBS Screen Recording on Wayland with PipeWire

Screen recording on Linux has evolved significantly with the shift from X11 to Wayland. Under Wayland, direct screen capturing by arbitrary applications is restricted for security, requiring a modern framework to safely share visual data. This article explains how the Linux operating system coordinates between the Wayland compositor, XDG Desktop Portals, PipeWire, and OBS Studio to enable secure, high-performance display and window capture.

The Wayland Security Model

In legacy X11 sessions, any running process can query the display server and read pixel data from any other window. Wayland eliminates this design flaw by isolating each application's buffers. Only the display server—known as the Wayland compositor (such as Mutter in GNOME or KWin in KDE Plasma)—knows the composition and contents of the entire desktop. Because applications cannot inspect each other's memory spaces, software like OBS Studio cannot capture pixels directly from the display server using legacy methods.

Permission Negotiation via XDG Desktop Portal

To capture the screen without violating the security model, Wayland uses the xdg-desktop-portal architecture. When you add a "Screen Capture (PipeWire)" source in OBS Studio, OBS initiates an inter-process communication (IPC) request over D-Bus to the portal service.

The portal opens a native desktop dialog asking the user to choose what to capture—an entire monitor, a specific application window, or a virtual display. Once the user approves the selection, the compositor generates a media stream. This ensures that no application can record display output without explicit user consent.

Stream Transport via PipeWire

Once access is granted, the compositor registers the outgoing video stream with PipeWire, the low-latency audio and video processing server standard on modern Linux systems.

PipeWire acts as a secure, neutral broker between the compositor and OBS Studio:

  1. The portal sends a PipeWire node ID and a file descriptor back to OBS via D-Bus.
  2. OBS connects to the local PipeWire daemon and requests the stream matching that node ID.
  3. PipeWire routes the raw video frames directly from the compositor’s output buffer to OBS Studio's capture plugin.

Zero-Copy Performance with DMA-BUF

To ensure smooth performance during high-resolution, high-framerate recording, the PipeWire pipeline relies heavily on DMA-BUF (Direct Memory Access Buffers).

Instead of copying pixels from video memory to system RAM and then back to the GPU for encoding, the compositor shares GPU memory buffer handles with PipeWire. PipeWire forwards these hardware handles to OBS Studio. This "zero-copy" transfer allows OBS to pass video frames directly to hardware-accelerated video encoders (such as VA-API, NVENC, or AMF) on the GPU, avoiding CPU bottlenecks and minimizing latency.