I need an Java app (desktop - Windows & Mac) that needs to send desktop screen video to other users via Sockets (WebSockets, because clients are using browser).
For now i have managed to do:
- Get screenshot using
Robot.getImageWritersByFormatName
(not so fast, but as far as i know there is no other cross-platform solution) - I have managed to setup socket communications
java socket client -> screenshare/socket server -> client(browser)
- Tried to send JPEG compressed images and then render them in browser, in local network it was acceptable, but when it's about wan it is very very slow (3/4fps and stream is already >350kbps)
- Figured out that i need video compression (not still image like JPEG), keyframes, iframes etc.. I dont have much experience with video encoding/decoding
- Found JCodec library (very good library, seems to me, with pure codecs for java, great job, but there is no documentation)
- Thanks to sample code, i have managed to encode sequence of BufferedImage images to h264/mp4 but only to save it to file
How i imagined, if i can use ByteBufferSeekableByteChannel instead of FileChannelWrapper (both implements SeekableByteChannel) and store data in memory using ByteBuffer then i can call channel.read(someOtherByteBuffer)
in loop and send byte array throught socket, but i get array full of zeroes.
Does somebody know how to make this work? Any other advice or maybe some other idea how to make this app are welcome.