Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a virtual camera for OS X

I need to get a synthetic generated video stream in a program like skype. The audio part is easy. There is a project called Soundflower which is an adapter. It presents a virtual audio destination device on the one side and a video source on the other side. I am searching for the same solution for OSX. Except I only need the part how to present it as a virtual camera. Do not misunderstood, I do not need a "ready to use" tool, I need the way how to develop it. So a ready to use tool is only helpful with the source code.

In the Windows world, where I came from, I already programmed such a Virtual Camera using DirectShow. Now I am searching for a similar solution in the OSX world.

like image 949
Martin Schlott Avatar asked Dec 20 '13 09:12

Martin Schlott


People also ask

Is there a virtual cam for Mac?

To get the Mac virtual camera to work on a generic app not already listed: Open the Terminal app which can be found in Launchpad on every Mac. Put in your password. NOTE: you will not see the password being put in, but it will be registering it.


1 Answers

This depends to some extent on the application with which you wish to interface. If it is an old-school QuickTime app (32-bit, 10.8 or earlier), you would need to write a QuickTime vdig (video digitiser) component. This is basically a plugin that provides a certain interface that can be dynamically enumerated and invoked by any QT-compatible app. However, this is all now deprecated (as of 10.9)!

The modern approach is to use the Core Media I/O Framework. Unfortunately, it isn't as thoroughly documented as most of the other frameworks, as it is used by only a fraction of the developer base (who need to create hardware interfaces).

There's an SDK project available, which contains the CoreMedia framework plus some example code:

  • ADC CoreMediaIO SDK

Take a look specifically at IOVideoSampleDevice.

You probably won't need a kext (kernel extension) as you won't be interfacing with real hardware. So hopefully you will just be able to get by with implementing the required CMIO interfaces and registering your device type.

There's a great book available which covers driver development for OS X and iOS:

  • OS X and iOS Kernel Programming

(Disclaimer: the authors are colleges and friends of mine.)

QuickTime used to be the DirectShow equivalent. Now, CoreMedia and friends have superseded it, with a far more modern and flexible API.

like image 168
gavinb Avatar answered Sep 30 '22 00:09

gavinb