Java applet屏幕截图到视频 [英] Java applet screen capture to a video

查看:104
本文介绍了Java applet屏幕截图到视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用java捕获截屏视频。我知道使用Robot类可以获得截图,但我如何将其作为视频捕获然后上传到服务器?这到底有多大?

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 capturing it as a video and then uploading it to the server? How exactly would that work?

想法?

推荐答案

使用纯Java解决方案,我怀疑它会起作用,但它当然取决于你对视频的解释。

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

在我的桌面上,分辨率为1920x1200,使用Java Robot捕获整个屏幕时,我每秒可以获得大约20帧。由于每个映像包含> 6 MB的未压缩数据,因此我需要超过1 Gbps的带宽才能将这些映像的原始数据传输到服务器。最有可能的是,需要如此多的带宽是不可接受的,因此您要么必须减少每秒的帧数,要么对图像应用某种压缩。

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.

一种可能性是使用ImageIO支持的图像格式之一压缩每个图像。压缩图像的大小当然在很大程度上取决于屏幕上实际显示的内容,但压缩机的性能并不是特别好。压缩到PNG应该为大多数桌面内容提供最佳的无损压缩率,但至少我的计算机每秒只能处理大约2帧。使用默认质量设置的JPEG压缩器大约每秒5帧。

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.

通过像 jffmpeg 可能会实现更好的性能和更好的压缩比,但我怀疑像WMV或H.264这样的主流视频编解码器适用于常见的桌面内容。

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.

如果你真的需要一个纯Java解决方案(并且不能使用任何可用的独立软件,那就是你所要求的),我会做尝试实现我自己的简单压缩算法。对于常见的桌面活动,大多数连续屏幕截图之间应该有很小的差异,所以可能工作得很好的是完全传输第一帧,然后实现一个算法来粗略检测矩形,其中已经进行了更改然后仅传输这些与JPG或优选(质量)PNG压缩相结合。

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.

这篇关于Java applet屏幕截图到视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆