Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:36:01+00:00 2026-05-26T23:36:01+00:00

i am not be able to detect/access my web cam using JMStudio when i

  • 0

i am not be able to detect/access my web cam using JMStudio when i run the JMF Registry i got the following screen after pressing "Detect Capture Devices"

Image

I am using ICatch (VI) PC Camera , its a usb web cam

here is the source code

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Vector;

import javax.imageio.ImageIO;
import javax.media.Buffer;
import javax.media.CannotRealizeException;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoDataSourceException;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.control.FrameGrabbingControl;
import javax.media.format.AudioFormat;
import javax.media.format.H261Format;
import javax.media.format.RGBFormat;
import javax.media.format.VideoFormat;
import javax.media.format.YUVFormat;
import javax.media.protocol.CaptureDevice;
import javax.media.protocol.DataSource;
import javax.media.util.BufferToImage;

/**
 * A disposable class that uses JMF to serve a still sequence captured from a
 * webcam over a socket connection. It doesn't use TCP, it just blindly
 * captures a still, JPEG compresses it, and pumps it out over any incoming
 * socket connection.
 * 
 * @author Tom Gibara
 *
 */

public class WebcamBroadcaster {

 public static boolean RAW = false;
 
 
 private static Player createPlayer(int width, int height) {
  try {
      
   Vector<CaptureDeviceInfo> devices = CaptureDeviceManager.getDeviceList(null);
//Testing Code
   CaptureDeviceInfo device = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
   if(device==null) 
   {
   System.out.println("no device");
   }
   else
   System.out.println("device exists");

   System.out.println(devices.size()); // Here i am getting 1
   for (CaptureDeviceInfo info : devices) {
    DataSource source;
    Format[] formats = info.getFormats();
   
    for (Format format : formats) {
        
        if (format instanceof AudioFormat) { // only this condition get satisfied
            System.out.println("AudioFormat");
       }
        
     if ((format instanceof RGBFormat)) {
      RGBFormat rgb = (RGBFormat) format;
      Dimension size = rgb.getSize();
      if (size.width != width || size.height != height) continue;
      if (rgb.getPixelStride() != 3) continue;
      if (rgb.getBitsPerPixel() != 24) continue;
      if ( rgb.getLineStride() != width*3 ) continue;
      MediaLocator locator = info.getLocator();
      source = Manager.createDataSource(locator);
      source.connect();
      System.out.println("RGB Format Found");   
      ((CaptureDevice)source).getFormatControls()[0].setFormat(rgb);
     } else if ((format instanceof YUVFormat)) {
      YUVFormat yuv = (YUVFormat) format;
      Dimension size = yuv.getSize();
      if (size.width != width || size.height != height) continue;
      MediaLocator locator = info.getLocator();
      source = Manager.createDataSource(locator);
      source.connect();
      System.out.println("YUV Format Found");   
      ((CaptureDevice)source).getFormatControls()[0].setFormat(yuv);
     } else {
      continue;
     }

     return Manager.createRealizedPlayer(source);
    }
   }
  } catch (IOException e) {
   System.out.println(e.toString());
   e.printStackTrace();
  } catch (NoPlayerException e) {
   System.out.println(e.toString());
   e.printStackTrace();
  } catch (CannotRealizeException e) {
   System.out.println(e.toString());
   e.printStackTrace();
  } catch (NoDataSourceException e) {
   System.out.println(e.toString());
   e.printStackTrace();
  }
  return null;
 }

 public static void main(String[] args) {
  int[] values = new int[args.length];
  for (int i = 0; i < values.length; i++) {
   values[i] = Integer.parseInt(args[i]);
  }
  
  WebcamBroadcaster wb;
  if (values.length == 0) {
   wb = new WebcamBroadcaster();
  } else if (values.length == 1) {
   wb = new WebcamBroadcaster(values[0]);
  } else if (values.length == 2) {
   wb = new WebcamBroadcaster(values[0], values[1]);
  } else {
   wb = new WebcamBroadcaster(values[0], values[1], values[2]);
  }
  
  wb.start();
 }
 
 public static final int DEFAULT_PORT = 9889;
 public static final int DEFAULT_WIDTH = 320;
 public static final int DEFAULT_HEIGHT = 240;
 
 private final Object lock = new Object();
 
 private final int width;
 private final int height;
 private final int port;
 
 private boolean running;
 
 private Player player;
 private FrameGrabbingControl control;
 private boolean stopping;
 private Worker worker;
 
 public WebcamBroadcaster(int width, int height, int port) {
  this.width = width;
  this.height = height;
  this.port = port;
 }

 public WebcamBroadcaster(int width, int height) {
  this(width, height, DEFAULT_PORT);
 }

 public WebcamBroadcaster(int port) {
  this(DEFAULT_WIDTH, DEFAULT_HEIGHT, port);
 }

 public WebcamBroadcaster() {
  this(DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_PORT);
 }
 
 public void start() {
  synchronized (lock) {
   if (running) return;
   player = createPlayer(width, height);
   if (player == null) {
    System.err.println("Unable to find a suitable player");
    return;
   }
   System.out.println("Starting the player");
   player.start();
   control = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
   worker = new Worker();
   worker.start();
   System.out.println("Grabbing frames");
   running = true;
  }
 }

 public void stop() throws InterruptedException {
  synchronized (lock) {
   if (!running) return;
   if (player != null) {
    control = null;
    player.stop();
    player = null;
   }
   stopping = true;
   running = false;
   worker = null;
  }
  try {
   worker.join();
  } finally {
   stopping = false;
  }
 }

 private class Worker extends Thread {
  
  private final int[] data = new int[width*height];
  
  @Override
  public void run() {
   ServerSocket ss; 
   try {
    ss = new ServerSocket(port);
    
   } catch (IOException e) {
    e.printStackTrace();
    return;
   }
   
   while(true) {
    FrameGrabbingControl c;
    synchronized (lock) {
     if (stopping) break;
     c = control;
    }
    Socket socket = null;
    try {
     socket = ss.accept();
     
     Buffer buffer = c.grabFrame();
     BufferToImage btoi = new BufferToImage((VideoFormat)buffer.getFormat());
     BufferedImage image = (BufferedImage) btoi.createImage(buffer);
     
     if (image != null) {
      OutputStream out = socket.getOutputStream();
      if (RAW) {
       image.getWritableTile(0, 0).getDataElements(0, 0, width, height, data);
       image.releaseWritableTile(0, 0);
       DataOutputStream dout = new DataOutputStream(new BufferedOutputStream(out));
       for (int i = 0; i < data.length; i++) {
        dout.writeInt(data[i]);
       }
       dout.close();
      } else {
       ImageIO.write(image, "JPEG", out);
      }
     }
     
     socket.close();
     socket = null;
    } catch (IOException e) {
     e.printStackTrace();
    } finally {
     if (socket != null)
      try {
       socket.close();
      } catch (IOException e) {
       /* ignore */
      }
    }
    
   }
   
   try {
    ss.close();
   } catch (IOException e) {
    /* ignore */
   }
  }

 }
 
}

I have searched lot many threads but no luck

I am using Windows XP
following are my class path values

JMFHOME E:\android\AR\jmf-2_1_1e-alljava\JMF-2.1.1e
CLASSPATH %JMFHOME%\lib\jmf.jar;%JMFHOME%\lib;

JFM lib file contains jmf.jar , multiplayer.jar , mediaplayer.jar ,
customizer.jar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:36:02+00:00Added an answer on May 26, 2026 at 11:36 pm

    Reinstalling this package again solved my problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not able to access localhost https pages in firefox3. It gave the
My issue is not able to render the chart in .tpl file. The following
I am not able to use the breakpoint in Studio with Javascript. I'm able
Why are we not able to override an instance variable of a super class
I am not able to figure out this simple thing in ASP.NET MVC: I
I am not able to flush stdin here, is there a way to flush
I am not able to make a clear decision on this one. I am
I am not able to get my jwysiwyg and Jhtmlarea text editors to work
I am not able to figure out why it is not tracing value for
I'm not able to connect a simple client and a simple server. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.