C# 从 wmv 文件中抓取帧
有谁知道是否可以使用 C# 从位置 X 上的视频 (.wmv) 中获取帧/图像,而无需安装 DirectX 并在 Windows 2008(我想尽可能少安装的网络服务器)上工作。
或者甚至使用 directx 的简单解决方案也可能很好。
亨克
Does anyone know if it is possible to grab a frame/image from a video (.wmv) on position X using C# without installing DirectX and working on Windows 2008 (a webserver I would like to install as less as possible).
Or even a simple solution with directx could be nice.
Henk
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您实际上需要研究的是 DirectShow,通用媒体(音频和视频)视频)Windows 库。 它曾经是 DirectX 的一部分,但几年前它分支并成为 Windows(平台)SDK 的一部分。 我还应该在这里指出,自 Windows Vista 以来,它现已被弃用,取而代之的是媒体基金会。 所知,这是一个更好的库(DirectShow 对于复杂的任务来说是地狱),但不幸的是,由于缺乏对 XP 和更早版本的支持,目前仅针对 Media Foundation 并不可行......
据我 真正可以做的是指向 DirectShow.NET,DirectShow 的 .NET 包装库,它相当稳定并且目前经过充分测试。 它包含各种示例,可以帮助您入门,但它绝不是一个简单的解决方案。 另外,我强烈建议您查看这篇 CodeProject 文章/示例应用程序。 它处理网络摄像头视频捕获和文件(包括 WMV)视频播放。 稍微尝试一下,并学习如何进行帧搜索/单帧捕获(我认为该项目可能甚至可以使用一些代码来做到这一点)应该可以满足您的需求。 也许您甚至可以在该 CodeProject 应用程序的 DirectShow.NET 示例中的某个位置找到精确的解决方案。
当然,如果可以的话,我会在这里建议一个更简单的解决方案,但目前您仍然受制于 DirectShow 的可怕之处。 无论如何,祝你好运!
What you'll actually need to look into is DirectShow, the general-purpose media (both audio and video) library for Windows. It used to be part of DirectX but several years ago it branched off and became part of the Windows (Platform) SDK. I should also point out here that it's now been deprecated since Windows Vista in favour of Media Foundation. From what I've read it's a much better library (DirectShow is hell for complex tasks), but unfortunately it's not really feasible to only target Media Foundation at the moment because of the lack of support for XP and earlier...
The best I can really do is point you to DirectShow.NET, a .NET wrapper library for DirectShow, which is rather stable and well tested at the moment. It includes various samples which should help you get going, but by no means will it be a straightforward solution. Also, I strongly recommend you take a look at this CodeProject article/sample application. It deals with both webcam video capture and video playback from files (including WMV). A bit of playing around with that, and learning how to do frame seeking/single frame capture (I think that project might even some code to do that) should get you what you need. Perhaps you'll even find the precise solution somewhere within the DirectShow.NET samples of that CodeProject app.
Of course, I would suggest an easier solution if I could here, but you're pretty much stuck with the horribleness that is DirectShow for the moment. Good luck anyway!
您应该尝试 FFmpeg。
You should try FFmpeg.
看一下 Windows Media Format SDK,它旨在让您可以直接访问 WMV (/WMA/ASF) 文件内的帧。
http://msdn.microsoft.com/en-us /library/dd757738(VS.85).aspx
特别是,您对用于读取这些文件的同步 API 感兴趣(IWMSyncReader 是接口名称)。 WMFSDK 中有一些相当不错的示例; 我相信这里对您来说最有趣的是 WMSyncReader,它将向您展示如何挖掘 WMV 文件并从位置 X 开始获取帧。
Take a look at the Windows Media Format SDK, which is designed to give you pretty direct access to the frames inside a WMV (/WMA/ASF) file.
http://msdn.microsoft.com/en-us/library/dd757738(VS.85).aspx
In particular, you're interested in the synchronous API for reading these files (IWMSyncReader is the interface name). There are some pretty decent samples in the WMFSDK; I believe the most interesting one for you here will be WMSyncReader, which will show you how to dig through a WMV file and get frames, starting at position X.