3

I'm trying to read raw video frames from a video capture device using JMF - the Java Media Framework.

I've successfully written the "capture" part - using a Player object created by Manager, I can display realtime video from a webcam. I don't know how to go about creating a custom component to access the actual frames, however. This is probably because up until now Manager has created every class instance I needed for me.

I would like to start by writing a GUI component that displays the video. (I'm not familiar with AWT/Swing, but based on knowledge of other GUI frameworks, I'd say something derived from a, say, JPanel that draws the video when a repaint request is made or a new frame is available.) I would like to be able to process every new frame and loop on x/y over all the pixels. I have access to the raw/RGB format on my device, but automatic conversion from, say, YUV wouldn't hurt.

I have no idea where to start. The JMF documentation recommends I derive my class from Processor or DataSink in several different places. Using the Processor interface seems like an overkill - I would have no need for the playback and timing control functions, for example; and I wouldn't know how to implement them in the first place. Deriving from DataSink seems like a simpler option with less useless abstract functions. However, in either case, I'm at a complete loss as how to:

a) Connect the component to my video capture DataSource
b) Access the actual frame buffers from within the class

I may even be going in a wrong direction here; I just wanted to document what I've tried so far. JMF documentation seems scarce and mostly oriented towards [designing] media players and converters.

Note: The Processing library seems to have a simple solution for this. I've seen an example along the lines of: x = new Image(captureDevice.getFrame()) which seems to suggest pixel-level access is possible, through Image if not the intermediate type.

But I would really like to see how hard it is in JMF first.

aib
  • 45,516
  • 10
  • 73
  • 79
  • Try out the code I posted here: http://stackoverflow.com/questions/1382508/how-to-integrate-webcam-in-swing-application-of-java/1382841#1382841 – JRL Feb 17 '10 at 02:02
  • @JRL: That looks good, though I've never had a chance to try it. We might as well put this question out of its misery; turn that comment into an answer and let me accept it please. – aib Feb 08 '12 at 00:23

2 Answers2

1

I'm sorry, but at this point, JMF is essentially dead. You would probably use FX for that, but FX isn't exactly doing well either.

Keith Mattix
  • 401
  • 5
  • 13
  • I guess so. I barely remember what this was for, anyway. Got discouraged too early :) – aib Feb 08 '12 at 00:22
1

You might try out the code that I posted here, which uses JMF and a class named FrameGrabber.

Community
  • 1
  • 1
JRL
  • 76,767
  • 18
  • 98
  • 146