Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose a virtual camera on macOS?

I want to write my own camera filters for videochat, and ideally apply them in any/all of the popular videochat applications (Zoom, Hangouts, Skype, etc.). The way I imagine this working is to write a macOS application that reads the camera feed, applies my filters, and exposes an additional virtual camera. This virtual camera could then be selected in whichever videochat application.

I've spent many hours researching how to do this and I'm still not clear if it's even possible with modern macOS APIs. There are a few similar questions on StackOverflow (e.g. here, here), but they are either unanswered or very old. I'm hoping this question will collect advice/links/ideas in the right direction for how to do this as of 2020.

Here's what I got so far:

  • There's a popular tool in the live streaming community called OBS Studio. It captures input from different sources (camera, desktop, etc.), has a plugin system for applying effects, and then streams the output to popular services (e.g. Twitch). However, there is no functionality to expose the stream as a virtual camera on macOS. In discussions about this (thread, thread), folks talk about a tool called Syphon and a tool called CamTwist.

  • Unfortunately, Syphon doesn't expose a virtual camera anymore: "SyphonInject NO LONGER WORKS IN macOS 10.14 (Mojave). Apple closed up the loophole that allows scripting additions in global directories to load into any process. Trying to inject into any process will silently fail. It will work if SIP is disabled, but that's a terrible idea and I'm not going to suggest or help anyone do that."

  • Fortunately, CamTwist works. I got it running on my macOS Catalina, applied some of its builtin effects on my camera stream, and saw it show up as a new camera in my Hangouts settings (after restarting Chrome). This was encouraging.

  • Unfortunately, CamTwist is rather old and not well maintained. It uses Quartz Composer for implementing effects, but Quartz Composer was deprecated by Apple and it's probably living its last days in Catalina.

  • The macOS SDK used to have an API called CoreMediaIO, which might have been the way to expose a virtual camera, but this API was also deprecated. It's not clear if/what is a modern alternative.

  • I guess another way of asking this whole question is: how is CamTwist implemented, how come it still works in macOS Catalina, and how would you implement the same thing in 2020?

Anything that sheds some light on all of this would be highly appreciated!

like image 658
user18184 Avatar asked Apr 09 '20 02:04

user18184


People also ask

Is there a virtual cam for Mac?

NeuralCam Live for Mac is an AI powered virtual webcam app specially designed for Macs with Apple Silicon. After installing and selecting it as the camera in the video call app it starts every time the video conferencing app is started and automatically enhances the webcam video with the last set enhancement settings.

How can I see what my camera sees on my Mac?

Follow the steps below:icon in the Dock bar found at the bottom of the screen. Select Applications from the menu bar, which is to the left in the Finder. Then double-click on the Photo Booth app. It should turn on the Webcam automatically, and you will see the webcam's feed.

How do I enable virtual camera?

Open Zoom, go to Settings, then Video, and choose OBS Virtual Camera as your camera. Return to OBS and click Start Virtual Camera.


1 Answers

I also want to create own camera filter like Snap Camera. So I researched around CoreMediaIO and Syphon. Did you check this Github project? https://github.com/lvsti/CoreMediaIO-DAL-Example

This repository started off as a fork of the official CoreMediaIO sample code by Apple. You know, the original code didn't age well since it was last updated in 2012. So the owner of the repository changed to make it compile on modern systems.

And you can know that the code works in macOS 10.14 (Mojave) to see the following issue. https://github.com/lvsti/CoreMediaIO-DAL-Example/issues/4

Actually I have not created the camera filter yet because I don't know how to send images to virtual camera that builded by CoreMediaIO. I would like to know more information. If you know please tell me.

like image 133
tommy19970714 Avatar answered Oct 18 '22 20:10

tommy19970714