How to create virtual webcam in Windows 10?
Asked Answered
F

3

39

I would like to take video from a webcam, render some text on the frames and do some motion tracking and pass it on to a virtual webcam so it can be streamed easily.

I found some answers on stackoverflow suggesting that I should use DirectShow. According to information in DirectShow documentation, the DirectShow SDK is part of Windows SDK. So I installed the latest Windows SDK but it seems that it doesn't include DirectShow because there are no DirectShow samples under C:\Program Files (x86)\Microsoft SDKs\Windows. (The stackoverflow answers are also pretty old - dated around 2010)

Can you suggest a way to make DirectShow work (including samples working on Visual Studio 2015) or some other alternative to DirectShow, that would help me create a virtual webcam?

Fieldfare answered 13/11, 2015 at 12:49 Comment(6)
Get samples from Windows SDK 7.x; build with latest Visual Studio. There is no standard virtual camera sample, you are to google Vivek's VCam.Thundery
I downloaded Windows SDK for Windows 7. When I launched the installer and I got this warning message: imgur.com/AhYhhlR (saying that I have pre-release of .NET Framework 4 and some components won't be installed and that I should install .NET Framework 4 from provided link). I proceeded anyway but after installation the samples where not in the destination directory. When I tried to install .NET Framework 4, the installer refused to install it, stating that I already have .NET Framework installed. I guess Windows 10 isn't designed to support such an old SDK.Deimos
You can install it on an older windows version and copy the files to windows 10.Spruce
DirectShow is no longer supported. I think it has been deprecated in Vista. It has been replaced by Media Foundation You can have a look at Media Foundation Capture Source You should be able to find some information from here msdn.microsoft.com/en-us/library/windows/desktop/…Izard
DirectShow was not actively developed for 15 years. It is not [yet] deprecated, and it is definitely supported, an example of which is AVI support bug in Windows 10 DirectShow, which Microsoft recently fixed and delivered the fix via Windows Update.Thundery
@LukášNeoproud, are you able to build the VC using the below answer?Seiden
T
28

Virtual webcam is typically a software only implementation that application discover as if it is a device with physical representation. The mentioned applications use APIs to work with web cameras and ability to extend the APIs and add your own video source is the way to create a virtual web camera.

In Windows there are a few APIs to consume video sources: Video for Windows, DirectShow, Media Foundation (in chronological order).

Video for Windows is not really extensible and limited in capabilities overall. It will see a virtual device if you provide a kernel mode driver for a virtual camera.

DirectShow is the API used by most video capture enabled Windows applications and it is present in all Windows versions including Windows 10 (except just Windows RT). Then it's perfectly extensible and in most cases the term "virtual webcam" refers to DirectShow virtual webcam. Methods to create DirectShow virtual webcam discussed in many StackOverflow questions remain perfectly valid for Windows 10, for applications that implement video capture using DirectShow:

DirectShow samples were removed from Windows SDK but you can still find them in older releases:

If you provide a kernel mode driver for video camera device (your virtual webcam through custom kernel driver), DirectShow would also see it just like other video APIs.

Media Foundation is a supposed successor of DirectShow but its video capture capabilities in the part of extensibility simply do not exist1. Microsoft decided to not allow custom video sources application would be able to discover the same way as web cameras. Due to Media Foundation complexity, and overhead and overall unfriendliness it is used by modest amount of applications. To implement a virtual webcam for Media Foundation application you again, like in case of Video for Windows, have to implement a kernel mode driver.


1 Starting with Windows Build 22000 (Windows 11), there is new API MFCreateVirtualCamera which offers virtual camera creation. A developer can implement a video source which the API connects to so called Windows Camera Frame Server service, which in turn distributes the generated video as a source along with regular cameras. Applications see this software implementation the same way as if it was, for example, a webcam.

Thundery answered 11/3, 2016 at 8:41 Comment(4)
Can you please write a sample C, C++ open source github so that all windows struggler community can follow your code and contribute?Buroker
@YumYumYum: the original VCam sample is where it was hosted all the years through: tmhare.mvps.org/downloads.htm There have been developed multiple derivatives and similar filters over time, of course, too.Thundery
Link in your comment is broken.Immix
@TimMB: See alax.info/blog/2161 + github.com/roman380/tmhare.mvps.org-vcamThundery
A
5

This is an ancient question internet-wise but I thought I could contribute:

I was looking into this about a year ago and almost abandoned my project altogether until I found Microsoft's SimpleMediaSource driver sample on their Github. It is documented here but it is a tough read if you haven't written drivers before - which was the case for me. Fortunately, documentation seems to have been updated and improved since I used it.

To get it working, I had to manually delete and copy-paste the DLL into C:\System32 after each compilation with Visual Studio. I also had to side-download and install the now removed (from what I can tell) devcon utility to add & remove drivers with devcon dp_add/dp_remove commands. You also need the Windows Driver Kit (WDK).

You need to enable unsigned driver loading within Windows so it may not be a great route if you want to distribute it. Anticheat and DRM software may also not appreciate it :)

There are two projects being compiled:

MediaSource - COM DLL project for the custom media source

SimpleMediaSourceDriver - UMDF driver install package

Amati answered 26/10, 2021 at 0:17 Comment(0)
F
2

Just install obs studio

In newer versions it automatiaclly installs an easy to use virtual webcam that mirrors the OBS scene.

Fructiferous answered 31/3, 2022 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.