bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.4k stars 1.57k forks source link

x11grab gpu accelerate #2170

Open tank520 opened 5 months ago

tank520 commented 5 months ago

I want to use gpu acceleration when record x11 screen, code below:

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(":0.0");
grabber.setFormat("x11grab");
grabber.setFrameRate(20);
grabber.setOption("hwaccel", "cuda");
grabber.setOption("hwaccel_device", "0");

when i see output in nvidia-smi, but the process is not showing up. is something wrong with the code ? BTW, the command line takes effect ffmpeg -f x11grab -framerate 20 -hwaccel cuda -i :0.0 out.mp4

saudet commented 5 months ago

We probably need to enhance FFmpegFrameGrabber somehow for that to work, but contributions are welcome!