Skip to content

win-mediafoundation: Add Windows Media Foundation Capture Device and Intel NPU AI features#10471

Open
thyintel wants to merge 2 commits into
obsproject:masterfrom
thyintel:obs_intel_ai
Open

win-mediafoundation: Add Windows Media Foundation Capture Device and Intel NPU AI features#10471
thyintel wants to merge 2 commits into
obsproject:masterfrom
thyintel:obs_intel_ai

Conversation

@thyintel

@thyintel thyintel commented Apr 2, 2024

Copy link
Copy Markdown
Contributor

Description

PR is linked with: obsproject/obs-deps#242 (Requires wil headers to build)
Windows 11 is also required for this PR to build and Windows 11 SDK (10.0.22000.0).

This is a draft implementation of Intel AI features using the NPU(=”Intel AI Boost”) on Intel Core Ultra(a.k.a Meteor Lake).
It enables Background Blur(Standard and Portrait), Background Removal, Auto Framing and Eye Contact correction over new Microsoft Effect Package and Media Foundation.
Because this capture device is based on Media Foundation, we created separate “Video Capture Device 2”. We are thinking that it’s better to integrate it into the existing DShow based Video Capture Device in order to not to make end-users confused.
Thus, we need help for (1) overall design guidance how we can integrate - how we can kick off MF based device instead of DShow base, (2) Any missing features to get merged? Because we focus on prototyping new AI features, wondering if we’re missing something on the MF device.
BTW, this feature only works on OEM integrated web-cam, external USB camera is planned to be supported for the future, but not yet supported as of March 2024, no ETA announced.

Screen shots:
GPU 99%, NPU 30% over 3D Mark, w/ AI features are enabled
image

New UI for AI – Background Blur, Removal, Auto Framing, Eye Contact by NPU(=Intel AI Boost)
they only appear on MTL, otherwise this section would be skipped.
image

Motivation and Context

Utilize Intel NPU for OBS and be able to add AI capabilities in OBS for Intel devices.

How Has This Been Tested?

This has been tested on:

  • MTL system containing the Intel NPU
  • ADL system without NPU

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x ] My code has been run through clang-format.
  • [x ] I have read the contributing document.
  • [x ] My code is not on the master branch.
  • [x ] The code has been tested.
  • [x ] All commit messages are properly formatted and commits squashed where appropriate.
  • [x ] I have included updates to all appropriate documentation.

@thyintel thyintel marked this pull request as draft April 2, 2024 21:29
@WizardCM WizardCM added the kind/feature Functionality or other elements that the project doesn't currently have. label Apr 2, 2024
@RytoEX RytoEX self-assigned this Apr 3, 2024
@thyintel thyintel force-pushed the obs_intel_ai branch 3 times, most recently from fc46b24 to 0584cda Compare April 5, 2024 20:49

@RytoEX RytoEX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a more descriptive commit message.

In C++ for variables/functions/identifiers that remain in C++, we prefer camelCase over snake_case.

Is it possible to, at minimum, split this into two commits, or perhaps two PRs:

  1. Add Media Foundation
  2. Add the NPU features

Comment thread plugins/win-mf/CMakeLists.txt Outdated
Comment thread cmake/Modules/FindWIL.cmake Outdated
Comment thread cmake/finders/FindWIL.cmake Outdated
Comment thread plugins/win-mf/cmake/windows/obs-module.rc.in Outdated
Comment thread plugins/win-mf/win-mf.cpp Outdated
Comment thread plugins/win-mf/win-mf.cpp Outdated
Comment thread plugins/win-mf/win-mf.cpp Outdated
Comment thread plugins/win-mf/win-mf.cpp Outdated
Comment thread plugins/win-mf/plugin-macros.h.in Outdated
Comment thread plugins/win-mf/mf-plugin.cpp Outdated
@thyintel thyintel changed the title win-mf: Add win-mf project win-mf: Add Windows Media Foundation Capture Device and Intel NPU AI features Apr 15, 2024
@thyintel thyintel force-pushed the obs_intel_ai branch 6 times, most recently from c8280fd to dcea1bb Compare April 23, 2024 03:06
@RytoEX

RytoEX commented Apr 24, 2024

Copy link
Copy Markdown
Member

plugins/win-mf/data/placeholder.png is only used for the DirectShow-based Virtual Camera. It doesn't seem to have a purpose here?

@RytoEX RytoEX marked this pull request as ready for review May 16, 2024 17:55
@RytoEX

RytoEX commented May 16, 2024

Copy link
Copy Markdown
Member

The deps updated with obsproject/obs-deps#242 was merged, so this is no longer a draft, but it will need to be rebased.

@WizardCM

Copy link
Copy Markdown
Member

So I was able to get this building with current deps, however it does not work on Windows 10. This is due to usage of IMFCameraControlMonitor. I assume this is expected, but I'm noting it for posterity.

10:31:38.979: Module '../../obs-plugins/64bit/win-mf.dll' not loaded

@WizardCM

Copy link
Copy Markdown
Member

I launched this PR on a Windows 11 Insider build, and got a crash when adding the source.

Snippets:

11:04:53.494: Video Capture Device 2 - MF: DecodeDeviceId failed
11:04:53.494: Video Capture Device 2 - MF: Video configuration failed
11:04:53.501: User added source 'Video Capture Device 2 - MF' (MediaFoundationsource_input) to scene 'Scene'
win-mf.dll!PhysicalCamera::GetBlur+0x55
win-mf.dll!PhysicalCamera::GetMepSetting+0x29
win-mf.dll!PhysicalCamera::SaveSettingsToDefault+0x11c
win-mf.dll!PhysicalCamera::Stop+0x2d
win-mf.dll!PhysicalCamera::Uninitialize+0x2d
win-mf.dll!PhysicalCamera::~PhysicalCamera+0x2e
win-mf.dll!PhysicalCamera::Release+0x22
win-mf.dll!MF_Create+0x4f
win-mf.dll!DeviceEnumerator::EnumerateCameraCallback+0xc2
win-mf.dll!MF_EnumerateCameras+0x93
win-mf.dll!DeviceEnumerator::Enumerate+0x7c
win-mf.dll!GetMediaFoundationSourceProperties+0xb2
obs.dll!obs_source_properties+0x8d
obs64.exe!OBSPropertiesView::ReloadProperties+0x81

Full logs (session and crash):

2024-06-16 11-04-39.txt

Crash 2024-06-16 11-04-54.txt

@thyintel

Copy link
Copy Markdown
Contributor Author

I launched this PR on a Windows 11 Insider build, and got a crash when adding the source.

Snippets:

11:04:53.494: Video Capture Device 2 - MF: DecodeDeviceId failed
11:04:53.494: Video Capture Device 2 - MF: Video configuration failed
11:04:53.501: User added source 'Video Capture Device 2 - MF' (MediaFoundationsource_input) to scene 'Scene'
win-mf.dll!PhysicalCamera::GetBlur+0x55
win-mf.dll!PhysicalCamera::GetMepSetting+0x29
win-mf.dll!PhysicalCamera::SaveSettingsToDefault+0x11c
win-mf.dll!PhysicalCamera::Stop+0x2d
win-mf.dll!PhysicalCamera::Uninitialize+0x2d
win-mf.dll!PhysicalCamera::~PhysicalCamera+0x2e
win-mf.dll!PhysicalCamera::Release+0x22
win-mf.dll!MF_Create+0x4f
win-mf.dll!DeviceEnumerator::EnumerateCameraCallback+0xc2
win-mf.dll!MF_EnumerateCameras+0x93
win-mf.dll!DeviceEnumerator::Enumerate+0x7c
win-mf.dll!GetMediaFoundationSourceProperties+0xb2
obs.dll!obs_source_properties+0x8d
obs64.exe!OBSPropertiesView::ReloadProperties+0x81

Full logs (session and crash):

2024-06-16 11-04-39.txt

Crash 2024-06-16 11-04-54.txt

It looks like the Crash logs are from the Windows 10 build, are there any from your attempt at adding the source on Windows 11?

@WizardCM

Copy link
Copy Markdown
Member

@thyintel the crash log is definitely from Windows 11, per the build number 26236 - not sure why it says 10. As I mentioned here, the MediaFoundation source is entirely hidden/disabled on on Windows 10 due to using Windows 11-only APIs.

@RytoEX

RytoEX commented Jul 10, 2024

Copy link
Copy Markdown
Member

This builds and runs on Windows 11 23H2 with the Windows 11 SDK (10.0.22621.0). The "Video Capture Device 2" is available and correctly loads my webcam. However, in Debug configuration, it spams the log with the following:

log spam
source 'Video Capture Device 2' (MediaFoundationsource_input) created
Video Capture Device 2: DecodeDeviceId failed
Video Capture Device 2: Video configuration failed
User added source 'Video Capture Device 2' (MediaFoundationsource_input) to scene 'Scene'
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(1363)\win-mf.dll!00007FFA13A03EB7: (caller: 00007FFA13A04389) ReturnHr(3003) tid(4df8) 80070490 Element not found.
    [PhysicalCamera::GetMepSetting(GetBlur(blur, shallowfocus, mask))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(1401)\win-mf.dll!00007FFA13A043E9: (caller: 00007FFA13A06055) ReturnHr(3004) tid(4df8) 80070490 Element not found.
    [PhysicalCamera::SaveSettingsToDefault(GetMepSetting(setting))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(1363)\win-mf.dll!00007FFA13A03EB7: (caller: 00007FFA13A04389) ReturnHr(3005) tid(3978) 80070490 Element not found.
    [PhysicalCamera::GetMepSetting(GetBlur(blur, shallowfocus, mask))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(1401)\win-mf.dll!00007FFA13A043E9: (caller: 00007FFA13A06055) ReturnHr(3006) tid(3978) 80070490 Element not found.
    [PhysicalCamera::SaveSettingsToDefault(GetMepSetting(setting))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(393)\win-mf.dll!00007FFA13A04567: (caller: 00007FFA13A04CDB) ReturnHr(3007) tid(5490) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(pSample->GetUnknown(MFSampleExtension_CaptureMetadata, IID_PPV_ARGS(&spMetadataAttri)))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(393)\win-mf.dll!00007FFA13A04567: (caller: 00007FFA13A04CDB) ReturnHr(3008) tid(3fcc) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(pSample->GetUnknown(MFSampleExtension_CaptureMetadata, IID_PPV_ARGS(&spMetadataAttri)))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(397)\win-mf.dll!00007FFA13A0462E: (caller: 00007FFA13A04CDB) ReturnHr(3009) tid(5490) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(spMetadataAttri->GetBlobSize( MF_CAPTURE_METADATA_FRAME_BACKGROUND_MASK, &cbBlobSize))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(397)\win-mf.dll!00007FFA13A0462E: (caller: 00007FFA13A04CDB) ReturnHr(3010) tid(3fcc) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(spMetadataAttri->GetBlobSize( MF_CAPTURE_METADATA_FRAME_BACKGROUND_MASK, &cbBlobSize))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(397)\win-mf.dll!00007FFA13A0462E: (caller: 00007FFA13A04CDB) ReturnHr(3011) tid(5490) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(spMetadataAttri->GetBlobSize( MF_CAPTURE_METADATA_FRAME_BACKGROUND_MASK, &cbBlobSize))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(397)\win-mf.dll!00007FFA13A0462E: (caller: 00007FFA13A04CDB) ReturnHr(3012) tid(5994) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(spMetadataAttri->GetBlobSize( MF_CAPTURE_METADATA_FRAME_BACKGROUND_MASK, &cbBlobSize))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(397)\win-mf.dll!00007FFA13A0462E: (caller: 00007FFA13A04CDB) ReturnHr(3013) tid(5490) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(spMetadataAttri->GetBlobSize( MF_CAPTURE_METADATA_FRAME_BACKGROUND_MASK, &cbBlobSize))]
C:\dev\obsproject\obs-studio\plugins\win-mf\libmfcapture\source\PhysicalCamera.cpp(397)\win-mf.dll!00007FFA13A0462E: (caller: 00007FFA13A04CDB) ReturnHr(3014) tid(5994) C00D36E6 The requested attribute was not found.    [PhysicalCamera::FillSegMask(spMetadataAttri->GetBlobSize( MF_CAPTURE_METADATA_FRAME_BACKGROUND_MASK, &cbBlobSize))]

Given the log spam, I wonder if something is not appropriately gated.

Appropriately, since the hardware I'm testing on at the moment does not have an NPU, I do not see the NPU features (background removal, eye gaze correction, etc.). I will re-check on capable hardware at a later time.

Comment thread plugins/win-mf/mf-plugin.cpp Outdated
@WizardCM

Copy link
Copy Markdown
Member

The current implementation of this PR will also need to bump the minimum Windows SDK version to 22621 due to the usage of IMFCameraControlNotify.

if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348)
message(FATAL_ERROR "OBS requires Windows SDK version 10.0.20348.0 or more recent.\n"
"Please download and install the most recent Windows SDK.")

@WizardCM

Copy link
Copy Markdown
Member

Ran the build on a debugger on Windows and confirmed the crash was not due to building on Windows:

image

@thyintel thyintel force-pushed the obs_intel_ai branch 6 times, most recently from e2ca0f8 to 3609748 Compare September 9, 2025 19:29
add_library(win-mf MODULE)
add_library(OBS::mf ALIAS win-mf)

target_sources(win-mf PUBLIC mf-plugin.cpp win-mf.cpp)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be renamed as it will clobber the plugin name used by the MediaFoundation encoder plugin in development as well.

Will reply back once I have guidance for what the correct plugin name/ID and subdirectory should be to get a proper, final, name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use win-mediafoundation-capture for the plugin ID/name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be changed now. Please let me know if any of the file names need to be changed as well.


target_sources(win-mf PUBLIC mf-plugin.cpp win-mf.cpp)

add_library(libmfcapture INTERFACE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is libmfcapture a bona-fide third party library? We do not want to carry around 3rd party libraries as vendored-in source code in our own source code, as this has lead to issues over the years (particularly with the vendored-in code becoming stale, unmaintained, and severely outdated).

If it is a "proper" library, it should be added to obs-deps so it's shipped with our other dependencies and then just pulled in by CMake just like WIL here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on this thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code here is written by Intel.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point here was, "Is libmfcapture available as a third-party library? Can we pull it in from an outside source?" If so, we should pull it in via obs-deps, as we prefer to avoid vendoring dependencies. If it is not available that way, then that might be something to investigate such that the library is not a "bespoke OBS vendored dependency" but rather a "third party library available for other implementations".

@RytoEX RytoEX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place the plugin files into plugins/win-mediafoundation/capture.

@RytoEX RytoEX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit while I notice it: update the commit message prefix to win-mediafoundation to match the paths.

@Fenrirthviti

Copy link
Copy Markdown
Member

As a note, I was testing this last week, and it looks like strings are failing to load for this, at least from the PR artifacts.

@thyintel thyintel changed the title win-mf: Add Windows Media Foundation Capture Device and Intel NPU AI features win-mediafoundation: Add Windows Media Foundation Capture Device and Intel NPU AI features Mar 18, 2026
@thyintel

Copy link
Copy Markdown
Contributor Author

As a note, I was testing this last week, and it looks like strings are failing to load for this, at least from the PR artifacts.

I will try and recreate this issue!

@thyintel thyintel force-pushed the obs_intel_ai branch 2 times, most recently from 7eb6560 to d8c5fe3 Compare March 18, 2026 16:58
@Lordmau5

Lordmau5 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Had a chance to test this as well and found 2 issues with it:

I have an Elgato Facecam Pro, and also their Camera Hub app installed, which in turn installs a virtual camera.
When I add the Video Capture Device source added by this pull request (the Media Foundation one) it auto-selects that one, and shortly after it crashes with the following crash report:
Crash 2026-03-27 22-05-55.txt

This is on the device default resolution option.
If I'm fast enough I can deactivate it and close OBS so it will save the scene and everything, with the source in the deactivated state.
Then, once I open it again, I can switch it to the Custom resolution setting, then selecting 1920x1080, but it still crashes.

The device I actually wanted to test it with is my Capture Card from Elgato (the Elgato 4K X) - It's been suggested to me to give it a try with this to see if that eliminates the random stuttering / frame pacing issues that are happening with the current DirectShow Video Capture Device source in OBS.

A lack of options compared to that source aside (whether intentional or not, such as Hardware Acceleration - not sure how Media Foundation handles that for example), I've noticed color differences.

On the left is the Media Foundation source (from this PR), on the right the DirectShow source (normal video capture device in OBS):
image

Doesn't seem to matter which video format / codec I select (XRGB, I420, NV12, YUY2 or MJPEG - P010 looks much more different, but that's obviously because of it being an HDR format)

(Someone in the OBS Discord brought up the idea that this could be Full vs. Limited color space stuff perhaps?)


Oh and yeah, the localization doesn't work on my end either - I grabbed the Windows x64 artifact from the Checks tab on this PR


Yes, so after a quick test with the DirectShow Video Capture source set to "Color Range: Full" instead of the Default (which for this device it picks Limited) the colors are the exact same.

So it seems like the Media Foundation Video Capture source doesn't automatically detect which Color Range to use and just defaults to Full range (lack of a select dropdown means I can't force it to Limited either)

@RytoEX

RytoEX commented Apr 15, 2026

Copy link
Copy Markdown
Member

I have an Elgato Facecam Pro, and also their Camera Hub app installed, which in turn installs a virtual camera.
When I add the Video Capture Device source added by this pull request (the Media Foundation one) it auto-selects that one, and shortly after it crashes with the following crash report:

@Lordmau5
When you say "it auto-selects that one", do you mean it auto selects the Elgato Facecam Pro or it auto selects the Elgato virtual camera? Trying to track down how to reproduce this crash.

@Fenrirthviti

Copy link
Copy Markdown
Member

As a note here, this does not appear to do any kind of logging of device state, which will be critical for support.

Example of a current DirectShow Device:

11:11:57.218: [DShow Device: 'Video Capture Device'] settings updated: 
11:11:57.218: 	video device: Game Capture 4K60 Pro MK.2
11:11:57.218: 	video path: \\?\pci#ven_12ab&dev_0710&subsys_000e1cfa&rev_00#4&36b65ff1&0&00d8#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{6f814be9-9af6-43cf-9249-c03401000226}
11:11:57.218: 	resolution: 1920x1080
11:11:57.218: 	flip: 0
11:11:57.218: 	fps: 59.94 (interval: 166833)
11:11:57.218: 	format: YV12
11:11:57.218: 	buffering: disabled
11:11:57.218: 	hardware decode: disabled
11:11:57.228: 	using video device audio: no
11:11:57.228: 	separate audio filter
11:11:57.228: 	sample rate: 48000
11:11:57.228: 	channels: 2
11:11:57.228: 	audio type: Capture
11:11:57.230: DShow: Elgato GC4K60ProMK2 tonemapper enable=1

Current Media Foundation device logs nothing of device state.

This is just an example log output, and is not exhaustive of options/configurations that would need to be logged, and some of these are hidden if they are not set (i.e. the audio settings at the bottom are not shown if device audio is being used).

We should try to match the paradigms on the DirectShow source as much as possible.

@RytoEX RytoEX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review.

Comment thread plugins/win-mediafoundation/capture/mf-plugin.cpp Outdated
Comment thread plugins/win-mediafoundation/capture/mf-plugin.cpp
Comment thread cmake/finders/FindWIL.cmake Outdated
Comment thread plugins/win-mediafoundation/capture/cmake/windows/obs-module.rc.in Outdated
Comment on lines +143 to +146
} else if (IsEqualCLSID(controlSet, PROPSETID_VIDCAP_CAMERACONTROL)) {
printf("PROPSETID_VIDCAP_CAMERACONTROL\n");

} else if (IsEqualCLSID(controlSet, KSPROPERTYSETID_ExtendedCameraControl)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (IsEqualCLSID(controlSet, PROPSETID_VIDCAP_CAMERACONTROL)) {
printf("PROPSETID_VIDCAP_CAMERACONTROL\n");
} else if (IsEqualCLSID(controlSet, KSPROPERTYSETID_ExtendedCameraControl)) {
} else if (IsEqualCLSID(controlSet, PROPSETID_VIDCAP_CAMERACONTROL)) {
printf("PROPSETID_VIDCAP_CAMERACONTROL\n");
} else if (IsEqualCLSID(controlSet, KSPROPERTYSETID_ExtendedCameraControl)) {

Comment on lines +69 to +70
#include "mfcapture.hpp"
#include "win-mf.hpp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these to the top of the includes?

Comment on lines +117 to +118
VALUE "InternalName", "win-mf"
VALUE "OriginalFilename", "win-mf"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be re-generated.

@Lordmau5

Lordmau5 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

I have an Elgato Facecam Pro, and also their Camera Hub app installed, which in turn installs a virtual camera.
When I add the Video Capture Device source added by this pull request (the Media Foundation one) it auto-selects that one, and shortly after it crashes with the following crash report:

@Lordmau5 When you say "it auto-selects that one", do you mean it auto selects the Elgato Facecam Pro or it auto selects the Elgato virtual camera? Trying to track down how to reproduce this crash.

@RytoEX
It auto-populates the Virtual Camera, yes - sorry, should've mentioned that

Grabbed the newest artifact, made a portable instance with it, added the source to it and when it popped up with the settings it had the Elgato Virtual Camera auto selected.
After a few seconds it crashed.

New crash log (looks very similar, just different offsets):
Crash 2026-04-15 22-39-41.txt


As before, if I'm fast enough I can switch it to either the Elgato Facecam Pro (not Virtual Camera) or my capture card and it'll work fine.

But as soon as I switch back to the Virtual Camera and wait about 2 seconds it crashes again

@RytoEX

RytoEX commented Apr 17, 2026

Copy link
Copy Markdown
Member

I have an Elgato Facecam Pro, and also their Camera Hub app installed, which in turn installs a virtual camera.
When I add the Video Capture Device source added by this pull request (the Media Foundation one) it auto-selects that one, and shortly after it crashes with the following crash report:

When you say "it auto-selects that one", do you mean it auto selects the Elgato Facecam Pro or it auto selects the Elgato virtual camera? Trying to track down how to reproduce this crash.

It auto-populates the Virtual Camera, yes - sorry, should've mentioned that

Grabbed the newest artifact, made a portable instance with it, added the source to it and when it popped up with the settings it had the Elgato Virtual Camera auto selected. After a few seconds it crashed.

New crash log (looks very similar, just different offsets): Crash 2026-04-15 22-39-41.txt

I can confirm that installing Elgato Camera Hub (currently version 2.2.2) and then selecting the Elgato Virtual Camera in the new "Video Capture Device (Media Foundation)" source, OBS will crash. You do not need to be running Elgato Camera Hub and you do not need to have an Elgato device connected to the system. Loading the Elgato Virtual Camera in the DShow source (Video Capture Device) does not crash.

image

Call stack:

 	vcruntime140d.dll!00007ff866a006dc()	Unknown
>	obs.dll!copy_frame_data_plane(obs_source_frame * dst, const obs_source_frame * src, unsigned int plane, unsigned int lines) Line 3372	C
 	obs.dll!copy_frame_data(obs_source_frame * dst, const obs_source_frame * src) Line 3432	C
 	obs.dll!cache_video(obs_source * source, const obs_source_frame * frame) Line 3560	C
 	obs.dll!obs_source_output_video_internal(obs_source * source, const obs_source_frame * frame) Line 3579	C
 	obs.dll!obs_source_output_video2(obs_source * source, const obs_source_frame2 * frame) Line 3641	C
 	win-mediafoundation-capture.dll!MediaFoundationSourceInput::OnVideoData(void * pData, int Size, __int64 llTimestamp) Line 138	C++
 	win-mediafoundation-capture.dll!MediaFoundationSourceInput::OnVideoDataStatic(void * pData, int Size, __int64 llTimestamp, void * pUserData) Line 162	C++
 	win-mediafoundation-capture.dll!PhysicalCamera::OnReadSample(HRESULT hrStatus, unsigned long dwPhyStrmIndex, unsigned long dwStreamFlags, __int64 llTimestamp, IMFSample * pSample) Line 433	C++
 	[External Code]	

When loading a built-in webcam that works, I get:

dst->linesize[plane] = 2560
lines = 360
dst->linesize[plane] * lines = 2560 * 360 = 921600
(length of data in src->data[plane]) = 921600

When loading the Elgato Virtual Camera, I get:

dst->linesize[plane] = 7680
lines = 1080
dst->linesize[plane] * lines = 7680 * 1080 = 8294400
(length of data in src->data[plane]) = 7626

I've passed this information on to Elgato in case this is an issue with their Virtual Camera rather than an issue with this PR.

Comment on lines +24 to +26
MIT License

Copyright (c) 2025 Microsoft Corporation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the MIT License from Microsoft instead of Intel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is derived from Microsoft's MIT-licensed Media Foundation capture sample, with Intel's additions layered on top. MIT requires retaining Microsoft's copyright notice, so it stays. Intel's contributions are GPLv2-or-later.

Comment on lines +3 to +11
This is provided under a dual MIT/GPLv2 license. When using or
redistributing this, you may do so under either license.

GPL LICENSE SUMMARY

Copyright(c) 2025 Intel Corporation.

This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Intel is the sole author of this file, GPLv2+ would be preferable to GPLv2-only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated Intel's GPL grant to "version 2 or, at your option, any later version." Intel isn't the sole author, but the only non-Intel code is Microsoft's MIT sample, which is compatible with GPLv2+.

/*

This is provided under a dual MIT/BSD/GPLv2 license. When using or
redistributing this, you may do so under either license.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If licensed under three licenses, probably should not say "dual".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right — three blocks shouldn't be called "dual." The BSD option isn't needed for this plugin, so I've removed the BSD block entirely. This should be fixed now.

Comment on lines +3 to +12
This is provided under a dual MIT/BSD/GPLv2 license. When using or
redistributing this, you may do so under either license.

GPL LICENSE SUMMARY

Copyright(c) 2025 Intel Corporation.

This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Intel is the sole author of this file, GPLv2+ would be preferable to GPLv2-only.

Comment thread plugins/win-mediafoundation/capture/libmfcapture/win-mf.hpp Outdated
Comment thread plugins/win-mediafoundation/capture/libmfcapture/win-mf.hpp Outdated

target_sources(win-mf PUBLIC mf-plugin.cpp win-mf.cpp)

add_library(libmfcapture INTERFACE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point here was, "Is libmfcapture available as a third-party library? Can we pull it in from an outside source?" If so, we should pull it in via obs-deps, as we prefer to avoid vendoring dependencies. If it is not available that way, then that might be something to investigate such that the library is not a "bespoke OBS vendored dependency" but rather a "third party library available for other implementations".

@Warchamp7 Warchamp7 added this to the OBS Studio 32.2 milestone May 6, 2026
@RytoEX

RytoEX commented Jun 4, 2026

Copy link
Copy Markdown
Member

Pushed a rebase which will fail. Will fix build failures after.

@RytoEX

RytoEX commented Jun 4, 2026

Copy link
Copy Markdown
Member

Rebased.
Correctly merged the string fixes back to the originating commits of the strings.
Fixed the use of the deprecated obs_properties_add_button() by using obs_properties_add_button2().
Fixed the clang-format failure.

Logging still needs to be addressed to be equivalent to the existing DirectShow implementation.
Outstanding feedback still needs to be addressed.

Comment on lines +10 to +12
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License, or (at your opinion) any later version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap text at 80 characters. There should be an example license available for the correct text wrapping.

Comment on lines +11 to +12
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License, or (at your opinion) any later version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Wrap at 80 characters (verify against the example license).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Functionality or other elements that the project doesn't currently have. Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants