Using JMF in JInternal Frames

Hello,
I'm am using several JInternalFrames within a desktop pane. Some of these frames have a JMF visual component.
Is it possible to ensure that if internal frames are selected that they are not obscured by a visual component on other frames??? It seems that the JMF visual component is heavyweight and is thus always on top of anything else.
thanks,
Oli Gosling

Hello Oli,
I have the same problem. I've tried a lot of things (like adding to panels instead of a getGetContentPane, to send back etc.), but I still can not send to back the Visual Component (as if it is on the glass pane of the JDesktopPane).
Have you found a solution or should I think of some tabbed pane or splitted panes or even individual frames?
thanks,
stefan.
PS: it may be a bug?

Similar Messages

  • Can we use GridBagLayout in JInternal Frame

    i've a question that can we use gridbaglayout in JInternalFrame?

    Yes:
    internalFrame.getContentPane().setLayout(new GridBagLayout());
    // Add children to be laid out to internalFrame,getContentPane()
    //or if you prefer:
    JPanel p = new JPanel(new GridBagLayout());
    internaleFrame.getContentPane().add(p);
    // Add children to be laid out to 'p'
    //

  • How to use JMF (pull)datasource class to access individual video frames?

    Is there anyway of using JMF datasource or pulldatasource class to access individual video frames?
    Edited by: pakkito on Apr 9, 2008 3:15 AM

    Is there anyway of using JMF datasource or pulldatasource class to access individual video frames?
    Edited by: pakkito on Apr 9, 2008 3:15 AM

  • Does enyone know how to grabb frames using JMF

    can u please help me , if enyone knows
    how to grabb frames from .AVI file using JMF and
    also
    how to save those frames as JPEG in to HDD .

    Take a look at this
    http://java.sun.com/products/java-media/jmf/2.1.1/solutions/JVidCap.html

  • Saving contents of jinternal frame

    Hi, I seem to have a problem saving files from jinternal frames. I created two files, the main GUI which holds the jdesktop pane and the other file (Documento) extends jinternalframe. I want to be able to save the current (active) jinternal frame but I have no idea how to do it. can anyone help me?
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.Graphics.*;
    import javax.swing.JOptionPane;
    import java.io.*;
    import java.util.*;
    *This is the main GUI of the program.
    public class mainGUI extends JFrame
                                   implements ActionListener,
                                    KeyListener{
        JDesktopPane desktop;
        Documento frame;
         private Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
         private JPanel toolbar, editarea, resultarea, blankPanel;
         private JMenu file, edit, project;
         private JMenuItem f_open, f_new, f_save, f_saveas, f_exit, e_select, e_copy, e_paste, p_compile;
         private JTextArea resultfield, editfield,editArea, tstr;
         private JButton bcompile;
         private JFileChooser fc = new JFileChooser();
         private String filepath;
         private ImageIcon bugicon;
         private static int docNum = 0;
         private boolean b_openfile;
         File filename;
        public mainGUI() {
            super("DGJ Program Scanner");
            setSize(800,600);
              setLocation((screen.width-800)/2, (screen.height-600)/2);
            /*Creates the workspace*/
            desktop = new JDesktopPane();
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
            /*Make dragging a little faster*/
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
          *This function creates the menu bar
        protected JMenuBar createMenuBar() {
             /*Initializes/instantiates the menu bar and its items*/
              file = new JMenu("File");
              edit = new JMenu("Edit");
              project = new JMenu("Project");
              f_new = new JMenuItem("Create new file");
              f_open = new JMenuItem("Open file...");
              f_save = new JMenuItem("Save current file");
              f_saveas = new JMenuItem("Save As...");
              f_exit = new JMenuItem("Exit program");
              e_select = new JMenuItem("Select All");
              e_copy = new JMenuItem("Copy selected");
              e_paste = new JMenuItem("Paste selected");
              p_compile = new JMenuItem("Scan current file for errors");
              /*Adds listeners to the menu items*/
              f_open.setActionCommand("f_open");
              f_open.addActionListener(this);
              f_save.setActionCommand("f_save");
              f_save.addActionListener(this);
              f_saveas.addActionListener(this);
              f_saveas.setActionCommand("f_saveas");
              f_new.setActionCommand("f_new");
              f_new.addActionListener(this);
              f_exit.setActionCommand("f_exit");
              f_exit.addActionListener(this);
              e_select.setActionCommand("e_select");
              e_select.addActionListener(this);
              e_paste.setActionCommand("e_paste");
              e_paste.addActionListener(this);     
              e_copy.setActionCommand("e_copy");
              e_copy.addActionListener(this);               
              /*Creates the icon of the bug*/
              bugicon = new ImageIcon("images/ladybug.gif");
              /*Creates the menu bar*/
              JMenuBar menu = new JMenuBar();
              menu.add(file);
                   file.add(f_new);
                   file.add(f_open);
                   file.add(f_save);
                   file.add(f_saveas);
                   file.add(f_exit);
              menu.add(edit);
                   edit.add(e_select);
                   edit.add(e_copy);
                   edit.add(e_paste);
              menu.add(project);
                   project.add(p_compile);
              /*Disables the save current file menu...(when program starts, no file is open yet)*/
              f_save.setEnabled(false);
              f_saveas.setEnabled(false);
            return menu;
        //React to menu selections.
        public void actionPerformed(ActionEvent e) {
            if ("f_new".equals(e.getActionCommand()))
            { //new
                createFrame(null);
                f_saveas.setEnabled(true);
            else if("f_open".equals(e.getActionCommand()))
            {//open documento
                   fc.setFileFilter(new SpanFilter());
                  int retval = fc.showOpenDialog(mainGUI.this);
                   tstr = new JTextArea();
                   /*This checks if the user has chosen a file*/
                if (retval == JFileChooser.APPROVE_OPTION) {
                    filename = fc.getSelectedFile();
                        filepath = filename.getPath();            
                        openFile(filename, new Point(30,30));       
            else if("f_save".equals(e.getActionCommand()))
                 try {
                      BufferedWriter out = new BufferedWriter(new FileWriter(filepath));
                      String str;
                      str = editArea.getText();
                      editArea.setText("");  
                      int length = str.length();
                      out.write(str, 0, length);
                      out.close();
                       } catch (Exception ex) {}
                       JInternalFrame fr = new JInternalFrame();
                       fr = desktop.getSelectedFrame();
                       Point p = fr.getLocation();
                        fr.dispose();    
                       openFile(filename, p);
            else if("f_saveas".equals(e.getActionCommand()))
                 fc.setFileFilter(new SpanFilter());
                  int retval = fc.showSaveDialog(mainGUI.this);
                if (retval == JFileChooser.APPROVE_OPTION) {
                    filename = fc.getSelectedFile();
                        filepath = filename.getPath();
                        if(!(filepath.contains(".dgj")))
                             filepath+=".dgj";
                      try {
                           BufferedWriter out = new BufferedWriter(new FileWriter(filepath));
                                String str;
                           str = editArea.getText();
                           int length = str.length();
                           out.write(str, 0, length);
                           out.close();
                       } catch (Exception ex) {}
                       Point p = frame.getLocation();
                        frame.dispose();
                   //     editArea.setText("");     
                       openFile(filename, p);
            else if("e_select".equals(e.getActionCommand()))
                 editArea.selectAll();
            else if("e_copy".equals(e.getActionCommand()))
                   editArea.copy();
            else if("e_paste".equals(e.getActionCommand()))
                 editArea.paste();
            else if("f_exit".equals(e.getActionCommand()))
            { //quit
                quit();
        public void openFile(File filename, Point p)
                        /*Reads the file*/
                        try {
                           BufferedReader in = new BufferedReader(new FileReader(filepath));
                             String str;
                             /*empties the textarea*/
                             tstr.setText("");
                             str = in.readLine();
                             /*Copy each line of the file into the temporary textarea*/
                           do{  
                          tstr.append(str);
                          str = in.readLine();
                          /* the "\n" is for the line to appear in the next line in the textarea,
                           * the "\r" is for windows system, wherein "\r" is required for the text
                           * to appear in beginning of the first line*/
                          if(str!=null)
                               tstr.append("\r\n");
                           }while (str != null);
                             /*Opens the new frame*/
                           createFrame(filename, filename.getName(), tstr.getText(), p);
                           in.close();
                       } catch (Exception ex){}
                      b_openfile = true;
                      f_save.setEnabled(true); 
                      f_saveas.setEnabled(true);   
         *Create a new internal frame.
        protected void createFrame(File f) {
             frame = new Documento(f);
         /*     frame = new JInternalFrame("Document "+(++docNum),
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);
            docNum++;
              frame.setSize(600,400);
              frame.setLocation(20*(docNum%10), 20*(docNum%10));       
             editArea = new JTextArea();
              JScrollPane scroll = new JScrollPane(editArea);     
              editArea.addKeyListener(this);
              editArea.append("");
              frame.add(scroll);
            frame.setVisible(true); //necessary as of 1.3
            desktop.add(frame);
            try {
                frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
          *Overwrite an existing internal frame for an open file
        protected void createFrame(File f, String title, String text, Point P) {
             frame = new Documento(title, f, P);
              frame.setSize(600,400);
              frame.setLocation(P); 
             editArea = new JTextArea();
              JScrollPane scroll = new JScrollPane(editArea);     
              editArea.setText("");
              editArea.addKeyListener(this);
              editArea.append(text);
              frame.add(scroll);
            frame.setVisible(true); //necessary as of 1.3
            desktop.add(frame);
            try {
                frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
        //Quit the application.
        protected void quit() {
            System.exit(0);
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            //JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            mainGUI frame = new mainGUI();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            frame.setVisible(true);
        public void keyTyped(KeyEvent k){}
        public void keyPressed(KeyEvent k)
             if(k.getKeyCode()==10)
                  editArea.append("\r");           
        public void keyReleased(KeyEvent k){}
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }here's the one that extends jinternalframe
    import javax.swing.JInternalFrame;
    import javax.swing.plaf.InternalFrameUI;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import java.util.*;
    /* Used by mainGUI.java */
    public class Documento extends JInternalFrame {
        static final int xOffset = 30, yOffset = 30;
         static JTextArea editArea;
         static int docNum = 0;
         static File file;
          *The constructer for a new documento
        public Documento(File file) {
            super("Document "+(++docNum),
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
            docNum++;
              this.file = file;
              setSize(600,400);
              setLocation(xOffset*(docNum%10), yOffset*(docNum%10));
    //        setUI(new InternalFrameUI());
         *The constructor for an existing documento
        public Documento(String title, File file, Point p) {
            super(title,
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
              this.file = file;             
              setSize(600,400);          
              setLocation(p);
    //        setUI(new InternalFrameUI());
        public int getNum()
             return docNum;
        public File getPath()
             return file;
    }I know it's pretty lengthy...it's probably all messed up since I'm lost :p
    Thanks if you could help me!

    I would be glad to help, but first I need a clarification. If I understand properly, you have two Java classes that you have created: the "main GUI" (which is most likely a JFrame extension in which the constructor adds a JDesktopPane to the content pane) and "Documento" (which you say is a JInternalFrame extension).
    My question is this: what do you mean by "save the current JInternalFrame"? Do you want to record its position, location, and identity? Do you want to save its contents?
    Thanks. Good luck. ;)

  • How to capture the video in a file using JMF-RTP?

    Please someone help in capturing the live streaming in a file using JMF......
    Thanks..

    Hi, I have a problem with RTPExport output video files. One side streams H263/RTP(AVTransmit2.java) and other write this steam to a file by RTPExport.java. When network conditions are ideal, output video file has same fps and same number of frames like original file. Problem occures, when theres packet lost in network, then output file has different fps,and also has less frames like original video(because it didnt write missing frames to file, and thats why it get shorter). Pls how can I achieve output file that will have the same fps like original one? How to write to file an identical copy of what I can see while receiveing video with AVReceive2.java? Its there a way to modifi rtpexport or avreceiver to do this? Thanks!

  • How to connect to Digital Camera using JMF?

    How to connect to Digital Camera using JMF?
    Any example?
    thx

    If the DC has a mode that works like a web cam, and can generate either a VFW or DirecShow stream, then you could capture a frame of the stream, yes.

  • Using jmf when doing an install

    when creating a program that is going to use jmf, does the host machine need to have jmf installed to do an rtp transmission of streaming video? or do i need to include a jmf.jar file in the installer package? or is the jmf pieces I need part of the jre 1.6u1
    thanks

    I would suggest you search for some of the good discussions about the hows and whys of redirecting content.  There is a lot of information out there that I do not have the time at the moment to summerize here.  But to make one brief point.
    You can never 'nuke' a redirect once you put one in place and NOT risk getting 404 errors.  Working with the assumption that your users have been notified that the page is moved AND that all users who have been such notified bothered to update their bookmarks.  That still leaves out the set of users who may not have visited your page in the time frame that the redirect page existed.  They will then get the dreaded 404 error because they where never told to update their bookmarks.  This also does not account for users who are comming from old links from other web sites, printed material, or anywhere else the URL may have been published.
    It is also possibe (but I'm not sure any current browser does this) that the client tool can automatically update a saved URI with new URI when it receives a proper permenant redirect.  That is the way the standard reads at least.

  • Problem with  M-JPEG by using JMF and JPEGCodec .

    Hi, there,
    I want to implement a M-JPEG using JMF and JPEGCodec, is that possible?(I already been trapped)
    My problem is I have a video clip which is a AVI file, the video format is following:
    Video format: RGB, 160x120, FrameRate=14.9, Length=57600, 24-bit, Masks=3:2:1, P
    ixelStride=3, LineStride=480, Flipped.
    I already convered a frame to an Image object(video format with JPEG and CVID doesn't work) ,
    I can also convert this Image back as a Buffer, It works fine with me .But to use JPEGCodec( provided by com.sun.image.codec.jpeg ) I need to convert an Image to a BufferedImage, I use the following defination:
    BufferedImage   bImage = new BufferedImage(frameImage.getWidth(null), frameImage.getHeigh(null),BufferedImage.TYPE_INT_RGB); It seems work, But when I use JPEGImageEncoder to encoder this bImage and save as a jpg file,
    everything is black .
    I also need to cast BufferedImage to an Image: frameImage = (Image) bImage; then I convert frameImage back to Buffer.My video clip still running , but every frame now became black .
    can someone help me? thanks in advance.

    I solved this problem . But I met a new problem.
    I converted the above video clip into a JPEG and I want to create a DataSink for it. the messege is:
    Video format: JPEG, 160x120, FrameRate=12.0, Length=3574
    - set content descriptor to: AVI
    - set track format to: JPEG
    Cannot transcode any track to: JPEG
    Cannot create the DataSink: javax.media.NoDataSinkException: Cannot find a DataS
    ink for: com.sun.media.multiplexer.RawBufferMux$RawBufferDataSource@2b7eea
    Transcoding failedHope some Java Experts can help me.
    Regards.

  • Using JMF to create AVIs

    Hello all, I am new to JMF and I was wondering if anyone could point me in the right direction of using JMF to create AVIs on the fly... I have short [ ] buffers that contain image data, and i need to convert this into an .avi file, but i will not have the buffers all at once, but rather will be passing them one at a time. So i need the avi renderer/writer to be able to handle incremental input of buffers, frame by frame.
    if anyone could give me a hand or tell me where to look, i would be much obliged!
    thanks so much,
    ben

    sheik2311 wrote:
    I must do it in Applet since it should work on the web.Actually, no...if it "should work on the web", it either needs to be an applet (pain in the butt for JMF development) or a WebStart application (not a pain in the button). I'd personally recommend using a web start application to avoid all of the hassles of trying to put JMF in an applet.
    Second, I'm not sure where your sample code came from, but you definately need some more robust sample code to work with...so...in the order you should play with them...
    To show a video in a Swing component
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/SwingJMF.html]
    To transmit audio/video
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/AVTransmit.html]
    To receive audio/video
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/AVReceive.html]
    To save a received video to disk
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/RTPExport.html]
    To show and record video
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/JVidCap.html]

  • Some questions while using JMF play mpeg-1 stream media?

    I use Helix server to provide unicast, and use JMF to play the stream media. But the JMF only play the audio stream transferred by rtp. I have used video palyer�s getVisualComponent() method to get Visual component and added it into the frame. But I get a pink screen. So I think some thing wrong with the video player.
    Who can give me an answer?
    1.     Whether JMF can play mpeg-1 video stream media?( Audio can be heard. Video stream comes to my computer but can�t be displayed.)
    2.     Which method it should use to synchronize video stream and audio stream?
    BTW: In JMF, when the RTSP player�s start() method is invoked, the player creates players by the stream�s track numbers. Video stream and audio stream have different players.

    Try posting your question under the Java Media Framework forum instead.
    You'll get much better responses if you ask the right people !
    regards,
    Owen

  • Beginner Question. need opinion on using JMF

    i am hoping to use JMF to have a audio/video chat session . it will be like there will be 5 PC's . and 1 PC will be streaming a video, the other 4 PC's will be showing it.
    what i want to do is to draw lines or make some mark on the video thats been telecast (from the other 4 PC's), and that change to be shown on all 5 PC's
    is this do-able ? and i hope my question was not confusing .

    localpott wrote:
    is this do-able ?Yes. JMF has the built-in capability to broadcast a stream to multiple participants simultaniously, and it works a lot like email. You just add a few more recipients to the list before you press send.
    As for drawing on the video, that'd be relatively easy to do. You'd just need to develop a layering system, whereby a "bottom" layer renders the video frames, and the upper layer renders / modifies the drawing. You'd just then need to create a video "Effect" class that would grab the upper layer, render it on top of the current video frame, and then it would come out of the Processor with the drawing on it.

  • Problem with Transmitting media using JMF

    Hello Everyone !!
    I am working on an application called SIPSpeaker which listens for incoming calls, answer the call and plays a message. I am done with the first two parts of the application, i.e. it can successfully answers the call. I am now facing problem with transmitting audio to the SIP Phone (the caller). I am using JMF and I am trying to send the audio over RTP.
    My code looks something like this....
    locator = new MediaLocator("rtp://130.237.214.124:" + port + "/audio");
            f = new File("C:/1.wav");
            try {
                ds = Manager.createDataSource(f.toURL());         
            } catch (NoDataSourceException ex) {
                ex.printStackTrace();
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            format = new Format[]{new AudioFormat(AudioFormat.GSM_RTP,8000,8,1)};
            contentDesc = new ContentDescriptor(ContentDescriptor.RAW_RTP);
                    processor = Manager.createProcessor(ds);
                    waitForState(processor,Processor.Configured);
                    processor.setContentDescriptor(contentDesc);
                    processor.getTrackControls()[0].setFormat(format[0]);
                    waitForState(processor,Processor.Realized);
    try {
                sink = Manager.createDataSink(processor.getDataOutput(),locator);
                System.out.println("6");
            } catch (NotRealizedError ex) {
                ex.printStackTrace();
            } catch (NoDataSinkException ex) {
                ex.printStackTrace();
    processor.start();
            try {
                sink.open();
                sink.start();
            } catch (SecurityException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
               we are required to work with a .wav file as input ....
    i am new to java and to JMF and i have absolutely no idea whats going wrong...
    please help me
    Regards,
    Sanjay !!

    Hello
    following is the error i get
    Failed to realize: com.sun.media.ProcessEngine@618d26
    Cannot build a flow graph with the customized options:
    Unable to transcode format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
    to: mpegaudio/rtp, 8000.0 Hz, 8-bit, Mono
    outputting to: RAW/RTP
    Error: Unable to realize com.sun.media.ProcessEngine@618d26
    what could be the problem ???

  • Fast acquring of images using JMF

    Hello!
    I have been trying to write a class for reading frames from a video camera using JMF, however the BufferToImage.createImage appeared to be very slow -- the code is fast if the method is commented out. How can I get the images faster? Or perhaps read pixels directly from the video stream buffer? Or is there another problem with the code? If BufferToImage was constructed using Buffer.getFormat, it was also slow.
    I attach the code that I have used for reading the frames.
    Sincerely,
    Artur Rataj
    * A video input driver that uses Java Media Framework.
    * This file is provided under the terms of the GNU General Public License.
    * version 0.1, date 2004-07-21, author Artur Rataj
    package video.drivers;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.util.BufferToImage;
    * This is a video driver that uses Java Media Framework to access video input devices.
    public class JMFDriver extends VideoDriver implements ControllerListener {
          * The input stream processor.
         Processor processor;
          * The stream from the input video device.
         PushBufferStream frameStream;
          * A converter from stream data to an image.
         BufferToImage frameStreamConverter;
          * A video stream buffer.
         Buffer videoBuffer;
          * Constructs a new driver.
         public JMFDriver(String deviceAddress, int width, int height, int bitsPerPixel)
              throws VideoDriverException {
              super(deviceAddress, width, height, bitsPerPixel);
              MediaLocator locator = new MediaLocator(deviceAddress);
              if(locator == null)
                   throw new VideoDriverException("Device not found: " + deviceAddress);
              javax.media.protocol.DataSource source;
              try {
                   source = javax.media.Manager.createDataSource(locator);
              } catch(IOException e) {
                   throw new VideoDriverException("Could not read device " + deviceAddress +
                        ": " + e.toString());
              } catch(NoDataSourceException e) {
                   throw new VideoDriverException("Could not read device " + deviceAddress +
                        ": " + e.toString());
              if(!( source instanceof CaptureDevice ))
                   throw new VideoDriverException("The device " + deviceAddress +
                        " not recognized as a video input one.");
              FormatControl[] formatControls =
                   ((CaptureDevice)source).getFormatControls();
              if(formatControls == null || formatControls.length == 0)
                   throw new VideoDriverException("Could not set the format of images from " +
                        deviceAddress + ".");
              VideoFormat videoFormat = null;
    searchFormat:
              for(int i = 0; i < formatControls.length; ++i) {
                   FormatControl c = formatControls;
                   Format[] formats = c.getSupportedFormats();
                   for(int j = 0; j < formats.length; ++j)
                        if(formats[j] instanceof VideoFormat) {
                             VideoFormat f = (VideoFormat)formats[j];
                             if(f.getSize().getWidth() == this.width &&
                                  f.getSize().getHeight() == this.height) {
                                  int bpp = -1;
                                  if(f instanceof RGBFormat)
                                       bpp = ((RGBFormat)f).getBitsPerPixel();
                                  else if(f instanceof YUVFormat) {
                                       YUVFormat yuv = (YUVFormat)f;
                                       bpp = (yuv.getStrideY() + yuv.getStrideUV())*8/
                                                 this.width;
                                  if(bpp == bitsPerPixel) {
                                       videoFormat = (VideoFormat)c.setFormat(f);
                                       break searchFormat;
              if(videoFormat == null)
                   throw new VideoDriverException("Could not find the format of images from " +
                        deviceAddress + " at " + bitsPerPixel + " bits per pixel.");
              try {
                   source.connect();
              } catch(IOException e) {
                   throw new VideoDriverException("Could not connect to the device " +
                        deviceAddress + ": " + e.toString());
              try {
                   processor = Manager.createProcessor(source);
              } catch(IOException e) {
                   throw new VideoDriverException("Could not initialize the processing " +
                        "of images from " + deviceAddress + ": " + e.toString());
              } catch(NoProcessorException e) {
                   throw new VideoDriverException("Could not initialize the processing " +
                        "of images from " + deviceAddress + ": " + e.toString());
              processor.addControllerListener(this);
              synchronized(this) {
                   processor.realize();
                   try {
                        wait();
                   } catch(InterruptedException e) {
                        throw new VideoDriverException("Could not initialize the processing " +
                             "of images from " + deviceAddress + ": " + e.toString());
              processor.start();
              PushBufferDataSource frameSource = null;
              try {
                   frameSource = (PushBufferDataSource)processor.getDataOutput();
              } catch(NotRealizedError e) {
                   /* empty */
              PushBufferStream[] frameStreams = frameSource.getStreams();
              for(int i = 0; i < frameStreams.length; ++i)
                   if(frameStreams[i].getFormat() instanceof VideoFormat) {
                        frameStream = frameStreams[i];
                        break;
              videoBuffer = new Buffer();
              videoBuffer.setTimeStamp(0);
              videoBuffer.setFlags(videoBuffer.getFlags() |
                   Buffer.FLAG_NO_WAIT |
                   Buffer.FLAG_NO_DROP |
                   Buffer.FLAG_NO_SYNC);
              processor.prefetch();
         public void controllerUpdate(ControllerEvent event) {
              if(event instanceof RealizeCompleteEvent)
                   synchronized(this) {
                        notifyAll();
         * Acquires an image from the input video device.
         public Image acquireImage() throws VideoDriverException {
              try {
                   frameStream.read(videoBuffer);
              } catch(IOException e) {
                   throw new VideoDriverException("Could not acquire a video frame: " +
                        e.toString());
              frameStreamConverter = new BufferToImage(
                   (VideoFormat)frameStream.getFormat());
              Image out = frameStreamConverter.createImage(videoBuffer);
              return out;
         * Closes the input video device.
         public void close() {
              processor.close();
         public static void main(String[] args) throws Exception {
              JMFDriver driver = new JMFDriver("v4l://0", 768, 576, 16);
              while(true)
                   Image image = driver.acquireImage();
                   System.out.print(".");
                   System.out.flush();

    This is how you do this:
    First you must know upfront what type of a format your camera is using,
    all the valid formats are static members of BufferedImage.
    Next you need to create a BufferedImage of the same format.
    Here is an example:
    My creative webcam is set to: 640x480 RGB 24bit color. i Create a BufferedImage into which i will copy the buffer:
    BufferedImage buff = new BufferedImage(640,480,BufferedImage.TYPE_3BYTE_BGR);
    Next the copy operation where appropriate
    cbuffer is my javax.media.Buffer from which i will copy the image data:
    System.arraycopy((byte[])cbuffer.getData(), 0, ((DataBufferByte) buff.getRaster().getDataBuffer()).getData(),0,img_size_bytes);
    Things to note here, are i cast the cbuffer.getData() to byte[] because that is the type of data this is. I cast buff.getRaster().getDataBuffer() to DataBufferByte because the bufferedimage is of type TYPE_3BYTE_BGR.
    also, img_size_bytes equals to 640*480*3
    This operation will copy the raw buffer into your buffered image avoiding the use of BufferToImage
    Only problem is the image will be flipped, but just flip the webcam to correct this =)

  • JMF Video Player Frame Rate comes down to zero

    Hi
    I am working on video Player using jmf. I am playing .mov file in the Applet. The appled have been signed and this part is working fine.
    I am able to get the video from server to the client using signed applet. But the problem now i am facing is that after few seconds of video download the frame rate and bit rate both comes down to Zero and the movie stops playing. I am using .mov extension with approximately 2-8 MB size of video.
    As i feels problem is coming with the http protocol. Because while playing the local video file with the same code it is performing well.

    This blog is written by one of the principle guys who writes the Flash plug-in.
    http://blog.kaourantin.net/?p=83
    I think it might have some answers for you--not the answer you want.

Maybe you are looking for