Recipes
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)
Src: https://ffmpeg.org/pipermail/ffmpeg-user/2018-June/040338.html
Wishlist
kms capture to OBS (is there a plugin somewhere?)
Resources
- https://www.ffmpeg.org/ffmpeg-devices.html#kmsgrab
- https://trac.ffmpeg.org/wiki/Hardware/VAAPI#DeviceSelection
- https://gist.github.com/Brainiarc7/24de2edef08866c304080504877239a3
just saw your comment @colemickens
Yeah, I'm aware of wlr-export-dmabuf-unstable-v1 (https://obsproject.com/mantis/view.php?id=719#c3754). 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?