开发者

Java applet screen capture to a video

开发者 https://www.devze.com 2022-12-16 20:12 出处:网络
I wanted to find out how can one capture screencast using java. I know that using Robot class one can get a screenshot but how do I go about ca开发者_JS百科pturing it as a video and then uploading it

I wanted to find out how can one capture screencast using java. I know that using Robot class one can get a screenshot but how do I go about ca开发者_JS百科pturing it as a video and then uploading it to the server? How exactly would that work?

ideas?


With a pure Java solution, I doubt that it will work, but it depends of course on what your interpretation of "video".

On my desktop with a 1920x1200 resolution, I am able to get about 20 frames per second when using the Java Robot to capture the entire screen. Since each image contains >6 MByte of uncompressed data, I would need more than 1 Gbps bandwidth to transmit the raw data of these images to a server. Most probably, requiring so much bandwidth is not acceptable, so you either have to decrease the number of frames per second or apply some kind of compression to the images.

One possibility is to compress each image using one of the image formats supported by ImageIO. The size of the compressed images will of course depend heavily on what is actually shown on the screen, but the performance of the compressors is not particularly good. Compressing to PNG ought to give the best lossless compression ratio for most desktop content, but at least my computer is only able to process just about 2 frames per second. Using the JPEG compressor with default quality settings reaches about 5 frames per second.

Using common video codecs through an abstraction layer like jffmpeg will probably achieve both better performance and better compression ratio, but I doubt that mainstream video codecs like WMV or H.264 are suitable for common desktop content.

If you really require a pure Java solution (and are not able to use any of the available standalone software, which do what you're asking for), I would make an attempt to implement my own, simple compression algorithm. With common desktop activity, there ought to be very little difference between most consecutive screen shots, so what might work quite well is to transmit the first frame completely and after that implement an algorithm to roughly detect rectangles, in which changes have been made and then transmit only these combined with JPG or preferrably (quality) PNG compression.


Or use Xuggler, a better wrapper for FFmpeg in Java. In fact, the code for capturing the screen and encoding the video is one of the standard tutorials.


I'm also curious about this. https://www.screencast.com/ is currently doing just this with a pure java (or at least straight out of the browser) experience.


You can just use something like Java to a native FFMPEG build, and execute the command line at runtime. Here is an applet that I made that does just that: http://have2chat.net/screencast/


I have downloaded the main capture *.JAR file for the Screencast-O-Matic.com. To download the file:

  1. Go to http://screencast-o-matic.com/jars/ScreencastOMaticRun-1.0.5.jar
  2. Save the file
  3. Extract the contents (I DO NOT intend to use this commercially!)
0

精彩评论

暂无评论...
验证码 换一张
取 消