# Capture doesn't work ! (mac M1)

**URL:** https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781
**Category:** Libraries
**Created:** [September 15, 2022, 4:49pm UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781 "2022-09-15T16:49:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ledondodo](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@ledondodo](https://discourse.processing.org/u/ledondodo)
#### Post date: [September 15, 2022, 4:49pm UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781/1 "2022-09-15T16:49:49Z")

</div>

Hello,

I’m trying to use my camera with Capture for the first time and I got some issues… I’m on a MacBook Pro with the M1 chip.  
I’ve downloaded the “Video Library for Processing 4” developed by The Processing Foundation and based on GStreamer.

I’m trying to run the most basic example of code:

```auto
import processing.video.*;
Capture cam;

void setup() {
  size(640,480);
  background(200,0,0);
  
  String[] cameras = Capture.list();
  cam = new Capture(this,cameras[0]);
  cam.start();
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0);
}

```

And every time I run it, or another one, I got this error:

```auto
(Processing core video:9266): GStreamer-CRITICAL **: 18:23:28.932: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed
(Processing core video:9266): GStreamer-CRITICAL **: 18:23:28.945: gst_element_link_pads_full: assertion 'GST_IS_ELEMENT (dest)' failed

```

and sometimes:

```auto
Could not run the sketch (Target VM failed to initialize).
For more information, read Help → Troubleshooting.

```

Sometimes it gets even worse and Java crashes, then I got an error report.  
I’ve updated Java, and even downloaded GStreamer from the official website, but I still get this error.  
I tried to debug it with printing things to know what could go wrong, and the error seems to appear by the line:

```auto
cam = new Capture(this,cameras[0]);

```

So I guess that’s here we load the camera informations, but I still couldn’t fix the issue since I don’t find any answers on the web…

I thought the issue was about the mac built-in camera, but I also tried with another USB-logitech-camera and it still doesn’t work.

Could you help me please ?

---

<div class="post-metadata">

### Author: ![ledondodo](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@ledondodo](https://discourse.processing.org/u/ledondodo)
#### Post date: [September 15, 2022, 4:53pm UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781/2 "2022-09-15T16:53:52Z")

</div>

Here is the full message from the terminal when Java crashes:

```auto
Processing video library using bundled GStreamer 1.20.3
Scanning GStreamer plugins... Done.

(Processing core video:9619): GStreamer-CRITICAL **: 18:47:33.725: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000147b8a944, pid=9619, tid=66835
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.2+8 (17.0.2+8) (build 17.0.2+8)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (17.0.2+8, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# C [libgstreamer-1.0.0.dylib+0x9e944] gst_element_link_pads_full+0x74
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /var/folders/5p/fnpzzwjs79g1jdt8bb32xbbc0000gn/T//hs_err_pid9619.log
#
# If you would like to submit a bug report, please visit:
# https://github.com/adoptium/adoptium-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Could not run the sketch (Target VM failed to initialize).
For more information, read Help → Troubleshooting.

```

---

<div class="post-metadata">

### Author: ![kevinschlei](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@kevinschlei](https://discourse.processing.org/u/kevinschlei)
#### Post date: [September 29, 2022, 10:33am UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781/3 "2022-09-29T10:33:10Z")

</div>

I have also had this issue on my M1 laptop.

Exactly the same GStreamer-CRITICAL error, and sometimes also the full VM crash too.

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [October 15, 2022, 12:10pm UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781/4 "2022-10-15T12:10:56Z")

</div>

I have filed an issue on the Processing4 repository. Not much to add except that I could run the same code no problem on an Intel Mac so the problem seems specific to Apple Silicon.

> <https://github.com/processing/processing4/issues/575>
>
> \## Description
> 
> Attempting to initialize camera capture on Apple Silicon cause…s a critical error in GStreamer. On an Intel Mac, the same issue does \_not\_ happen. Note: this issue has been mentioned on the forum \[here\](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781).
> 
> \## Expected Behavior
> 
> 
> The camera capture should be initiated without errors.
> 
> \## Current Behavior
> 
> A critical error is raised and the camera capture can not be initiated. See below:
> 
> \`\`\`
> Processing video library using bundled GStreamer 1.20.3
> Scanning GStreamer plugins... Done.
> Available cameras:
> FaceTime HD Camera
> 
> (Processing core video:4365): GStreamer-CRITICAL \*\*: 13:31:26.506: gst\_bin\_add\_many: assertion 'GST\_IS\_ELEMENT (element\_1)' failed
> 
> (Processing core video:4365): GStreamer-CRITICAL \*\*: 13:31:26.513: gst\_element\_link\_pads\_full: assertion 'GST\_IS\_ELEMENT (dest)' failed
> \`\`\`
> 
> \## Steps to Reproduce
> 
> 
> 1. Use an M1 MacBook Pro
> 2. Try running the \[capture example\](https://processing.org/reference/libraries/video/Capture.html) from the reference
> 3. See errors in the console
> 
> Below is a stripped down version of the example that still triggers the error. The error doesn't happen if you comment out \`cam = new Capture(this, cameras\[0\]);\`
> 
> \`\`\`Java
> import processing.video.\*;
> 
> Capture cam;
> 
> void setup() {
> size(640, 480);
> 
> String\[\] cameras = Capture.list();
>   
> if (cameras.length == 0) {
> println("There are no cameras available for capture.");
> exit();
> } else {
> println("Available cameras:");
> for (int i = 0; i \< cameras.length; i++) {
> println(cameras\[i\]);
> }
> 
> cam = new Capture(this, cameras\[0\]);
> //cam.start();     
> }      
> }
> \`\`\`
> 
> \## Your Environment
> \* Processing version: 4.0.1
> \* Operating System and OS version: MacOS 12.5.1 Monterey 
> \* Other info: M1 Max CPU
> 
> \## Possible Causes / Solutions
> 
> Unknown

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [October 18, 2022, 1:47pm UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781/5 "2022-10-18T13:47:10Z")

</div>

Just saw the following workaround [suggested on the Github issue](https://github.com/processing/processing4/issues/575#issuecomment-1282368416).

```auto
cam = new Capture(this, 640, 480, "pipeline:avfvideosrc device-index=0 ! video/x-raw, width=640, height=480, framerate=30/1");

```

This worked for me on macOS 12.5.1 (Monterey) on an M1 Macbook Pro.

---

<div class="post-metadata">

### Author: ![ledondodo](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@ledondodo](https://discourse.processing.org/u/ledondodo)
#### Post date: [October 19, 2022, 6:20pm UTC](https://discourse.processing.org/t/capture-doesnt-work-mac-m1/38781/6 "2022-10-19T18:20:06Z")

</div>

Amazing! It worked, thanks.
