I am working on a Java application to record the screen. I am doing this using a Robot to take several screenshots, save them to a temporary folder and I then use JpegImagesToMovie.java to build these into a QuickTime movie file.
The problem I am experiencing is that, despite developing my script to run at 20fps, I only achieve around 5fps. I have tracked this down to the disk speed in that it is taking too long to save the image to disk and this is holding up the rest of the script.
Next, I modified the script to store the images in an array of BufferedImages and then write them to disk once recording has stopped which fixes the frame rate, however when recoding, Java will quickly run out of memory (After a few seconds of recording).
Does anyone have any ideas or experience with doing this. One solution I can think of is if there is a way to increase the compression on the JPEG images but I am unsure of how to do this.
Any help would be greatly appreciated!
One option you might want to consider is to do the processing on multiple threads. One thread can be dedicated to taking screenshots, and many other threads can write to disk. Since writing to disk is not a CPU-intensive operation you can have many of them running concurrently, each one writing to a different files. The following program works fine on my machine with 512M heap size: