WPF 中的视频缩略图
我正在尝试将视频添加到我的 WPF 项目中,但我找不到生成视频预览/缩略图的正确解决方案。互联网上的很多解决方案都提到您应该在代码后面播放然后暂停视频。我不太喜欢这个解决方案,特别是因为它与我们项目的 MVVM 结构结合起来会变得非常混乱。
我想到的另一个解决方案是从视频生成屏幕截图并显示该屏幕截图而不是视频,但我也没有成功创建屏幕截图。
你们如何显示视频的缩略图?
I'm trying to add videos to my WPF project, but I can't find a proper solution for generating previews/thumbnails of the video. A lot of solutions on the internet mention you should play and then pause the video in code behind. I don't really like that solution especially because it gets very messy in combination with the MVVM structure of our project.
Another solution I thought of is generating a screenshot from the video and display that screenshot instead of the video, but I also have no success in creating the screenshots.
How do you guys show thumbnails of your videos?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过将 MediaPlayer 的 ScrubbingEnabled 属性设置为 true 来实现此目的,但您仍然需要继续实时捕获任何影片。
有关更多示例,请阅读 Clint Rutkas 撰写的这篇精彩博客文章:
http:// /www.betterthaneveryone.com/archive/2009/10/02/882.aspx
You do this by setting the MediaPlayer's property of ScrubbingEnabled to true and still you need to move forward to capture any movie at real time.
For more samples, please read this nice blog entry by Clint Rutkas:
http://www.betterthaneveryone.com/archive/2009/10/02/882.aspx
您可以使用 ffmpeg.exe 为视频生成缩略图作为 jpg 文件,
这是更简单的方法,因为默认情况下我们仅显示缩略图图像,并且媒体元素是隐藏或不活动的,只有当我们单击它时,我们才会显示缩略图。开始播放视频。这还可以提高资源使用率,因为如果您显示多个视频,媒体元素会很重。
You can use ffmpeg.exe to generate thumbnail for your video as a jpg file,
Which is simpler way to do it, because by default we only show Thumbnail image and media element is hidden or inactive, and only when we click on it, we start playing the video. This also improves resource usage as media element is heavy if you are displaying multiple videos.