您可以在Java中使用ffmpeg包装 - Xuggler和内置Java Robot类。这里是Xuggler的示例代码。
final Robot robot = new Robot();
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
// First, let's make a IMediaWriter to write the file.
final IMediaWriter writer = ToolFactory.makeWriter("output.mp4");
// We tell it we're going to add one video stream, with id 0,
// at position 0, and that it will have a fixed frame rate of
// FRAME_RATE.
writer.addVideoStream(0, 0,
FRAME_RATE,
screenBounds.width, screenBounds.height);
// Now, we're going to loop
long startTime = System.nanoTime();
for (int index = 0; index < SECONDS_TO_RUN_FOR*FRAME_RATE.getDouble(); index++)
{
// take the screen shot
BufferedImage screen = robot.createScreenCapture(screenBounds);
// convert to the right image type
BufferedImage bgrScreen = convertToType(screen,
BufferedImage.TYPE_3BYTE_BGR);
// encode the image to stream #0
writer.encodeVideo(0,bgrScreen,
System.nanoTime()-startTime, TimeUnit.NANOSECONDS);
System.out.println("encoded image: " +index);
// sleep for framerate milliseconds
Thread.sleep((long) (1000/FRAME_RATE.getDouble()));
}
// Finally we tell the writer to close and write the trailer if
// needed
writer.close();
另一个选项是Screentoaster网站 - 但我记下确定它提供的帧率。
对不起,在Windows下运行 - 不喜欢它非常:) – Warlax 2010-02-02 22:24:00