title: How to expose a virtual camera on macOS?
body: <p>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.</p>
  
  <p>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. <a href="https://stackoverflow.com/questions/55714548/create-edit-stream-virtual-camera-for-mac">here</a>, <a href="https://stackoverflow.com/questions/20700007/building-a-virtual-camera-for-os-x">here</a>), 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.</p>
  
  <p>Here's what I got so far:</p>
  
  <ul>
  <li><p>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 (<a href="https://obsproject.com/forum/threads/virtual-web-cam-solution-for-mac.93632/" rel="noreferrer">thread</a>, <a href="https://www.reddit.com/r/obs/comments/9t95v4/virtualcam_addon_for_mac_users/" rel="noreferrer">thread</a>), folks talk about a tool called Syphon and a tool called CamTwist.</p></li>
  <li><p>Unfortunately, Syphon doesn't expose a virtual camera <a href="https://github.com/zakk4223/SyphonInject" rel="noreferrer">anymore</a>: "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."</p></li>
  <li><p>Fortunately, <a href="http://camtwiststudio.com/" rel="noreferrer">CamTwist</a> 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 <a href="https://www.success.grownupgeek.com/index.php/2013/03/16/how-to-use-camtwist-in-google-hangouts/" rel="noreferrer">restarting</a> Chrome). This was encouraging.</p></li>
  <li><p>Unfortunately, CamTwist is rather old and not well maintained. It uses Quartz Composer for implementing effects, but Quartz Composer was <a href="https://vdmx.vidvox.net/blog/quartz-composer-im-not-dead-yet" rel="noreferrer">deprecated</a> by Apple and it's probably living its last days in Catalina.</p></li>
  <li><p>The macOS SDK used to have an API called <a href="https://developer.apple.com/library/archive/samplecode/CoreMediaIO/Introduction/Intro.html" rel="noreferrer">CoreMediaIO</a>, which might have been the way to expose a virtual camera, but this API was also deprecated. It's <a href="https://stackoverflow.com/questions/56157333/what-is-coremediaio-dal-virtual-camera-alternative-in-macos-mojave">not clear</a> if/what is a modern alternative.</p></li>
  <li><p>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?</p></li>
  </ul>
  
  <p>Anything that sheds some light on all of this would be highly appreciated!</p>