播放视频并提取帧 [英] Play video and extract frame
问题描述
大家好,
在进行项目时,一个奇怪的小主意突然浮现在我的脑海.
我想播放媒体文件(任何格式,但没有GUI),允许用户暂停/恢复视频,并添加选项以将该帧提取为位图(而不是制作屏幕截图).
我在C#中找到了 DirectShow MediaPlayer [视频 [ ^ ]类不包含当前框架"属性.
如果我知道当前框架,CP可能会有一篇有关提取它的文章.
只要我可以隐藏gui,我也可以使用其他方法来播放视频.
Hello all,
Whilst working on a project, a strange little idea popped into my mind.
I want to play a media file (any format but without a gui), allow the user to pause/resume the video and add the option to extract that frame as a bitmap (instead of making a screenshot).
I''ve found the DirectShow MediaPlayer in C#[^] but the Video[^] class doesn''t contain a ''current frame'' property.
If I knew the current frame, CP would probably have an article on extracting it.
I''m also open for other method''s of playing the video as long as I can hide the gui.
推荐答案
该文档非常缺少示例,但是有两个主意.
-该类呈现给由其Owner属性指定的控件.可以使用Control.DrawToBitmap或类似方法访问呈现给该控件的上一帧吗?
-如果设置RenderToTexture并处理TextureReadyToRender,则可能会在每个帧中获得一个纹理.我对这门课不熟悉,所以我不知道是不是这种情况,但是很难看到它还有其他作用.我目前看不到如何从纹理中获取位图数据,但是必须是可能的...
That documentation is horribly short on examples, but two ideas come to mind.
- The class renders to a control, specified by its Owner property. Can you use Control.DrawToBitmap, or something similar, to access the previous frame rendered to that control?
- If you set RenderToTexture, and handle TextureReadyToRender, you may get a texture each frame. I am not familiar with this class so I don''t know if that''s the case, but it''s hard to see how else it would work. I can''t currently see how to get the bitmap data out of a texture but that must be possible ...
也许它与
中的MediaDetector方法为您工作 http://wpfmediakit.codeplex.com/ [ ^ ]
解决您的问题.
这是一个快速解决方案,如何使用这个强大的库制作视频缩略图.
创建视频缩略图 [
Hi,
maybe it''s working for you with MediaDetector Method from
http://wpfmediakit.codeplex.com/[^]
solves your problem.
Here''s a quick solution how to make Video-Thumbnails with this great Library.
Creating Video Thumbnails[^]
Best Regards
这篇关于播放视频并提取帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!