How to take a screenshot of desktop fast with Java in Windows (ffmpeg, etc.)?

后端 未结 4 724
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 09:56

I would like to use java to take a screenshot of my machine using FFMPEG or some other solution. I know linux works with ffmpeg without JNI, but running it in Windows does n

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 10:25

    You will need to use JNI or JNA to call some combination of CreateCompatibleBitmap, XGetImage, DirectX or OpenGL to grab a screenshot and then copy some raw bitmap data back to Java. My profiling showed a speed up of about 400% over the Robot class when accessing raw bitmap data on X11. I have not tested other platforms at this time. Some very early code is available here but I haven't had much time to work on it recently.

提交回复
热议问题