Skip to content
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

Video capture not working in Mac OS Catalina (and later) #134

Closed
grauwald opened this issue Oct 18, 2019 · 103 comments
Closed

Video capture not working in Mac OS Catalina (and later) #134

grauwald opened this issue Oct 18, 2019 · 103 comments

Comments

@grauwald
Copy link

Running the example file that comes with the Processing video library throws the following error:

libc++abi.dylib: terminating with uncaught exception of type NSException Could not run the sketch (Target VM failed to initialize). Make sure that you haven't set the maximum available memory too high. For more information, read revisions.txt and Help → Troubleshooting.

This issue is also reported here:

https://discourse.processing.org/t/did-macos-catalina-or-something-break-the-video-library/14699

There is some speculation in that thread that the library depends on 32bit compiled code which is no longer supported in Mac OS Catalina as Apple is now requiring applications be 64bit.

Resolving this issue is beyond my expertise but it would be awesome if Mac users could continue to use the video library without having to downgrade to older versions of OS X.

@grauwald
Copy link
Author

Some further info on this for anyone willing and able to tackle it. As the Video library is built off GStreamer decided to take a look at that project directly and found a recent commit that adds support of Mac OS X Catalina:

GStreamer/cerbero@2c9fc16

Perhaps this is as simple as integrating this new build?

@suyashcjoshi
Copy link

I'm seeing the same problem, even simple Processing Video example Sketch is not working on Mac OS Catalina.

@suyashcjoshi
Copy link

Some further info on this for anyone willing and able to tackle it. As the Video library is built off GStreamer decided to take a look at that project directly and found a recent commit that adds support of Mac OS X Catalina:

GStreamer/cerbero@2c9fc16

Perhaps this is as simple as integrating this new build?

I tried to look but can't figure out where to make change in order to integrate the new build of cerbero.

@james628
Copy link

james628 commented Nov 1, 2019

I am looking forward to catch this bug.
Please solve and release.
Thank you.

@grauwald
Copy link
Author

grauwald commented Nov 1, 2019

@codeanticode it looks like you are the primary maintainer of this lib. Any chance Mac OS Catalina will be supported in the future?

@codeanticode codeanticode added this to the Version 2.0 stable milestone Nov 1, 2019
@codeanticode
Copy link
Member

@grauwald Definitely, this is a high-priority issue. I haven't installed Mac OS Catalina yet, so I'm curious if you have tried the latest beta, does it work with it?

@vdurnev
Copy link

vdurnev commented Nov 2, 2019

@codeanticode I can confirm that with latest beta build video examples stat working again. There is another issue with samples - you have to pass camera name to Capture constructor). This code: video = new Capture(this, width, height); generates null pointer exception, but video = new Capture(this,320, 240, "FaceTime HD Camera"); works

@codeanticode
Copy link
Member

@vdurnev this is great news, thanks a lot for testing! The other issue you mentioned has been fixed with this PR: #135

@larspai
Copy link

larspai commented Nov 4, 2019

Super news. How does an ordinary user get access to this update? (No update available in install library menu...?)

@grauwald
Copy link
Author

grauwald commented Nov 4, 2019

@codeanticode was able to successfully run the latest beta of v2 of the video library. Yay!!!

For those coming along trying to do this, had to do some command line to get OS X to give permissions to run the .dylib used by the lib. Based on this hackish solution here: Jackett/Jackett#5589 (comment)

Guessing the final release of this lib will be signed and verified so this security issue in Catalina won't be a problem.

@ihaveaccount
Copy link

v2 library works on catalina, thank you @codeanticode

How to install

$ xattr -p com.apple.quarantine libavcodec.58.35.100.dylib
it will return string like this:
0081;5dc1bfaa;Chrome;78F18F7D-3F71-4E55-8D58-BAB946AB4707

replace 0081 with 00c1 and copy string

then replace STRING in the following command with your string
$ xattr -w com.apple.quarantine "STRING" *.dylib
it will fix all libraries in this folder

then cd to gstreamer-1.0/ and run command again

@larspai
Copy link

larspai commented Nov 6, 2019

Worked for me. Thanks!

@easytarget2000
Copy link

Thanks a lot, @ihaveaccount. That did the trick.
There were two parts that I struggled with for a second:

then replace STRING in the following command with your string
$ xattr -w com.apple.quarantine "STRING" *.dylib

Don't forget the quotation marks!

then cd to gstreamer-1.0/ and run command again

At first, I skipped over this part, as I thought it was talking about re-running the project at this point. gstreamer-1.0/, however, is a sub-dir of library/macosx/. You're supposed to run the xattr -w command in both directories.

It might have been my lack of reading comprehension, but I figured I'd share this as there will be many users in need of this solution over the next couple of days.

You want to run something like this:
$ cd ~/Documents/processing/libraries/video/library/macosx
$ xattr -p com.apple.quarantine libavcodec.58.35.100.dylib
$ xattr -w com.apple.quarantine "00c1;5dc1bfaa;Chrome;78F18F7D-3F71-4E55-8D58-BAB946AB4707" *.dylib
$ cd gstreamer-1.0
$ xattr -w com.apple.quarantine "00c1;5dc1bfaa;Chrome;78F18F7D-3F71-4E55-8D58-BAB946AB4707" *.dylib

Also, be aware that your Processing sketchbook might not be in ~/Documents/processing/, if you have configured the path yourself.

@Stuver
Copy link

Stuver commented Nov 6, 2019

I have tried this twice and the only difference I can see is that I'm using Safari instead of Chrome. Would this make a difference?

@easytarget2000
Copy link

@Stuver, I don't think the source makes a difference. Did you make sure that you used your result from xattr -p com.apple.quarantine libavcodec.58.35.100.dylib and replaced the first four chars with 00c1?
Do you get an error message in Processing or an OS error message regarding insecure libraries?

@Stuver
Copy link

Stuver commented Nov 6, 2019

Yes. I've done that and manually verified all the packages within the library and still no luck

@briangriffith
Copy link

I can also confirm it worked, the manual validation of 200+ lib files is wildly frustrating, aside from that @ihaveaccount and @easytarget2000 give solid instructions.

@5knnbdwm
Copy link

Hey, it tried it all and it still isn't working for me. But I also got a different result from running xattr -p com.apple.quarantine libavcodec.58.35.100.dylib. As instead of 0081 I got 0083, changed it anyways to 00c1.
The error message that I now receive are Processing video library using GStreamer 1.16.0 and a couple NullPointerException

@danieloskarsson
Copy link

I also updated to Catalina and struggled with this and only got it working thanks to comments by @codeanticode @ihaveaccount and @vdurnev. However to get it work on my 2018 Macbook Pro 13" needed to change the name of the camera "FaceTime HD Camera" -> "FaceTime HD Camera (Built-in)".

import processing.video.*;
static final String CAMERA_NAME = "FaceTime HD Camera (Built-in)";
Capture cam;
void setup() {
  size(1080, 720);
  cam = new Capture(this, width, height, CAMERA_NAME);
  cam.start();
}

@romya0010
Copy link

romya0010 commented Nov 10, 2019

Update:
OK, @danieloskarsson thanks, tried your method and it works perfect. You saved my life 🥇

Hi guys, I'm new here... very exited :)
So I got the video library working with your amazing advice and updates, but now, trying to use opencv library for computer vision, I get this error message:
Processing video library using GStreamer 1.16.0
NullPointerException...

Help please

Here's the code (from examples of opencv library):

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

  video.start();
}

void draw() {
  scale(2);
  opencv.loadImage(video);

  image(video, 0, 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  println(faces.length);

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

@codeanticode
Copy link
Member

@romya0010 I think that's because of a bug in beta 4 reported here #130. For the time being, the workaround is to add the camera name to the arguments of the Camera constructor.

@mariuswex
Copy link

Hello, im new and this is my first day i worked with processing.
I hope you can help me. I got the Problem with the FaceTime Camera. I also work with macOS Catalina.

At this point I can't get forward.

  • open console, cd to ~/Documents/processing/libraries/video/library/macosx

Which console? what do you mean with "cd"

And I can't find this file:
0081;5dc1bfaa;Chrome;78F18F7D-3F71-4E55-8D58-BAB946AB4707

And I don't understand this:
then replace STRING in the following command with your string
$ xattr -w com.apple.quarantine "STRING" *.dylib
it will fix all libraries in this folder

then cd to gstreamer-1.0/ and run command again

Please help me, thanks a lot!

@vwls
Copy link

vwls commented Dec 2, 2019

v2 library works on catalina, thank you @codeanticode

How to install

$ xattr -p com.apple.quarantine libavcodec.58.35.100.dylib
it will return string like this:
0081;5dc1bfaa;Chrome;78F18F7D-3F71-4E55-8D58-BAB946AB4707

replace 0081 with 00c1 and copy string

then replace STRING in the following command with your string
$ xattr -w com.apple.quarantine "STRING" *.dylib
it will fix all libraries in this folder

then cd to gstreamer-1.0/ and run command again

Solution worked for me (macOS Catalina 10.15.1 MacBook Pro Retina 13 inch early 2013 edition).
Thanks @ihaveaccount and @codeanticode !

@dantepfer
Copy link

Installed beta 4 successfully following @ihaveaccount's directions, on Catalina. Video examples work as long as a name is specified for the camera, but the default camera (no name specified) does not, as others have pointed out.

@codeanticode, thanks much for your work on this. FYI, I do camera capture with a BlackMagic interface. For some reason it's never turned up with a name in the "Available Cameras" list, but it does work as the default camera (without specifying a name). So, for now my ability to use it is broken, and I'll be very happy when the previous default camera behavior returns. Thanks again!

@codeanticode
Copy link
Member

@dantepfer thanks for your update. I had pause the work on the video library while I take care of other projects but the plan is to come back to it as soon as time permits and finalize the v2 release :-)

@andmaliang
Copy link

As a student starting to use Processing wanting it to work and after a day of searching Forums and threads this is what worked for me in 7 (almost) easy steps:
macOs Catalina 10.15.3 (MacBook Pro, 2018)

1. replace ~/Documents/processing/libraries/video with "video" folder from https://github.com/processing/processing-video/releases/tag/r6-v2.0-beta4

By now the video library was not recognized so I followed @ihaveaccount comment (#134 (comment)) but used @easytarget2000 commands (#134 (comment))

1. Open Terminal and run these commands:


* cd ~/Documents/processing/libraries/video/library/macosx

* xattr -p com.apple.quarantine libavcodec.58.35.100.dylib

"it will return string like this:
0081;5dc1bfaa;Chrome;78F18F7D-3F71-4E55-8D58-BAB946AB4707
replace 0081 with 00c1 and copy string
then replace STRING in the following command with your string"

* xattr -w com.apple.quarantine "STRING" *.dylib

* cd gstreamer-1.0

* xattr -w com.apple.quarantine "STRING" *.dylib

Nothing new in this comment section, but by now I got the library reading but this error messages "Processing video library using GStreamer 1.16.0" e "Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help → Troubleshooting."

The built-in camera was recognized using these lines of code:
String [] cameras = Capture.list();
println(cameras[0]);
capture = new Capture(this, 320, 240, cameras[0]);

But just a big crash report after running the sketch (Processing app was not authorized to use the camera)

My solution for this:
3. Go to /Applications and right-click on the Processing app to "show Package Contents"
4. Go to Processing.app/Contents/MacOS folder and run the "Processing" file (it should open Terminal and then Processing)
5. Go to "Files Open Recent" or "Exemples" and run a sketch WITH the "Capture" function
6. This should Pop-Up a request access to the camera! Accept it
7. After closing Terminal and Processing it worked perfectly for me!

I advise reading the tagged comments before you follow these steps since they are from much more experienced people than I am!

Hope it helps! And sorry for grammar or some noob mistakes since I created an account just to post this and to thanks all of the comments since it's from them that I was able to do this.

Thanks, VendrellPT, some of us followed this step and runs very well, but some of us if we check the mac preferences the permission of camera allows not processing app, but terminal, after we opened the content folder and open procssing by terminal. so each time we open processing and using video library , we have to go inside processing cotent and open it by terminal, how to ssolve this problem ?

@crcdng
Copy link

crcdng commented Jun 14, 2020

My step-by-step workaround for camera and microphone (requires that you are a member of the Apple Developer program) here:

https://gist.github.com/i3games/b063987dfb62baf5d0afda422631b480

@tobiasalbirosa
Copy link

tobiasalbirosa commented Jul 16, 2020

Running the example file that comes with the Processing video library throws the following error:

libc++abi.dylib: terminating with uncaught exception of type NSException Could not run the sketch (Target VM failed to initialize). Make sure that you haven't set the maximum available memory too high. For more information, read revisions.txt and Help → Troubleshooting.

This issue is also reported here:

https://discourse.processing.org/t/did-macos-catalina-or-something-break-the-video-library/14699

There is some speculation in that thread that the library depends on 32bit compiled code which is no longer supported in Mac OS Catalina as Apple is now requiring applications be 64bit.

Resolving this issue is beyond my expertise but it would be awesome if Mac users could continue to use the video library without having to downgrade to older versions of OS X.

https://github.com/processing/processing-video/releases I'd tried whit an lower version and work it, i have mac os catalina 10.15.16(updated today) and processing 3.5.4(updated today), using Video Library Release 5 (version 2.0-beta3)([https://github.com/processing/processing-video/releases/tag/r5-v2.0-beta3]), the last Release is the 6

@tobiasalbirosa
Copy link

tobiasalbirosa commented Jul 16, 2020

Running the example file that comes with the Processing video library throws the following error:

libc++abi.dylib: terminating with uncaught exception of type NSException Could not run the sketch (Target VM failed to initialize). Make sure that you haven't set the maximum available memory too high. For more information, read revisions.txt and Help → Troubleshooting.

This issue is also reported here:

https://discourse.processing.org/t/did-macos-catalina-or-something-break-the-video-library/14699

There is some speculation in that thread that the library depends on 32bit compiled code which is no longer supported in Mac OS Catalina as Apple is now requiring applications be 64bit.

Resolving this issue is beyond my expertise but it would be awesome if Mac users could continue to use the video library without having to downgrade to older versions of OS X.

capture

@seungtaehello
Copy link

For those of you still having this problem I found a trick that worked on my MacBook Pro 2019. I tried everything else here and still no luck until this.
That being said I am running
Processing beta 4
The Video 2.0 beta 4 video library
GStreamer 1.16.2

If you run the “GettingStartedCapture” sketch from terminal Catalina prompts you to allow permission!

1)Install "processing-java" so you can run a sketch from terminal.
From the processing tools menu select - install processing-java. Select For all users when prompted.

2)Open terminal and run the gettingStartedCapture sketch or any sketch that tries to use the camera. Use the full path to the directory containing the sketch on your machine. For me it looked like this

processing-java --sketch=/Users/jamesc/Documents/Processing/libraries/video/examples/Capture/GettingStartedCapture --run

Thank you so much for this!! I have spent two days to solve this problem. Now it works!

@makakken
Copy link

makakken commented Sep 1, 2020

okay, new update, after installing with the workaround of: #134 (comment)

i got the following error:

Processing video library using GStreamer 1.16.0
Available cameras:
FaceTime HD-Kamera (integriert)
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

I really need that fix ;) Can i help in any way?

MacOS Catalina 10.15.6
Processing 3.5.4

So, i tryed from command line:

Processing video library using GStreamer 1.16.0
Available cameras:
[0] "FaceTime HD-Kamera (integriert)"
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help � Troubleshooting.
Could not run the sketch.
[Finished in 6.8s with exit code 1]
[cmd: ['processing-java', '--force', '--sketch=/Users/gooze/Documents/Processing/libraries/video/examples/Capture/GettingStartedCapture', '--run']]
[dir: /Users/gooze/Documents/Processing/libraries/video/examples/Capture/GettingStartedCapture]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin]

@rodinia814
Copy link

I followed the steps here which fixed the issue for me (make sure Processing is not running, or quit and restart it after doing these steps): https://discourse.processing.org/t/did-macos-catalina-or-something-break-the-video-library/14699/17

@benfry
Copy link
Contributor

benfry commented Sep 23, 2020

Hi all, sorry that this has been broken for so long. The video and sound libraries were moved out of the core because 1) they were very large, and 2) so that others could maintain them. Unfortunately there's nobody doing that maintenance at the moment, so here we are.

I've made some additional edits for the next Processing 4 release (alpha 3) that should at least provide the basis for this, so that code will request camera access. We'll have to get a new video release out, however, so that it works without additional messing with folders and .dylib files.

Thanks very much to @VendrellPT for the helpful comment on how to get things working in the meantime.

@johnbcarpenter
Copy link

Thanks for all your work on the Processing codebase Ben!

@benfry
Copy link
Contributor

benfry commented Oct 8, 2020

Thanks, @johnbcarpenter.

Alright folks, @codeanticode was able to make some additional updates to the video library and has posted a new 2.0 release!

You can find the release here: https://github.com/processing/processing-video/releases/tag/latest and it should show up as an update in the Contributions Manager sometime soon.

Also, be sure to read the following from the release notes:

Camera capture should work in Processing 3.x when running on Windows and Linux, unfortunately, due to security & privacy changes in macOS since Mojave, it will not work on macOS 10.14 and newer. Camera capture is supported on macOS only in Processing 4.x. Video playback should work in Processing 3.x across all platforms though.

@benfry benfry closed this as completed Oct 8, 2020
@benfry benfry reopened this Oct 8, 2020
@benfry
Copy link
Contributor

benfry commented Oct 8, 2020

(Didn't mean to close that…) We'll post a 4.0a3 release soon which incorporates the additional changes so that applications prompt for the necessary permissions. Once that's done, we should be all set.

In the meantime, you can build Processing 4 from the source and manually install the latest video release if you don't want to wait.

@doronby
Copy link

doronby commented Oct 21, 2020

ETA ?

@benfry
Copy link
Contributor

benfry commented Oct 22, 2020

No. I do this in my free time. Tricky to set an “ETA” for one's free time.

@benfry benfry changed the title Video capture not working in Mac OS Catalina Video capture not working in Mac OS Catalina (and later) Jan 17, 2021
@processing processing deleted a comment from AlexandreKieber Jan 18, 2021
@processing processing deleted a comment from highjeans Jan 18, 2021
@benfry
Copy link
Contributor

benfry commented Jan 18, 2021

Removed two posts from folks who didn't read what's already here, in order to avoid confusion for future visitors.

Now locking until the release is out…

@processing processing locked and limited conversation to collaborators Jan 18, 2021
@benfry
Copy link
Contributor

benfry commented Jan 18, 2021

4.0 alpha 3 now posted: https://github.com/processing/processing4/releases/tag/processing-1272-4.0a3

Be sure to update to a 2.x release of the Video library.

I have no plans (or more realistically, no time) to update Processing 3.x, so if you want to do video/sound capture work on macOS, this is the release to use.

Capture can still be a little slow to start up, and may require more than one attempt on the first try to get the macOS security dialog to show up. Not sure what's going on there, but eager for someone else to help improve it.

@benfry benfry closed this as completed Jan 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests