Usb webcam " Internal data stream error"

Hi,
I have trouble trying to get Processing to recognise usb webcams. This camera works in Quicktime and other apps like PureData on the same computer. What am I doing wrong?

Processing console:

Processing video library using bundled GStreamer 1.20.3
Scanning GStreamer plugins... Done.
Available cameras:
[0] "FaceTime HD Camera"
[1] "Microsoft® LifeCam VX-2000"
BaseSrc: [avfvideosrc0] : Internal data stream error.

Code from “Video Library for Processing 4”:

/**
 * Getting Started with Capture.
 * 
 * Reading and displaying an image from an attached Capture device. 
 */

import processing.video.*;

Capture cam;

void setup() {
  size(640, 480);

  String[] cameras = Capture.list();

  if (cameras == null) {
    println("Failed to retrieve the list of available cameras, will try the default...");
    cam = new Capture(this, 640, 480);
  } else if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    printArray(cameras);

    // The camera can be initialized directly using an element
    // from the array returned by list():
    cam = new Capture(this, cameras[1]);

    // Or, the camera name can be retrieved from the list (you need
    // to enter valid a width, height, and frame rate for the camera).
    //cam = new Capture(this, 640, 480, "FaceTime HD Camera (Built-in)", 30);
  }

  // Start capturing the images from the camera
  cam.start();
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0, width, height);
  // The following does the same as the above image() line, but 
  // is faster when just drawing the image without any additional 
  // resizing, transformations, or tint.
  //set(0, 0, cam);
}

Hi @blippr,

Whenever you have an issue with some library, try to search on the GitHub repository issues:

It seems to be fixed but not released yet.

You can try this fix mentioned in the post:

int FPS = 30; // frames per second
cam = new Capture(this, width, height, cameras[1], FPS);
2 Likes

Thank you, I will try to search there first. In this case it is this specific external webcam that does not work in Processing, the “Microsoft® LifeCam VX-2000”. Another external webcam works (Logitech) in Processing, as do the internal FaceTime HD Camera.

Hi
As @josephh explained
You can use the text of these configurations to create a Capture object. On a Mac with a built-in camera,for example, this might look like:

video = new Capture(this, "name=FaceTime HD Camera (Built-in),size=640x480,fps=30");

Hi Blippr,

I’ve had same trouble with an external usb SJCAM. After a lot of investigation, i’ve found the solution. In my case the problem is that de format (MPEJ o Image/Jpeg) could’t be negotiated with processing video library. So I create a gstreamer pipeline. In linux the sintax to do this is similar to the sintax used in gst-launch. So this have resolved my trouble:

cam = new Capture(this, 640, 480, "pipeline: v4l2src device=/dev/video2 ! image/jpeg, width=640, height=480 ! jpegdec ");

Hope it helps.

Regards
Mariano