7

I am looking for a way to add an overlay to a running Windows game, like OBS (a game streaming application, used for Twitch).

I though about using the Robot class to take 25/30 screenshots every seconds and display them, but I'm not sure that's the right solution..

So my question is the following: How can I screenshare a running app to a Java application (localhost, same computer), in order to add an overlay in front of it ?

EDIT: I tried using VLC Streaming but that makes the computer really laggy (i7/8Gb)... I tried with FFMpeg too, using screen-capture-recorder and gdigrab, the computer was not laggy, but the video drops like 5/10 FPS in real-time.
In FFMpeg, I used the following command : ffplay -f dshow -f gdigrab -i title="<NAME>" -framerate 30.

I would like to have a 25/30 FPS with a gaming computer (i7/8Gb)..

Val
  • 762
  • 8
  • 32
  • When you say `stream`, what exactly low level Java object are you referring as result? A constantly fed `InputStream` where you can read the frame data of from another thread/program? – higuaro Jan 28 '15 at 07:42
  • I don't really care about the Java object type. It just has to be displayable in a `JPanel` :). The app is the client, and the server can be a 3rd party software (like VLC), or integrated in the app directly. – Val Jan 29 '15 at 13:57

2 Answers2

3

Try java-screen-recorder, it is a simple screen capturer and converter. It is not very cpu/gpu consuming. Solution based on java.awt.Robot and repeated capturing of the screen.

gvlasov
  • 18,638
  • 21
  • 74
  • 110
ancalled
  • 174
  • 6
  • I'm not sure this tool lets the user to stream in real-time (I don't want to record the screen to a file and watch it later, but stream it).. – Val Jan 26 '15 at 18:50
  • There are a lot of open source over internet! you can go further and connect screen-recoder with f.e. [Xuggler Streaming](http://www.xuggle.com/xuggler) – ancalled Jan 27 '15 at 01:33
  • 1
    If you think that should work, can you provide a source-code example that should run at 25/30FPS to stream an app ? – Val Jan 27 '15 at 09:01
1

I once developed SimRat (A simple screen sharing app like Teamviewer) using Robot & Corba. You might be able to get a basic idea looking at the code. This is not the best possible way to implement screen sharing. Java RMI would be helpfull for you.

  • I tried some methods, and the screenshots using the `Robot` class looks like the fastest one in my case.. So I'll accept this answer ! Thanks :) – Val Feb 02 '15 at 19:45
  • yeah... me too using openairplay, is one of the technique sharing screen as well.... but i wonder how the sound streaming become available .... – gumuruh Feb 05 '18 at 14:04