SUMMARY On Intel UHD 620 (8th gen KBL-R), when using KDE with wayland backend, the default DRM color format is ARGB2101010 (30-bit). When trying to use kmsgrab with ffmpeg in this mode, it results in the error "drm format not supported by vaapi" since there is no match in vaapi for this drm format. On specifying KWIN_DRM_PREFER_COLOR_DEPTH=24 in /etc/environment, the DRM format changes to ARGB8888 (24-bit), this makes the ffmpeg kmsgrab successful but the output video is garbled. This works completely fine on Kwin X11 and GNOME wayland, the only difference I could find was that in both these cases, the color format was XRGB8888. Here is the ffmpeg command I am running: ffmpeg -device /dev/dri/card0 -f kmsgrab -framerate 60 -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v hevc_vaapi output.mkv I have tried using h264_vaapi, vp8_vaapi codecs also, the result is same. STEPS TO REPRODUCE 1. Login to Plasma wayland with KWIN_DRM_PREFER_COLOR_DEPTH=24 2. Record screen with ffmpeg kmsgrab using vaapi. OBSERVED RESULT Video output is grabled EXPECTED RESULT Normal screen capture SOFTWARE/OS VERSIONS Linux/KDE Plasma: 6.3.4-zen1-1-zen (64-bit)/5.27.5 (available in About System) KDE Plasma Version: 5.27.5 KDE Frameworks Version: 5.106.0 Qt Version: 5.15.9 ADDITIONAL INFORMATION Mesa version: 23.2.0-devel (git-613eb64011) ffmpeg version: 6.0
Created attachment 159342 [details] Garbled video when recorded with KWIN_DRM_PREFER_COLOR_DEPTH=24
Created attachment 159343 [details] drm_info on KDE wayland with KWIN_DRM_PREFER_COLOR_DEPTH=24
Update I found that when I run the emulator yuzu in full screen, the DRM format changes to XRGB8888 and the screen recording also works fine in that case. Attaching the captured video.
Created attachment 159351 [details] Correct video with yuzu running in full screen mode (DRM format switches to XRGB8888)
Most likely this is caused by either kmsgrab or vaapi not handling the buffer format + modifier combination properly. If you get a correct image on the screen, KWin isn't doing anything wrong. In general, please use the xdg portal system to do screen casting, which handles these sort of things automatically. kmsgrab is not a good way to do screen recording and will only get more problematic over time, as we start to use more hardware features it can't deal with.