Writing a virtual webcam?
Asked Answered
A

2

21

I need to create a virtual webcam that poses as a webcam, but takes as input a set of images that it plays. I have seen solutions like ManyCam, and Fake Webcam, but they all seem to one limitation or the other (resolution, max file size, fps etc.) I am working on Windows XP SP3.

I understand that I have to write a WIA interface for this task, but being a Python programmer, I have never written drivers or interfaces to devices. What are the main tasks in writing this interface ? What would the flow look like ?

Accessible answered 5/6, 2011 at 15:37 Comment(4)
unrelated advice: "don't say that you are a Python programmer", you're a programmer that prefers (or only knows) Python... yet.Cistern
May be s/he's a core developer of cpython... :-)Summon
@Cistern great advice ! though it may be more of a cultural thing. @Summon just thinking about that made me go crazy. if I were a developer of cpython, wouldn't I be a C programmer? or I could be a python programmer because I program pythonAccessible
See also #4215286Mam
A
27

You need to write DirectShow filter which is a COM server that implements an IPin, IAMStreamConfig and IKsPropertySet interfaces. For the IPin part you'd better to start by inheriting the CSourceStream class, for that you need to get the Windows SDK, having the SDK installed there would be a DirectShow Base Classes sources in samples\multimedia\directshow folder, there you'll find the CSourceStream (among many others). DllRegisterServer function of the COM server should register your filter within CLSID_VideoInputDeviceCategory category using filter mapper.

After building the COM-server, you register it with regsvr32 tool, and your virtual webcam should appear in the web cam lists.

Also check the samples\multimedia\directshow\filters\ball sample that can be improved and used as a starting point for your task.

Anis answered 5/6, 2011 at 16:53 Comment(3)
Thanks you very much for detailing the flow. I will look at the samples and learn. Thanks again :)Accessible
@Anis please help in #65839949Surrender
Thanks @n0rd. I know this question/answer is old, but would you have a minimal example of such code? Ideally it would be a single .c or .cpp file :) PS: does the solution you describe create a virtual webcam, that can be used as a webcam in the browser?Diversified
S
1

Read this first
https://learn.microsoft.com/en-us/windows/win32/directshow/writing-source-filters

Then you can adopt
https://github.com/roman380/tmhare.mvps.org-vcam

You can work on top of this sample virtual camera.

This implements IAMStreamConfig and IKsPropertySet interfaces
This is built using CSourceStream and CSource class which implements IPin and IBaseFilter

Surrender answered 23/1, 2021 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.