桌面TCP流(java) [英] Desktop TCP Streaming (java)

查看:74
本文介绍了桌面TCP流(java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用套接字流式传输桌面屏幕截图. 我不知道执行此操作的确切方法,所以我选择了AWT的机器人:)

I want to stream desktop screen captures using sockets. I don't know the exact way to do this, so I went with AWT's robot :)

Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);

问题是来自机器人的图像太大而无法生成流. 1440x900的捕获量约为 0.3MB ,我无法足够快地传输以创建流畅的24fps流.

The problem is that images coming from the robot are too large to make a stream. A 1440x900 capture is about 0.3MB and I can't transfer it fast enough to create a smooth 24fps stream.

当前我正在使用TCP套接字,因为我无法将图像分割成多个部分并通过UDP发送.

Currently I'm using a TCP socket, because I had problems cutting down the image into multiple parts and sending them over with UDP.

这可能不是正确的方法,但是什么是正确的方法?高清视频流如何传输?

Probably this isn't the right method, but what is? How are HD video streams transferred?

预先感谢

推荐答案

我认为您需要外部库来创建视频(可能取决于平台).

I think you'll need external library to create video (may be platform dependent).

使用图像的方法很简单,但是您需要发送每一帧.使用视频编解码器时,它的尺寸较小,因为它发送的是全尺寸的帧,而另一些只包含图片的更改部分 看到这里:

The approach with images is simple but you'll need to send each frame. When you use video codec size is smaller because it sends some of frames in full size and other contain only changed part of the picture See here:

http://en.wikipedia.org/wiki/Key_frame

http://en.wikipedia.org/wiki/I-frame

以下是我刚刚搜索过的一些开源库:

Here some open-source libs I just googled:

https://code.google.com/p/java-screen-recorder/

http://www.xuggle.com/xuggler/

我想您也可以找到一些库来从图像创建视频流...

I think You also can find some libs to create video stream from images...

这篇关于桌面TCP流(java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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