Skip to content

Using the internal MacBook camera results in a streaming error #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davantwillert opened this issue Dec 22, 2021 · 25 comments
Closed

Using the internal MacBook camera results in a streaming error #191

davantwillert opened this issue Dec 22, 2021 · 25 comments

Comments

@davantwillert
Copy link

Description

Using the internal camera on a MacBook results in a streaming 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

@davantwillert
Copy link
Author

Also tried it with "pipeline:avfvideosrc" and "pipeline:avfvideosrc device-index=0" as names and still got the streaming error.

@twisst
Copy link

twisst commented Dec 28, 2021

Same problem in MacOS Monterey 12.0.1 with the same laptop and Processing version.

@tjcruz-dei
Copy link

I'm having exactly the same problem: MacOS Monterey, MacBook Air (Retina, 13-inch, 2019).

@twisst
Copy link

twisst commented Jan 4, 2022

Apparently there are more problems with Monterey and Gstreamer: https://discourse.processing.org/t/processing-new-gstreamer-error/33975/8

@twisst
Copy link

twisst commented Jan 4, 2022

The last comment on this post led me to try a workaround which does help.

If you start OBS Studio, start the virtual camera and then run the sketch, it works fine. Apparently there is some kind of mismatch between how the built-in Facetime camera should be started and what Gstreamer is trying, and putting OBS in between fixes that. Apparently this problem is not unique to Gstreamer or Processing.

@benfry benfry transferred this issue from benfry/processing4 Jan 10, 2022
@mrbbp
Copy link

mrbbp commented Mar 23, 2022

By using Capture.list() to choose the webcam, i'm able to initialize the webcam on my macbook pro 2018, 4 thunderbolt
otherwize if i don't select device it does not works, even with OBS.
Tried with other mbp (M1 and older) without OBS, it initialize webcam.

cam = new Capture(this, width, height, Capture.list()[1]);

for me Capture.list[0] is OBS virtual cam

MacBook Pro (13-inch, 2018, Four Thunderbolt 3 Ports)
MacOS Catalina - 10.15.7

@davantwillert
Copy link
Author

davantwillert commented Mar 23, 2022

Still get the same error, even with Capture.list()[0]. Printing out the list shows "FaceTime HD Camera (Built-in)" but the same streaming error:
"Processing video library using GStreamer 1.16.2
FaceTime HD Camera (Built-in)
BaseSrc: [avfvideosrc0] : Internal data stream error."

@mrbbp
Copy link

mrbbp commented Mar 24, 2022

Still get the same error, even with Capture.list()[0]. Printing out the list shows "FaceTime HD Camera (Built-in)" but the same streaming error: "Processing video library using GStreamer 1.16.2 FaceTime HD Camera (Built-in) BaseSrc: [avfvideosrc0] : Internal data stream error."

Did you tried to install OBS and configure Virtual Camera as @twisst recommand?
With virtual camera of OBS installed,
if I use the capture sketches, I have no error but the launched camera is the virtual camera (OBS is not launched) which displays an image with the OBS logo. and I have no more error message.

@azemanatela
Copy link

I solved by writting:
FPS = 30; // frames per second
cam = new Capture(this, width, height, Capture.list()[0],FPS);

@ludiccc
Copy link

ludiccc commented Jun 17, 2022

I confirm this error with external cameras also.

@codeanticode
Copy link
Member

Fixed with ace6d59

@Fierozen
Copy link

Fierozen commented Feb 21, 2023

There may be an additional problem as I still get the same error with Processing 4.1.3, even when using the full method signature for a second USB camera. This code works for "FaceTime HD Camera (Built-in)", but not with a second USB camera. And I tried it with two different USB cameras. The lines printed by the printArray are:
[0] "HD Web Camera"
[1] "FaceTime HD Camera (Built-in)"

cameras = Capture.list();
printArray(cameras);
size(640, 480);
int FPS = 30;
video = new Capture(this, width/scl, height/scl, cameras[0], FPS);

The error message is still the same:

BaseSrc: [avfvideosrc0] : Internal data stream error.

UPDATE: It now works with this call to the Capture constructor:

video = new Capture(this, width/scl, height/scl, cameras[0]);

But it does not work with this:

video = new Capture(this, width/scl, height/scl, cameras[0], 30); // nor does it work with , FPS)

One more variable I introduced before it started working was that I installed the processing.video library for 3.5.3. But this example is now working in 4.1.3.

@ludiccc
Copy link

ludiccc commented Feb 25, 2023

I tried your code with Processing 4.2 and video library 2.2.2 and worked without any problem.

@davantwillert
Copy link
Author

I tried your code with Processing 4.2 and video library 2.2.2 and worked without any problem.

For me the example works in 4.1.3 / video library 2.2.2 with both an external and internal camera.
The issue was closed as it works I guess.

There is an odd thing on MacOS where I need to provide the FPS for the internal camera (30).
It would be nice to be able to see all the modes (resolution and FPS) like Capture.list() provided in Processing 3.

@Fierozen
Copy link

Well, as I've said. I've got it working now with the external USB camera on MacOS. But given your comment quoted below, I now need to go back and see if it will work on the internal MacOS camera without the FPS parameter.

There is an odd thing on MacOS where I need to provide the FPS for the internal camera (30).

@hamoid
Copy link
Contributor

hamoid commented Jul 30, 2023

Hi :-) I'm trying to help someone revive an old project I did which uses a USB webcam. She uses an M1 Intel Mac. This is the error with the GettingStartedCapture

Processing video library using bundled GStreamer 1.20.3
Scanning GStreamer plugins... Done.
Available cameras:
[0] "Live! Cam Sync HD VF0770"
[1] "Cámara FaceTime HD (integrada)"
BaseSrc: [avfvideosrc0] : Internal data stream error.

In the software I wrote I specified 30 FPS but it doesn't help.
The video library version is 2.2.2.

Any ideas what I could try?

@hamoid
Copy link
Contributor

hamoid commented Jul 30, 2023

Here a test program

import processing.video.*;

Capture cam;
void setup() {
  size(640, 480);
  String[] cameras = Capture.list();
  println("Available cameras:");
  printArray(cameras);
  cam = new Capture(this, 640, 480, cameras[0]);
  cam.start();
}
void draw() {
  if (cam.available()) cam.read();
  image(cam, 0, 0);
}

and the resulting screenshot
err

@ajavamind
Copy link

I don't use iOS, but when I encounter a problem like this in Windows, I used FFmpeg to show me all the USB/UVC cameras with resolutions and fps used. I pick one and use Capture with a pipeline to set width, height, and fps for that particular camera I want.

video = new Capture(this, cameraWidth, cameraHeight, pipeline);
The last time I used ffmpeg for this purpose resulted in a pipeline like this:
cam = new Capture(this, 1280,720, "pipeline: ksvideosrc device-index=0 ! image/jpeg, width=1280, height=720, framerate=15/1 ! jpegdec ! videoconvert");

ksvideosrc is a Windows only source.

There may be version of ffmpeg on iOS. http://ffmpeg.org/download.html#build-mac

@hamoid
Copy link
Contributor

hamoid commented Aug 3, 2023

Just adding here the OS info / specs of the problematic computer:

image

@ludiccc
Copy link

ludiccc commented Aug 3, 2023 via email

@hamoid
Copy link
Contributor

hamoid commented Aug 5, 2023

In another Intel MacBook from 2013 the same program works fine 🤷‍♂️
image
So the framerate is not necessarily involved (and I tried with and without).

@hamoid
Copy link
Contributor

hamoid commented Sep 7, 2023

The problems in two different Mac computers were solved by updating Mac OS. Otherwise both failed to run any webcam examples.

@twisst
Copy link

twisst commented Apr 9, 2024

BaseSrc: [avfvideosrc0] : Internal data stream error.

UPDATE: It now works with this call to the Capture constructor:

video = new Capture(this, width/scl, height/scl, cameras[0]);

But it does not work with this:

video = new Capture(this, width/scl, height/scl, cameras[0], 30); // nor does it work with , FPS)

One more variable I introduced before it started working was that I installed the processing.video library for 3.5.3. But this example is now working in 4.1.3.

Same thing here, on Processing 4.3 on a Macbook Pro 2020, Sonoma 14.4.1. Previous adding the FPS fixed this issue, now it's the reverse :-D Thanks for the tip.

@ostermuellerj
Copy link

Sonoma 14.4
Posting for posterity, was getting error:

Processing video library using bundled GStreamer 1.20.3
Scanning GStreamer plugins... Done.
Available cameras:
FaceTime HD Camera (Built-in)
BaseSrc: [avfvideosrc0] : Internal data stream error.

Was fixed with the proposed solution here: #208
i.e.
cam = new Capture(this, "pipeline:autovideosrc");
This fixed my error.

@mrwenchen
Copy link

Change the camera[0] to "pipeline:avfvideosrc device-index=0", then it will work, found the solution on this forum: https://lab.arts.ac.uk/books/creative-coding/page/how-to-fix-internal-data-stream-error-in-processing-4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests