0

I have this command to record my screen with vaapi on linux:

ffmpeg -y -device /dev/dri/card1 -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=format=nv12' -c:v h264_vaapi -qp 24 output.mkv 

And it works mostly fine except the colors are wrong. I've found that with nvenc if I set the pixel format to gbrp, it outputs correct colors, and with cpu encoding if I use libx264rgb, that outputs correct colors.

But for recording with vaapi I have failed to figure out a way to get correct colors, and the main reason for that is that I can only use it for screen recording with scale_vaapi=format=nv12 set, I haven't found a way around it, the gpu simply can't use any other pixel format (it should be able to use yuv420p but haven't gotten it to work), and using the normal format filter instead of the scale_vaapi subfilter always fails for me for some reason (on kmsgrab anyways, when I'm encoding files it's the opposite, i can't use the scale_vaapi filter, need to use the normal format filter instead)

Which means I would either need a different way of fixing the color issues (a tall order, no normal filters seem to work in conjunction with scale_vaapi), or a way to ,do colorspace conversion over to the cpu (software) instead of the gpu to use the same method.

After several hours of messing around I have found very few methods to affect the colors, and none of them really useful.

This appears to be a fairly common issue, I've seen many others struggling with this but nothing much in the way of solutions.

2
  • Try adding -format yuyv422 next to -f kmsgrab
    – Gyan
    Commented Jul 29 at 4:40
  • @Gyan I tried with yuv420p, yuv422p, gbrp, all of them just gave me the same error: [kmsgrab @ 0x565227163f00] Framebuffer pixel format 34325258 does not match expected format.
    – Cestarian
    Commented Jul 29 at 4:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.