Hello,
I’m learning Processing and currently having problem with displaying video from webcam using Processing Video library. the console shows this:
Processing video library using bundled GStreamer 1.20.3
Scanning GStreamer plugins... Done.
(Processing core video:23010): GStreamer-CRITICAL **: 16:48:23.550: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed
(Processing core video:23010): GStreamer-CRITICAL **: 16:48:23.558: gst_element_link_pads_full: assertion 'GST_IS_ELEMENT (dest)' failed
 
and the display window is black.
Can anyone help with this? I’m running Processing 4.0.1 Apple Silicon version.
Thank you,
             
            
               
               
               
            
            
           
          
            
            
              Hello @thinh.pham  I have noticed the same issue and reported it on Github (see link below). It seems like the video library is currently broken on Apple Silicon.
  
  
    
  
  
    
    
      
        opened 12:09PM - 15 Oct 22 UTC 
      
      
     
    
    
   
 
  
    ## 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 
   
   
  
    
    
  
  
 
             
            
               
               
              2 Likes 
            
            
           
          
            
            
              You could also see if this example works for you - gst1-java-examples/SwingCamera at master · gstreamer-java/gst1-java-examples · GitHub 
Might help narrow down whether this is a bug in Processing Video or lower down the stack.
             
            
               
               
              1 Like 
            
            
           
          
            
            
              Just saw the following workaround suggested on the Github issue .
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.
             
            
               
               
              3 Likes 
            
            
           
          
            
            
              Also try "pipeline:autovideosrc". If it works, that is at least cross-platform.
             
            
               
               
              2 Likes 
            
            
           
          
            
            
              Thanks for the tip! The following worked for me:
cam = new Capture(this, 640, 480, "pipeline:autovideosrc ! video/x-raw, width=640, height=480, framerate=30/1");
 
             
            
               
               
              1 Like 
            
            
           
          
            
            
              What about without the caps bit too?  eg. just "pipeline:autovideosrc". If that works it would exclude one possible problem.  I need to do more testing of the GStreamer bindings on native Apple Silicon (currently still doing most stuff with x86_64 JVM via Rosetta).  Might be something awry going on in device discovery, or the way that Processing Video is using that.
             
            
               
               
               
            
            
           
          
            
            
              
Thanks for the suggestion   However, I’m not sure I understand what you mean. Could you share your version of the line of code in question?
             
            
               
               
               
            
            
           
          
            
            
              Just -
cam = new Capture(this, 640, 480, "pipeline:autovideosrc");
 
             
            
               
               
              2 Likes 
            
            
           
          
            
            
              Thanks! It technically works but the image gets stretched.
             
            
               
               
              1 Like