File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Java Media Framework - How to capture screen activity? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Media Framework - How to capture screen activity?" Watch "Java Media Framework - How to capture screen activity?" New topic
Author

Java Media Framework - How to capture screen activity?

claudiu teodorescu
Greenhorn

Joined: Nov 26, 2009
Posts: 8
Hello,
I have to capture video desktop activity (including audio) to a file using JMF. I spent hours and hours searching this... a have studied a lot of classes, examples BUT I don't know how to bind them... how to record the actvity. My project is to record screen activity, upload on a server and finally control my computer remotely from an applet (or from another java desktop application).

Can someone show me some hints or code for modifying JVidCap example from Sun? Someone else on Sun forum said he could do it but did not say how...

I just want to modify the video capturing so that I get the screen actifity recorded. I read nearly all examples possible including Screen Grabber...

Please help me!


This is the capturing class in the example:


I also have two classes to get the screen activity as datasource... but I really don't understand how to implement them in my application because there is no method returning a datasource object...

This captures the frames using a Robot and feeds them to DataSource class:

Sorry I posted 3 big classes but I hope someone can bind them or help me to go on on this project.... it is so important to me ...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
I doubt that JMF contains much that would help with this. Note that the JVidCap example you linked to captures video from a camera (or video card), not from the desktop.

The java.awt.Robot.createScreenCapture method can create snapshots of the screen; that may be a starting point.


Ping & DNS - my free Android networking tools app
claudiu teodorescu
Greenhorn

Joined: Nov 26, 2009
Posts: 8
I already used screenshots with Robot and send them as byte arrays using sockets but the framerate is to little, so I wanted to capture my screen as video file and stream it to the client using HTTP... first I want to record the screen to a video file. I tried this but the video file is 0 bytes... Don't know why. Hre is the code: I used DataSource and LiveStream example classes (LiveStream feeds the DataSource with screenshots using a Robot). I renamed DataSource to CDataSource and passed the MediaLocator to is


Why is that file 0 bytes? something wrong with datasink?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
Interesting; I stand corrected. Did you get Sun's ScreenGrabber example to work? It seems to do pretty much what you're looking for.
claudiu teodorescu
Greenhorn

Joined: Nov 26, 2009
Posts: 8
Well... I try make it work but looks like the file is 0 bytes lenght.... something is wrong with recording...
claudiu teodorescu
Greenhorn

Joined: Nov 26, 2009
Posts: 8
Finally I could recod the video and the sound. The file was 0 bytes length cause I didn't close the processor and datasink because my WindowClose event was not working properly.
Note: I use LiveStream and DataSource classes from ScreenGrabber example from Sun AND I renamed DataSource to CDataSource (because it was confusing for netbeans IDE) + I passed the MediaLocator in the constructor of CDataSource class so, in that class you must modify this:

This is the main class (don't forget to select the right recording device of your soundcard). I post it for everyone trying to do this
Enjoy my code

 
wood burning stoves
 
subject: Java Media Framework - How to capture screen activity?