简体   繁体   English

C# 从 wmv 文件中抓取框架

[英]C# Grab frame from wmv file

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).有谁知道是否可以使用 C# 从 position X 上的视频 (.wmv) 中获取帧/图像,而无需安装 DirectX 并在 Windows 上工作,尽可能少地安装 2008 网络服务器。

Or even a simple solution with directx could be nice.甚至使用 directx 的简单解决方案也可以。

Henk亨克

What you'll actually need to look into is DirectShow , the general-purpose media (both audio and video) library for Windows.您实际上需要研究的是DirectShow ,它是 Windows 的通用媒体(音频和视频)库。 It used to be part of DirectX but several years ago it branched off and became part of the Windows (Platform) SDK.它曾经是 DirectX 的一部分,但几年前它分支并成为 Windows(平台)SDK 的一部分。 I should also point out here that it's now been deprecated since Windows Vista in favour of Media Foundation .我还应该在这里指出,自 Windows Vista 支持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...从我读过的内容来看,它是一个更好的库(DirectShow 对于复杂的任务来说是地狱),但不幸的是,由于缺乏对 XP 和更早版本的支持,目前仅针对 Media Foundation 并不可行......

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.我能做的最好的事情就是将您指向DirectShow.NET ,它是 DirectShow 的 .NET 包装库,目前相当稳定且经过良好测试。 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.另外,我强烈建议您查看此 CodeProject 文章/示例应用程序。 It deals with both webcam video capture and video playback from files (including WMV).它处理网络摄像头视频捕获和文件(包括 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.也许您甚至会在该 CodeProject 应用程序的 DirectShow.NET 示例中的某处找到精确的解决方案。

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.当然,如果可以的话,我会建议一个更简单的解决方案,但你现在几乎被 DirectShow 的可怕所困扰。 Good luck anyway!总之祝你好运!

You should try FFmpeg .您应该尝试FFmpeg

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.查看 Windows 媒体格式 SDK,它旨在让您直接访问 WMV (/WMA/ASF) 文件中的帧。

http://msdn.microsoft.com/en-us/library/dd757738(VS.85).aspx 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).特别是,您对用于读取这些文件的同步 API 感兴趣(IWMSyncReader 是接口名称)。 There are some pretty decent samples in the WMFSDK; 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.我相信对您来说最有趣的将是 WMSyncReader,它将向您展示如何从 position X 开始挖掘 WMV 文件并获取帧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM