c# - MediaFoundation 找不到视频捕获仿真器驱动程序。但 DirectShow 确实

标签 c# winapi video directshow ms-media-foundation

我们正在开发一种软​​件,我们可以在其中预览和记录从视频采集卡采集的输入视频源。预览是用DirectShow实现的,录制是用Media Foundation实现的(老软件慢慢升级到MediaFoundation)

问题出在 MediaFoundation:它似乎在我们的发布机器上正确找到了视频捕获卡,但没有找到我们在测试机器上使用的“屏幕捕获”视频模拟器。 另一方面,DirectShow 代码可以正确找到视频捕捉设备和屏幕捕捉设备模拟器。

那么,为什么 MediaFoundation 找不到模拟器驱动程序?

注意:模拟器是在DirectShow中制作的...它是VHScrCap

这是 MediaFoundation 代码:

HRESULT DeviceList::EnumerateVideoDevices(){
HRESULT hr = S_OK;
IMFAttributes *pAttributes = NULL;

ClearVideo();

// Initialize an attribute store. We will use this to 
// specify the enumeration parameters.

hr = MFCreateAttributes(&pAttributes, 1);

// Ask for source type = video capture devices
if (SUCCEEDED(hr))
{
    hr = pAttributes->SetGUID(
        MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, 
        MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
        );
}

// Enumerate devices.
if (SUCCEEDED(hr))
{
    hr = MFEnumDeviceSources(pAttributes, &m_ppVideoDevices, &m_cVideoDevices);
}

SafeRelease(&pAttributes);

return hr;

hr = MFEnumDeviceSources(pAttributes, &m_ppVideoDevices, &m_cVideoDevices); 处未找到任何设备。

谢谢!

最佳答案

媒体基金会不应该选择所谓的“虚拟”DirectShow 视频源。 DirectShow 通过视频输入类别提供视频源,其中包括由 WDM 驱动程序设备支持的过滤器,然后是注册到该类别的任何其他过滤器。 Media Foundation 有自己的适配器来公开 WDM 捕获设备,但 DirectShow 过滤器在那里是不可见的。基本上,您需要一个单独的 Media Foundation 模拟器。

From MSDN :

Starting in Windows 7, Media Foundation automatically supports audio and video capture devices. For video, the device must provide a kernel streaming (KS) minidriver in the video capture category. Media Foundation uses the PnP path to enumerate the device. For audio, Media Foundation uses the Windows Multimedia Device (MMDevice) API to enumerate audio endpoint devices. If the device meets these criteria, there is no need to implement a custom media source.

However, you might want to implement a custom media source for some other type of device or other live data source. There are only a few differences between a live source and other media sources:

关于c# - MediaFoundation 找不到视频捕获仿真器驱动程序。但 DirectShow 确实,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24612174/

相关文章:

c# - 如何在 Xmarin.Android 应用程序中使用 Flurry Analytics (.jar)?

c# - 如何在 Powerdesigner 中创建可以为不同数据库生成创建脚本的模型?

http - 如何检测 Windows 中的防火墙?

Html5 视频叠加架构

html - 如何在视频标签中播放 AVI 文件?

C# Linq 分组

c# - 在没有try catch的情况下检查文件是否正在使用?

c++ - 窗口 Hook 问题

c - 文件作为 Win32 应用程序的参数

c++ - 存储视频数据的最有效方式