使用 Media Foundation & 捕获问题C++ 中的 Windows 8 [英] Problems capturing with Media Foundation & Windows 8 in C++

查看:34
本文介绍了使用 Media Foundation & 捕获问题C++ 中的 Windows 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将是我在 StackOverflow 中寻找解释几天后的第一个问题.请对我的提问保持温和,因为我知道我的问题有点奇怪,因为它是一个普遍的问题.

This is going to be my first question in StackOverflow after several days looking for an explanation. Please, be gentle with me for asking because I know my problem is a bit bizarre to be a general problem.

我基于 Microsoft 示例CaptureToFile"制作了一个 MF 捕获视频应用程序.它确实适用于 Windows 7 x64.我升级到 Visual Studio 2013 没有问题.当我尝试将所有开发工作放在 Windows 8.1 x64 机器上时出现了问题.

I made a MF capture video application, based in the Microsoft example 'CaptureToFile'. It did work on Windows 7 x64. I upgraded to Visual Studio 2013 without problems. Problems arose when I try to put all the development on a Windows 8.1 x64 machine.

应用程序编译和执行没有错误,但无法在异步模式下使用 m_pReader->ReadSample() 捕获样本;只有前两个样本到达 OnReadSample 方法;并且必须有控制"样本,因为 IMFSample 在所有样本中都是空的.之后,应用程序会挂起"等待数据.

The app compiles and executes without error, but it's UNABLE to capture samples by using m_pReader->ReadSample() in asynchronous mode; only the first two samples arrive to OnReadSample method; and there must be 'control' samples, because the IMFSample is null in all of them. After that, the app gets 'hanged' waiting for data.

我已经尝试过原始的 MFCaptureToFile 具有相同结果的示例.

I've tried the original MFCaptureToFile sample with the same sad results.

当然,我觉得软硬件都差不多(同款采集卡同款驱动,都是台式机……)

Of course, I think hardware and software are similar (the same capture card with the same driver version, both are desktop PC...)

您知道这种行为的任何可能原因吗?在 Win7 中一切正常!或者至少,如果你能告诉我一些寻找正在发生的事情的新途径

Do you know any possible reason for this behaviour? in Win7 everything is working flawless! Or at least, if you could light me a bit about new paths for finding what's happening

提前致谢

更新:游戏中还有另一个玩家".查看线程,我看到一个工作线程位于实时工作队列容器RTWorkQ.dll"中,仅适用于 Windows 8.我将继续调查.同时,如果您有任何想法、可以分享的内容,我会很高兴听到您的消息.

UPDATE: There is another 'player' in the game. Looking into the threads, I see that a worker thread is in 'RTWorkQ.dll', the real-time work queue container, specific only for Windows 8. I will go on investigating. In the meantime, if you have any idea, something to share, I'll be glad to hear you.

更新 2:我修改了示例 MFCaptureToFile 以同步获取视频示例,因为我认为问题可能是由于异步行为;与队列有关.我不得不说,即使进行了这种更改,问题仍然存在.第二次尝试读取样本时,应用程序会挂起"等待并非永远不会到达的读数.

UPDATE 2: I've modified the sample MFCaptureToFile to get the video samples synchronously, because I thought the problem could be due to the asynchronous behaviour; related with the queues. I've to say that the problem persist even with this change. The second time it tries to read a sample, the application gets 'hanged' waiting for a reading that doesn't never arrives.

更新 3:我已尝试使用 CaptureEngine使用另一种 MF 方式捕获视频 (MFCaptureEngine) 的示例应用程序.它可以完美地构建和运行,但在开始预览"时不显示任何图像,并且不记录任何有用的、仅不可播放的文件.

UPDATE 3: I've tried with the CaptureEngine sample application that uses another MF way to capture video (MFCaptureEngine). It builds and runs flawlessly but doesn't show any images when starting the 'preview' and doesn't record any useful, only non-playable files.

更新 4:我已经在 Windows 8 PRO 中安装了 Visual Studio 2010 Ultimate.示例中的示例 MFCaptureToFile 再次失败.无法从图像采集卡读取第二个样本.我开始认为这可能是捕获卡 (Datapath VisionRGB-E1S) 和 Windows 8 PRO 之间的不兼容,尽管驱动程序确保它在这个平台上工作正常并且测试程序显示图像.明天我将尝试使用外部 USB 网络摄像头进行测试.

UPDATE 4: I've installed Visual Studio 2010 Ultimate in Windows 8 PRO. The sample MFCaptureToFile fails again in the sample. It's unable to read a 2nd sample from the frame grabber. I'm starting to think that can be an incompatibility between the capture card (Datapath VisionRGB-E1S) and Windows 8 PRO despite the driver assures it works fine in this platform and the test program shows images. Tomorrow I'm going to try the test with an external USB webcam.

推荐答案

终于找到这个问题的原因了.

Finally, I have figured out the reason of this problem.

随着 Windows 8.1 的发布,微软引入了 Windows 8.1 的新 AVStream 接口KS_FRAME_INFO 结构 - 新的 FrameCompletionNumber 成员.

With Windows 8.1 release Microsoft has introduced New AVStream Interfaces for Windows 8.1 There is a small but very important change in KS_FRAME_INFO structure - the new FrameCompletionNumber member.

已完成队列中帧的识别序列号.此编号用于验证正确的帧顺序.当这个值是0,帧被取消.此成员可用从视窗 8.1.

An identifying sequence number for the frame in the completed queue. This number is used to verify proper frame order. When this value is 0, the frame was cancelled. This member is available starting with Windows 8.1.

DirectShow 不关心这个数字.媒体基金会关心.

DirectShow doesn't care about this number. And MediaFoundation cares.

因此,您不能仅在用户模式方面解决该问题.制造商必须发布更新.顺便说一句,我有两个网络摄像头 - Logitech C270 和 Creative Live Socialize HD.Logitech 支持 Metro,而 Creative 不支持.

So, you cannot just fix that on your user-mode side. The manufacture developers must release an update. Btw, I have two webcams - Logitech C270 and Creative Live Socialize HD. Logitech supports Metro while Creative does not.

我只用几行代码就成功更新了我的驱动程序(以正确设置 FrameCompletionNumber).

I have successfully updated my driver with only a few lines of code (to set up FrameCompletionNumber properly).

更新.类似线程 http://www.osronline.com/showthread.cfm?link=255004

这篇关于使用 Media Foundation & 捕获问题C++ 中的 Windows 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆