Windows 上用于视频捕获的 DirectShow 的替代方案
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/542693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Alternatives to DirectShow for video capture on Windows
提问by bsruth
I am looking at updating a program that currently uses DirectShow for video capture. While DirectShow seems to work well, I was wondering if there were any more powerful or up to date SDKs or APIs that I should look into. Some features that would be helpful would be ones that will:
我正在考虑更新当前使用 DirectShow 进行视频捕获的程序。虽然 DirectShow 似乎运行良好,但我想知道是否有任何更强大或最新的 SDK 或 API 值得我研究。一些有用的功能将是:
- Provide a consistent framerate (33ms between frames for NTSC) during capture.
- Work with DirectShow compatible capture devices.
- Not require an extra license to be installed on the customer's PC.
- Allow for simultaneous preview and hardware encoding of video.
- Be able to be integrated into a C++/MFC application.
- 在捕获期间提供一致的帧速率(NTSC 的帧之间为 33 毫秒)。
- 使用兼容 DirectShow 的捕获设备。
- 不需要在客户的 PC 上安装额外的许可证。
- 允许同时进行视频预览和硬件编码。
- 能够集成到 C++/MFC 应用程序中。
I've looked into LeadTools Multimedia Capture SDKand VisioForge Capture SDKand Microsoft Media Foundation, but just wanted to know what others have used successfully before I invest time or money into one of these alternatives. I don't care if this is a commercial or open source product.
我已经研究过LeadTools Multimedia Capture SDK和VisioForge Capture SDK以及Microsoft Media Foundation,但只是想在我将时间或金钱投入这些替代方案之一之前,了解其他人成功使用了什么。我不在乎这是商业产品还是开源产品。
EDIT: While I appreciate the attempts to solve my particular problem, this question was supposed to be about alternatives to DirectShow. So, I removed all of the references to my specific problem. Solving that will need to wait for another question.
编辑:虽然我很欣赏解决我的特定问题的尝试,但这个问题应该是关于 DirectShow 的替代方案。因此,我删除了对我的特定问题的所有引用。解决这个问题需要等待另一个问题。
回答by Quassnoi
Quite all capture boards come with their own timers.
几乎所有的捕获板都有自己的计时器。
You may try to query you source filter for IReferenceClock
and use its own timer that is usually more accurate than a PC's one.
您可以尝试查询源过滤器IReferenceClock
并使用它自己的计时器,该计时器通常比 PC 的计时器更准确。
If you use ISampleGrabber
then the callback function is called microsecondsfrom the moment Receive
is called on the Sample Grabber's input pin, they're just few lines away in the source code.
如果您使用ISampleGrabber
,则从在Sample Grabber 的输入引脚上调用的那一刻起,回调函数将被称为微秒Receive
,它们在源代码中只有几行。
It seems that your frame source timing is inaccurate (not the timing set in IMediaSample
, but actial timing the frames are delivered in).
看来您的帧源计时不准确(不是 中设置的计时IMediaSample
,而是传送帧的实际计时)。
What is the source filter that produces the frames?
生成帧的源过滤器是什么?
回答by Quassnoi
The DirectShow API is very good, I've never found better on the windows platform. DirectShow has been superseded by Media Foundation, which is Vista (and later) operating systems only.
DirectShow API 非常好,我从来没有在 windows 平台上找到更好的。DirectShow 已被Media Foundation取代,后者仅适用于 Vista(及更高版本)操作系统。
We'll have to wait for XP to die before people will start mass development using Media Foundation...
在人们开始使用 Media Foundation 进行大规模开发之前,我们将不得不等待 XP 消亡……
May I ask why you're seeking an alternative to DirectShow - it's a very well supported API - well documented on MSDN and there's a very active and friendly forumon MSDN for DirectShow Development.
我可以问你为什么要寻找 DirectShow 的替代品 - 它是一个非常受支持的 API - 在 MSDN 上有很好的记录,并且在 MSDN 上有一个非常活跃和友好的论坛,用于 DirectShow 开发。
回答by CPlusSharp
LeadTools and VisioForge SDKs are just wrappers for DirectShow + some custom filters from them! There is no real alternativ to DirectShow for capturing on a Windows PC. Maybe on Win8 with MediaFoundation? Some Hardware Vendors have there own capture programms, but most of them just use DirectShow.
LeadTools 和 VisioForge SDK 只是 DirectShow 的包装器 + 一些来自它们的自定义过滤器!在 Windows PC 上捕获 DirectShow 没有真正的替代品。也许在带有 MediaFoundation 的 Win8 上?一些硬件供应商有自己的捕获程序,但大多数只使用 DirectShow。
I think your problem is not DirectShow. How long is your callback working? Because if your doing some analysis on the image, then you need to do this fast. Not the time in your callback is importent, but the presentation time in the mediasample you get! This should be +33ms from the previews sample.
我认为你的问题不是 DirectShow。您的回调工作多长时间?因为如果您对图像进行一些分析,那么您需要快速执行此操作。重要的不是回调中的时间,而是您获得的 mediasample 中的呈现时间!这应该是预览示例中的 +33 毫秒。
回答by rogerdpack
FFmpeg can receive directshow input and manipulate it, and it's free. AviSynth maybe too...
FFmpeg 可以接收 directshow 输入并对其进行操作,而且它是免费的。AviSynth 可能也是...
回答by Chris Holmes
VideoLan may be an option for you.
VideoLan 可能是您的一个选择。
回答by jheriko
The problem might just be the method you are using for timing. Are you using the high performance timer API?
问题可能只是您用于计时的方法。您在使用高性能计时器 API吗?