Capture from the first active plane, download the result to normal frames and encode

This will only work if the framebuffer is both linear and mappable - if not, the result may be scrambled or fail to download.

ffmpeg -f kmsgrab -i - -vf 'hwdownload,format=bgr0' output.mp4

Capture from CRTC ID 42 at 60fps, map the result to VAAPI, convert to NV12 and encode as H.264.

ffmpeg -crtc_id 42 -framerate 60 -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi output.mp4