Skip to content

Instantly share code, notes, and snippets.



Last active Feb 21, 2021
What would you like to do?
Streaming screen capture under Wayland


kmsgrab capture with ffmpeg

sudo LIBVA_DRIVER_NAME=iHD ffmpeg -crtc_id 69  -framerate 60 -f kmsgrab -i - -vaapi_device /dev/dri/renderD128 -filter:v hwmap,scale_vaapi=w=1920:h=1200:format=nv12 -c:v h264_vaapi -profile:v constrained_baseline -level:v 3.1 -b:v 20000k test.mp4

LIBVA_DRIVER_NAME=iHD ffmpeg -device /dev/dri/card0 -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi -vstats output.mp4

Allow kmsgrab capture as non-root user

Unsafe but needed

sudo setcap cap_sys_admin+ep $(which ffmpeg)



kms capture to OBS (is there a plugin somewhere?)




This comment has been minimized.

Copy link

@colemickens colemickens commented Feb 1, 2019

Hi, have you seen these things?

The wlroots/sway folks plan to address "window|region capture" in the future as well. There are a number of Wayland compositors using wlroots and it seems increasing collaboration between the wlroots and KDE folks.

My hope has been that someone would adapt wlstream to be an obs plugin. It seems that wlstream has done the hard parts of getting an ffmpeg-compatible stream, without root, but I don't know enough about OBS APIs, C, ffmpeg, etc, to be able to figure out how to adapt the frames from wlroots to whatever OBS wants.

I think there's also some wondering if someone should build a wlroots<->pipewire bridge and then a Pipewire bridge for OBS, but I don't know the merits of the various approaches.

It would be cool if there was a repo or a rallying point for various Wayland/OBS folks to collaborate...


This comment has been minimized.

Copy link
Owner Author

@edrex edrex commented Feb 11, 2019

just saw your comment @colemickens

Yeah, I'm aware of wlr-export-dmabuf-unstable-v1 ( I was just wanting to get something working for actual streaming to an RTMP server.

I wonder: could ffmpeg be manually pointed to the right surface for capturing without root via the protocol, as wlstream does, or will it need patching?


This comment has been minimized.

Copy link
Owner Author

@edrex edrex commented Feb 11, 2019

I was never able to get dmabuf-capture working, so i guess that's step 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment