Desktop TCP Streaming (java)

核能气质少年 提交于 2019-12-31 02:45:28

问题


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);

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.

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?

Thanks in advance


回答1:


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...




回答2:


How are HD video streams transferred?

Typically as a video stream, which a 'group of images' is not. Video codecs often have clever ways to compress groups of images further, e.g. by only showing the part of the next frame that is different to the previous one.

You might also want to look into encoding the images as a high compression JPEG.

Having said that, I doubt you'll get a very good transfer rate at that size in pixels.



来源:https://stackoverflow.com/questions/16592664/desktop-tcp-streaming-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!