# Usb webcam " Internal data stream error"

**URL:** <https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073>\
**Category:** Libraries\
**Created:** [October 4, 2022, 12:53pm UTC](https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073 "2022-10-04T12:53:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blippr](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@blippr](https://discourse.processing.org/u/blippr)\
**Post date:** [October 4, 2022, 12:53pm UTC](https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073/1 "2022-10-04T12:53:25Z")

</div>

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:

```auto
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”:

```auto
/**
 * 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);
}

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [October 4, 2022, 1:02pm UTC](https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073/2 "2022-10-04T13:02:44Z")

</div>

Hi @blippr,

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

> <https://github.com/processing/processing-video/issues/191>
>
> \## Description
> 
> 
> Using the internal camera on a MacBook results in a streamin…g error
> 
> \## Expected Behavior
> 
> 
> Be able to use the internal MacBook camera as a Capture device
> 
> \## Current Behavior
> 
> 
> \## Steps to Reproduce
> 
> 
> 1. Pick any example under Examples \> Libraries \> Video \> Capture, e.g. Mirror
> 2. Press Cmd-R or the Run icon
> 3. A window pops up but the console reports an error:
> \`\`\`
> Processing video library using GStreamer 1.16.2
> BaseSrc: \[avfvideosrc0\] : Internal data stream error.
> \`\`\`
> 
> \## Your Environment
> 
>  
> 
> \* Processing version: 4.0b2
> \* Operating System and OS version: MacOS Monterey 12.1
> \* Other information: MacBook Pro 13, 2020
> 
> \## Possible Causes / Solutions

It seems to be fixed but not released yet.

You can try this fix mentioned in the post:

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

```

---

<div class="post-metadata">

**Author:** ![blippr](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@blippr](https://discourse.processing.org/u/blippr)\
**Post date:** [October 4, 2022, 1:19pm UTC](https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073/3 "2022-10-04T13:19:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [October 4, 2022, 1:21pm UTC](https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073/4 "2022-10-04T13:21:49Z")

</div>

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:

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

```

> **[Video](https://processing.org/tutorials/video/)**
>
> How to display live and recorded video.

---

<div class="post-metadata">

**Author:** ![marianoacc](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@marianoacc](https://discourse.processing.org/u/marianoacc)\
**Post date:** [January 28, 2024, 4:25pm UTC](https://discourse.processing.org/t/usb-webcam-internal-data-stream-error/39073/5 "2024-01-28T16:25:37Z")

</div>

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
