"Zero-copy" Linux screen capture plugin for OBS that uses libdrm and dmabuf

Related tags

Audio obs-kmsgrab
Overview

linux-kmsgrab plugin for OBS

Introduction

This plugin is a proof-of-concept libdrm-based screen capture for OBS. It uses DMA-BUF to import CRTC framebuffer directly into EGL texture in OBS as a source. This bypasses expensive double GPU->RAM RAM->GPU framebuffer copy that is invoked by anything X11-XSHM-based.

It is Linux-Only, as DMA-BUF is a Linux-only thing. Other platforms might have similar functionality, but I'm totally not an expert.

It is almost completely agnostic of any windowing system you might have: it works reasonably well with both X11 and Wayland, and theoretically could work even with bare KMS terminals.

However, on Wayland I'd recommend using something like https://hg.sr.ht/~scoopta/wlrobs instead -- it also uses DMA-BUF, but supposedly does this in a less hacky way.

Building

It requires latest master OBS, as EGL support is very fresh and has not yet been released. You'll need to compile and install master OBS yourself. Make sure that installation prefix is fed into cmake invocation too, as it needs access to latest OBS headers from master and won't work with any older released version.

Generally it works like this:

# Clone and cd
mkdir build && cd build
export CMAKE_PREFIX_PATH=<master-obs-prefix>
cmake .. -GNinja -DCMAKE_INSTALL_PREFIX="$CMAKE_PREFIX_PATH"
ninja
ninja install

By default this plugin will use Polkit's pkexec to run the linux-kmsgrab-send helper utility with elevated privileges (i.e. as root). This is required in order to be able to grab screens using kms/libdrm API, as we completely sidestep X11/Wayland management of current drm context. When OBS starts you'll be presented with polkit screen asking for root password, and then you'll be asked again when configuring the capture module.

If you don't have Polkit set up, you need to compile this plugin with -DENABLE_POLKIT=NO cmake flag and entitle the linux-kmsgrab-send binary with CAP_SYS_ADMIN capability flag manually, like this:

sudo setcap cap_sys_admin+ep "$CMAKE_PREFIX_PATH/lib64/obs-plugins/linux-kmsgrab-send"

Note that this has serious system-wide security implications: just having this linux-kmsgrab-send binary lying around with caps set will make it possible for anyone having local user on your machine to grab any of your screens. Decide for yourself whether that's a concerning threat model for your situation.

Known issues

  • there's no way to specify grabbing device (in cause you have more than one GPU), it will just use the first available
  • no sync whatsoever, known to rarily cause weird capture glitches (dirty regions missing for a few seconds)
  • no resolution/framebuffer following -- may break if output resolution changes
  • may conflict with some x11 compositors and wayland impls
Issues
  • Installation troubles

    Installation troubles

    Having built/installed both obs-studio and this plugin no new source appears in obs. What is the exact place the files should be placed to? because it doesnt look like installing places them correctly.

    opened by SolitudeSF 12
  • Fixes for OBS 27

    Fixes for OBS 27

    This includes:

    • [x] updated signature for gs_texture_create_from_dmabuf
    • [x] multiple planes with drmGetModeFb2

    This should include:

    • [ ] original drmGetModeFb path for a single-plane query (not all configs support Fb2)

    This does not include:

    • fixes for recent sway/wlroots/... breaking passing dma-buf fds with EGL texture creation returning ENOMEM. This is being investigated
    opened by w23 1
  • Cannot create EGLImage: Arguments are inconsistent

    Cannot create EGLImage: Arguments are inconsistent

    Hi! OBS Studio 27 now require fourcc in gs_texture_create_from_dmabuf function. I edited code and added fourcc, but it doesn't work. I also tried to set fourcc manually, based on this OBS-Studio deleted code, but i get similar error.

    Code:

    ctx->texture = gs_texture_create_from_dmabuf(fb->width, fb->height,
    	GS_BGRA, // FIXME handle fourcc?
    	fb->fourcc,  // i added fourcc there
    	1, // FIXME handle planes
    	ctx->fbs.fb_fds + index,
    	&stride,
    	&offset,
    	NULL // FIXME what are modifiers? we just don't know
    

    Error:

    error: Cannot create EGLImage: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).```
    bug help wanted 
    opened by scaledteam 17
  • Proper synchronization

    Proper synchronization

    Figure out whether libdrm provides any APIs for synchronization, and use them to make sure that we're uploading/using the DMA-BUF-backed texture at the right moment.

    opened by w23 0
Owner
Ivan Avdeev
Eclectic Engineer
Ivan Avdeev
OBS Plugin to capture CS:GO with Trusted Mode enabled

OBS Plugin to capture CS:GO with Trusted Mode enabled Ever since Valve introduced Trusted Mode you could no longer capture Counter-Strike: Global Offe

Gregor Steiner 101 Jun 22, 2022
An OBS plugin for removing background in portrait images (video), making it easy to replace the background when screen recording.

OBS Plugin: Background Removal Introduction Building MacOSX Linux / Ubuntu Windows Download Check out the latest releases for downloads and install in

Roy Shilkrot 1.1k Jun 24, 2022
An OBS plugin for Zoom/Meet-like virtual background feature.

OBS Virtual background plugin English / Japanese OBS Virtual background plugin is a plugin for OBS. This plugin allows you to crop the background area

KOUNOIKE Yuusuke 146 Jun 16, 2022
OBS Plugin with image that reacts to sound source.

OBS Image Reaction Plugin Image that reacts to sound source. Installing binaries Download binaries from Releases. For Windows, Move the contents of pl

null 26 Jun 27, 2022
audio monitor filter for OBS Studio

Audio Monitor dock and filter for OBS Studio Plugin for OBS Studio to add Audio Monitor dock and filter. It allows you to put the audio of a OBS sourc

Exeldro 177 Jun 19, 2022
Single file audio playback and capture library written in C.

A single file library for audio playback and capture. Example - Documentation - Supported Platforms - Backends - Major Features - Building - Unofficia

David Reid 2.3k Jun 29, 2022
Capture audio from a microphone on your Raspberry Pi Pico or any RP2040 based board. 🎤

Capture audio from a microphone on your Raspberry Pi Pico or any RP2040 based board. ??

Arm Developer Ecosystem 95 May 24, 2022
Linux client for Archo Music written in C++, uses Qt Framework.

ArchoMusicLinux Linux client for Archo Music written in C++, uses Qt Framework. For the original client, visit Archo Music Compiling Setting up the li

GianXD 2 Nov 13, 2021
HamMessenger is a portable device that uses a ham radio and the APRS protocol as a medium to send and receive text messages.

HamMessenger is a portable, battery powered device that runs on a microcontroller and interfaces with an inexpensive ham radio to send and receive text messages and provide position updates using the APRS protocol. Messages and position updates sent via HamMessenger can be viewed on sites such as aprs.fi. HamMessenger messages are NOT encrypted!

null 186 Jun 13, 2022
RetroWave is a hardware sound board series that uses vintage sound chips and works with modern hardware.

RetroWave Authentic sounds from vintage sound chips, on modern hardware! Introduction RetroWave is a hardware sound board series that uses vintage sou

SudoMaker 42 Jun 5, 2022
A weird distortion and lowpass plugin

Delta Limiter Building ./waf clean configure build Documentation pandoc -s user_manual.md -o user_manual.html pandoc -s user_manual.md -o user_manual.

Hannes Braun 2 Jan 26, 2022
PeakEater is a free open-source VST3/AU waveshaper plugin

PeakEater Free open source VST3/AU wave shaping plugin for macOS and Windows. View Demo · Download · Report Bug Table of Contents About The Project Fe

Vladyslav Voinov 40 Apr 14, 2022
BYOD is a guitar distortion plugin with a customisable signal chain that allows users to create their own guitar distortion effects.

BYOD is a guitar distortion plugin with a customisable signal chain that allows users to create their own guitar distortion effects. The plugin contains a wide variety of distortion effects from analog modelled circuits to purely digital creations, along with some musical tone-shaping filters, and a handful of other useful processing blocks.

null 144 Jun 28, 2022
ChowKick is a kick drum synthesizer plugin based on creative modelling of old-school drum machine circuits

ChowKick is a kick drum synthesizer plugin based on creative modelling of old-school drum machine circuits. MIDI input to the plugin triggers a pulse with a parameterized size and shape. The pulse is then passed into a resonant filter which can be tuned to a specific frequency, or matched to the frequency of the incoming MIDI notes.

null 99 Jun 27, 2022
SuperCollider as a VST3 plugin

PluginCollider PluginCollider is an experimental fork of https://github.com/supercollider/SuperColliderAU and it is still not complete since it only b

Pascal Gauthier 22 Jun 11, 2022
Wolf MidiCurve is a MIDI remapping plugin.

Wolf MidiCurve is a MIDI remapping plugin. It can be built as an LV2 or VST plugin and as a standalone Jack application.

Wolf Plugins 7 Nov 18, 2021
Audio Plugin API

Audio Plugin API

null 798 Jun 20, 2022
Audacity is an easy-to-use, multi-track audio editor and recorder for Windows, Mac OS X, GNU/Linux and other operating systems

Audacity is an easy-to-use, multi-track audio editor and recorder for Windows, Mac OS X, GNU/Linux and other operating systems. Audacity is open source software licensed under GPL, version 2 or later.

Audacity 7.6k Jun 23, 2022
Sneedacity (formerly Audacity) is an easy-to-use, multi-track audio editor and recorder for Windows, Mac OS X, GNU/Linux and other operating systems.

Sneedacity (formerly Audacity) is an easy-to-use, multi-track audio editor and recorder for Windows, Mac OS X, GNU/Linux and other operating systems. Sneedacity is open source software licensed under GPL, version 2 or later.

Sneed's Feed & Seed 868 Jun 26, 2022