简体   繁体   English

为OS X构建虚拟摄像头

[英]Building a virtual camera for OS X

I need to get a synthetic generated video stream in a program like skype. 我需要在像skype这样的程序中获得合成生成的视频流。 The audio part is easy. 音频部分很简单。 There is a project called Soundflower which is an adapter. 有一个名为Soundflower的项目,它是一个适配器。 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. 我正在为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. 在Windows世界中,我来自哪里,我已经使用DirectShow编写了这样的虚拟相机。 Now I am searching for a similar solution in the OSX world. 现在我在OSX世界中寻找类似的解决方案。

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. 如果它是一个老式的QuickTime应用程序(32位,10.8或更早版本),则需要编写QuickTime vdig (视频数字转换器)组件。 This is basically a plugin that provides a certain interface that can be dynamically enumerated and invoked by any QT-compatible app. 这基本上是一个插件,它提供了一个可以由任何QT兼容的应用程序动态枚举和调用的特定接口。 However, this is all now deprecated (as of 10.9)! 但是,这一切现已全部弃用(截至10.9)!

The modern approach is to use the Core Media I/O Framework. 现代方法是使用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: 有一个SDK项目可用,其中包含CoreMedia框架和一些示例代码:

Take a look specifically at IOVideoSampleDevice . 具体看一下IOVideoSampleDevice

You probably won't need a kext (kernel extension) as you won't be interfacing with real hardware. 您可能不需要kext (内核扩展),因为您将无法与真实硬件连接。 So hopefully you will just be able to get by with implementing the required CMIO interfaces and registering your device type. 因此,希望您能够实现所需的CMIO接口并注册您的设备类型。

There's a great book available which covers driver development for OS X and iOS: 有一本很棒的书,涵盖了OS X和iOS的驱动程序开发:

(Disclaimer: the authors are colleges and friends of mine.) (免责声明:作者是我的学院和朋友。)

QuickTime used to be the DirectShow equivalent. QuickTime曾经是DirectShow的等价物。 Now, CoreMedia and friends have superseded it, with a far more modern and flexible API. 现在,CoreMedia和朋友已经取代它,拥有更加现代化和灵活的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM