Java – I’m writing a screen capture module in Java, but I’m having serious performance issues writing screenshots to disk. What else can I do


I'm writing a screen capture module using the Robot class. I'm taking screenshots of the application every x milliseconds and writing them to disk. After screen capture is finished, I'm compiling the screenshots to video with FFMPEG.

However, writing images to disk is extremely slow and grinds my application to a halt. What am I missing? Is there a better way to write a simple screen capture module?

Edit: I've tried several ways of writing the images to disk, and all are very slow. I've been sticking with the following, due to its ease of use:

ImageIO.write(bufferedImage ,"jpg", file);

Best Solution

Or encode the image into video format right when you capture the image, and avoid writing the large temporary file at all. Full code using Xuggler can be found here:

Xuggler Screen Capture Demo Code

Related Question