11

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Martin Schlott
  • 4,369
  • 3
  • 25
  • 49

1 Answers1

15

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:

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:

(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.

gavinb
  • 19,278
  • 3
  • 45
  • 60
  • Thank you for your answer. I don't believe someone can top your answer but I will give that a chance as I hoped for a answer like: "Sure, there is a a project XY which does exactly what you want and the source is BSD." :-) You show me the stony dark valley :-) Like QuickTime, DirectShow is now superseded after torturing developers for years ( I do not know if QuickTime was a similar mess). I started downloading your suggestion already. I guess in about an hour you will get your green checkmark. – Martin Schlott Dec 20 '13 at 09:53
  • Sure. :) Your request is somewhat a niche topic, so I'd be somewhat surprised if there were a ready-made project that does just this. I've seen such samples for QT, but not CMIO. But this SDK does have a complete example, so you should be able to extract most of what you need from that. Having worked with both DirectShow and QuickTime, I have many more scars from DS! QuickTime is old-fashioned but DS is a nightmare. – gavinb Dec 20 '13 at 10:31
  • 1
    as of October 2015, the mentioned CoreMediaIO SDK project does not compile on Yosemite or El Capitan. I tried to make it work and was able to solve a lot of issue by removing the old source code within the "source" folder and add the equivalent frameworks since it seems they have been bundled into frameworks (added: accelerate, evenkit, audiotoolbox, coreaudio,coreaudiokit, carbon, audiounit). Then I ran into core C++ errors i couldn't get away within a couple hours and decided to let go and I'm hoping an Apple employee would fix the sample source code and we will all be happily ever after... – user1988824 Oct 26 '15 at 14:42
  • @user1988824 Any luck with the virtual camera? – Dmytro Hutsuliak Feb 24 '16 at 12:12
  • @DmitryGutsulyak no luck. I went through a lot of code and examples I found online. I remember being able to get a hold of the video / audio inputs but could not create the virtual device. – user1988824 Feb 25 '16 at 13:28
  • Wow.. with so many apps that do that, I cant believe there is no documentation. Take ManyCam or Snap Camera for example, they are trendy and very 2020. – omarojo Apr 17 '20 at 18:26