Windows 11 Virtual Video Camera

Just a quick hookup of my test Media Foundation media source into new Windows 11 MFCreateVirtualCamera API.

Software video source is presented by Windows 11 as a video capture device. Finally, there is a nice way to create virtual cameras, even though Windows 11 (Windows Build 22000) is a minimal requirement.

Application produced video stream is accepted by both Media Foundation and DirectShow APIs:

Media Foundation API based Windows Camera application showing virtual camera
DirectShow API based GraphStudioNext application showing virtual camera

The new API works throough earlier introduced Frame Server subsystem: the new API pulls video frames from provided Media Foundation media sources and distributes data among the connected applications, the same way things happen with regular driver backed video sources.

  1. Download MediaFoundationVirtualCamera.7z and extract the contents
  2. Run “regsvr32 MediaFoundationVirtualCameraMediaSource.dll” from elevated command line prompt
  3. Run MediaFoundationVirtualCamera.exe
  4. While MediaFoundationVirtualCamera.exe is running, a new camera is registered with the system and is available for the applications

Vivek’s VCam is finally to be phased out, but it will still take some time.

Humanitarian aid in Kharkov, Ukraine

My friend remains in Kharkov, Ukraine, the city experiencing ongoing shelling and destruction.

He is running a team of over 40 volunteers whose daily activity is delivery of food and medication to people throughout the city and villages around. They supply over 2000 people with essentials weekly.

Donations and funds to fuel the support are greatly appreciated, and are directly used for humanitarian aid. Please share the information, and I highly recommend these people to those who seek how to pass help directly to those helping civilians in hotspots.

I leave contact and other details below:

Continue reading →

Suspended (or closed?)

As my city of Kharkov, on the North-East of Ukraine, is attacked by MLRS and artillery, I am not really sure that I would want to continue when the fog of war is gone. Thanks everyone for reading over years!

True media of local events, “open in web” gets you the stream if you don’t use Telegram: Pictures and videos of military damage to civil infrastructure, which is happening right now.

Beyond the Possible

I am replaying a pretty much regular MPEG TS recording taken from air, just with a MPEG TS rollover condition inside.

  1. Microsoft Media Foundation – ? FAIL
  2. Microsoft Movies & TV Application – ? FAIL (obviously because of #1 above, but let me double this down)
  3. Media Player Classic MPC-HC – ? FAIL
  4. VLC – ? FAIL
  5. DirectShow with one commercial MPEG demultiplexer filter – ? FAIL
  6. GStreamer 1.18 – ? FAIL

Oh, come on! Anyone? The recording is absolutely known to be one hundred percent valid!

Sounds like we have a new industry standard.

Microsoft Media Foundation drops sample times at MPEG TS rollover at 30.000s on audio leg, but not on video.

YouTube video contains content… blocked on copyright grounds

Previous post embedded a video clip, hosted by YouTube, with a 37 seconds recording of Microsoft Edge window playing another YouTube clip. The video clearly showed UI part of browser and YouTube web page besides the video. Audio was a re-encoded re-capture of playback audio, however obviously matching algorithm would do a positive here because audio was captured excellently. The clip itself had a link to original content in the description & also linked blog post. Essentially, the 37s fragment of 205s song displayed that capture and recording of a separate window using OS API and tooling produces a decent MP4 file.

Then this happened:

After a manual review, a copyright owner has claimed some material in your video.

As a result, your video has been blocked, and can no longer be played on YouTube.

This is not a copyright strike. This claim does not affect your account status.

Video title: DxgiTakeWindowSnapshot’s WGC & Loopback Audio Recording

So it is a copyright infringement nowadays to show a screen-rip of half a minute trim of playback of 1/6th of music video with clear indication of source and purpose, and MANUAL REVIEWER confirmed that.

But okay, the song is rather good.

DxgiTakeWindowSnapshot & Window Recording w/ Audio

I am sometimes using a rework of earlier DxgiTakeSnapshot application for one specific purpose mentioned below. In addition to Desktop Duplication API, recent version of Windows offer a similar (in sense of acquisition of external video content) API: Windows.Graphics.Capture (hereinafter “WGC”), and the new rework is using this API to capture visual content as a snapshot or, now, as a video stream.

I will skip the technical details and just link Robert Mikhayelyan’s Win32CaptureSample project on GitHub, which is perhaps the best place to ask questions about this new API.

The today’s application takes a snapshot of given monitor, window or process windows (each window separately) similar to original DxgiTakeSnapshot application, and this might be worth a separate post, but at this time I just wanted to mention an quick hack with -Video command line argument.

The hack uses the API along with taking audio currently played and records the audiovisual stream into MP4 file until you stop it with Control+Break.

For example, this way I recorded video below by recording browser window with YouTube playback. I started the app first to quickly identify HWND of interest.

C:\>DxgiTakeWindowSnapshot.exe -Process msedge.exe
DxgiTakeWindowSnapshot.exe 20210717.1-16-g34e6c97 (Release)
HEAD -> video, origin/video
2021-11-20 21:07:46 +0200
Found process 023228 "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
Found 2 windows for process 023228
Trying to capture window 0x0000000000A608E0, Filatov & Karas - ????? ? ?????? (Live @????????? ) - YouTube - Personal - Microsoft??? Edge
Trying to capture window 0x00000000016D066E, Filatov & Karas - Don???t Be So Shy (RuSongTV - Turkey) - YouTube and 3 more pages - Personal - Microsoft??? Edge
Found process 013944 "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
Found 0 windows for process 013944

C:\>DxgiTakeWindowSnapshot.exe -Window 0x0000000000A608E0 -Video
DxgiTakeWindowSnapshot.exe 20210717.1-16-g34e6c97 (Release)
HEAD -> video, origin/video
2021-11-20 21:07:46 +0200
Trying to capture window 0x0000000000A608E0, Filatov & Karas - ????? ? ?????? (Live @????????? ) - YouTube - Personal - Microsoft??? Edge
Stopping: CTRL_C_EVENT

(see next post on why video below is blocked here)

Original content: Filatov & Karas – ????? ? ?????? (Live @????????? )

The application is currently hardcoding produced video as 1920×1080@60 with 10 MBps bitrate, and is subject to certain limitations because of quick and hacky implementation:

  • as mentioned, 1920×1080@60 with 10 MBps video bitrate (& max documented bitrate for stock AAC audio encoder)
  • video might be letterboxed to preserve aspect ratio (default behavior of Media Foundation XVP)
  • compatible Media Foundation video encoder which is expected to be discoverable as default (hardware encoding is used as designed)
  • a pretty much regular audio device expected, certain not so usual settings like 5.1 audio as shared format are likely to cause exceptions
  • the application picks default multimedia audio device for recording (actual code line is auto const Device = DefaultAudioEndpoint(eRender, eMultimedia);)

So that one specific purpose the application is good for is meeting recording: record a window with Google Meet session, Microsoft Teams or alike and you have a convenient copy of content for review or share.

As of now the application is recording only audio playback device, but not the microphone – I will reach this some time later.

If you want something more convenient, there is also Robert’s Simple Screen Recorder in Windows Store, however this will be video only yet with source code on GitHub.

DxgiTakeWindowSnapshot uses Media Foundation in old-school way: it creates a Microsoft Media Foundation Media Session pipeline with a few custom primitives and some stock ones, esp. video encoder, video processor and audio encoder it takes all this stuff off to record media…

Download links