捕获每个 WPF MediaElement 帧
有没有办法捕获每个 WPF MediaElement 帧?就像在每个渲染帧触发并允许我访问它的事件一样。如果 MediaElement 不提供此类功能,如何实现或我可以使用其他哪些控件?顺便说一句,是否有这样的控件或方法可以允许通过帧捕获进行离屏快速渲染媒体剪辑? (这样我就可以尽快处理帧)
Is there a way to capture each WPF MediaElement frame? Like an event that fires at each rendered frame and allows me to access it. If MediaElement does not provide such functionality, how could it be implemented or what other control could I use? On a side note, is there such a control or method that would allow for off-screen fast rendering of media clips with frame capture? (so I could process frames as fast as possible)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试我的 WPF MediaKit 项目。允许您使用 Media 在 WPF 中执行几乎所有操作。尝试一下 MediaDetector.cs,它允许您从媒体中的任何时间提取帧。它有点问题,因为我从来没有花很多时间在上面,但应该可以满足你的需要。
Try out my WPF MediaKit project. Allows you to do pretty much anything in WPF with Media. Try out the MediaDetector.cs, it allows you to extract out frames from any time in the media. It's a little buggy as I've never put a lot of time in it, but should work for what you need.
没有内置的WPF方式:
我能够使用 DirectShow 从 .mpg、.wmv、.mov、.flv、.avi 和其他电影格式获取帧图像。我使用 DirectShow 的 COM 图形生成器接口构建了一个过滤器图形。生成的过滤器图对影片进行了解码,并将其连接到用 C# 编写的自定义渲染器过滤器。我的自定义过滤器接收帧数据并将其转换为 BitmapSource 对象以使用 BitmapSource.Create 进行显示。
DirectShow 解决方案表现得相当好,托管到非托管的转换没什么大不了的,但花了一段时间才弄清楚 DirectShow 图形构建的细节。
There is no built-in WPF way:
I was able to get frame images from .mpg, .wmv, .mov, .flv, .avi and other movie formats using DirectShow. I constructed a filter graph using DirectShow's COM graph builder interfaces. The resulting filter graph decoded the movie and connected it to a custom renderer filter written in C#. My custom filter received the frame data and converted it into BitmapSource objects for display using BitmapSource.Create.
The DirectShow solution performed quite well, and the managed to unmanaged transition was no big deal, but it took a while to figure out the details of the DirectShow graph building.
如果你发挥你的想象力,也许这个片段可以给你一些想法:
If you use your imagination perhaps this snippet can give you some ideas:
您可以尝试此方法来输出任何 UI 元素,包括 WPF 中的 MediaElement
you can try this method to output any UI Element including the MediaElement in WPF