问题
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