Skip to content

xnqs/obs-kmscap

Repository files navigation

OBS KMS Capture Plugin (obs-kmscap)

obs-kmscap is a zero-copy screen capture plugin for OBS Studio on Linux. It serves as the spiritual succesor to w23's obs-kmsgrab Instead of capturing through a display server (like X11 or Wayland), it hooks directly into the Linux kernel's Direct Rendering Manager (DRM) and Kernel Mode Setting (KMS) subsystems. This allows it to capture hardware framebuffers natively and export them directly to OpenGL/EGL as DMA-BUF file descriptors for raw, incredibly low-overhead screen recording.

Features

  • Zero-Copy Capture: Directly maps hardware buffers into OpenGL textures via EGL DMA-BUFs avoiding slow CPU memory copies entirely.
  • Display Server Agnostic: Operates completely under the compositor, fully supporting Xorg, Wayland (Sway, Gnome, KDE), and pure raw TTY environments right out of the box!
  • Hardware Cursor Support: Tracks and natively overlays the hardware cursor by querying the DRM Universal Cursor Plane and its atomic coordinates (CRTC_X & CRTC_Y).
  • Graceful Fallbacks: Transparently interfaces with bleeding-edge DRM implementations (GetFB2 with modifiers support) while gracefully falling back to legacy kernel paths (GetFB) if needed.
  • GPU Agnostic: Functions optimally on AMD and Intel configurations, as well as Nouveau and relatively modern proprietary NVIDIA stacks (with KMS enabled).

Requirements

To use this plugin, your system MUST effectively meet the following strict requirements:

  1. Native Linux kernel with working DRM & KMS drivers loaded.
  2. The obs executable must possess the CAP_SYS_ADMIN elevated privilege so the plugin can traverse memory isolation boundaries to map framebuffers generated by your active desktop compositor.

Building and Installation

Arch-based distributions

If you are on an Arch-based distribution, you can use the AUR package obs-kmscap-git.

Standard building and installation

This is a standard CMake project. To build and install the plugin from source globally into /usr:

# 1. Generate the CMake configuration files:
cmake -S . -B build_x86_64 -DCMAKE_INSTALL_PREFIX=/usr

# 2. Compile the binaries:
cmake --build build_x86_64

# 3. Install locally (requires sudo to write to /usr/lib)
sudo cmake --install build_x86_64

Setting Linux Capabilities

Because the Linux kernel isolates GPU memory framebuffers by their allocator processes (typically your Wayland/X11 display server), regular applications are blocked from intercepting the handles needed to read them. You must grant the helper binary the system privileges to read these handles:

# Grant the capability to the helper binary
sudo setcap cap_sys_admin+ep $(which obs-kmscap-helper)

Usage

Once installed and provisioned:

  1. Make sure OBS is completely restarted after you alter the setcap permissions, otherwise changes won't be applied to the environment.
  2. Add a new generic Source to an OBS Scene.
  3. Select "KMS Screen Capture".
  4. In the component properties window, configure the following:
    • DRI Card: Select the target GPU (usually /dev/dri/card0 or /dev/dri/card1).
    • Display Output (CRTC): Select which active monitor node to capture.
    • Capture Cursor: Check to trace and overlay the native GPU cursor plane onto the render.

Limitations & Known Issues

  • NVIDIA Proprietary Drivers: Standard DRM/KMS features can be spotty on proprietary NVIDIA stacks depending on the specific branch. You must forcibly enable KMS by passing nvidia-drm.modeset=1 as a kernel boot parameter.
  • Security Implications: Because the plugin runs the helper binary with the CAP_SYS_ADMIN capability (which essentially grants administrative system boundaries to the binary), please take note of the potential security implications, of any user on your system being able to capture any screen on your system.

About

fast zero-copy screen capture for Linux, but better ⚡

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors