C# 从 WMV 中提取特定帧
代码项目上的这个示例几乎正是我所需要的......除了< code>saveFrameFromVideo 采用百分比而不是帧编号...
我如何使用它从 WMV 文件中提取帧 X?
我也尝试过FFmpeg.NET...但是没有任何可下载的版本,我无法'没有得到构建的源代码...
This example on Code Project is almost exactly what I need... except the saveFrameFromVideo
takes a percentage instead of a frame number...
How can I use this to extract frame X from a WMV file?
I've also tried FFmpeg.NET... but there weren't any downloadable builds, and I couldn't get the source to build...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以尝试 AsfMojo 来完成此任务,它允许您通过以下方式提取图像时间偏移:
在内部,Media SDK 和一些自定义流操作用于获取帧精确的静止帧(最多 100 毫秒的容差),因此如果您知道媒体文件的帧速率(即 25),您可以计算时间偏移最近的帧:
You can also try AsfMojo for this task, it allows you to extract an image by time offset:
Internally the Media SDK and some custom stream manipulation is used to get frame accurate still frames (up to a 100 millisecond tolerance), so if you know the frame rate of your media file (i.e. 25) you can calculate the time offset of the nearest frame:
神奇之处在于这一行:
它根据流的百分比和长度计算帧数。由于您已经知道帧编号,因此请使用它。
The magic is in this line:
It's calculating the frame number from the percentage and the length of the stream. Since you already know the frame number, use that instead.
我一直致力于从网络摄像头视频和视频文件中提取帧 - 对于这两者,我使用了 AForge 库 - (您需要添加对 AForge.Video、AForge.Imaging、AForge.Video.Directshow 和 AForge.Video.FFMPEG 的引用) 。对于直播视频,我添加了 videoSourcePlayer_NewFrame(object sender, ref Bitmap image) 来获取帧 - 位图图像包含位图类型中所需的帧。这基本上是我在 Windows 窗体中添加的视频源播放器的事件处理程序。
对于文件中的视频,我使用了:
videoSource=new FileVideoSource(文件名);
视频源.Start();
videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(videoSource_NewFrame);
videoSource_NewFrame 是出现新帧时的事件处理程序。
I have been working on extracting frames from webcam videos and video files- for both, i used the AForge library- (you need to add references to AForge.Video, AForge.Imaging , AForge.Video.Directshow and AForge.Video.FFMPEG). For live videos, I added a videoSourcePlayer_NewFrame(object sender, ref Bitmap image) to get the frame- Bitmap image contains the required frame in type Bitmap. This is basically the event handler for the videosource player i added in the windows form.
For video from a file, i used:
videoSource=new FileVideoSoource(fileName);
videoSource.Start();
videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(videoSource_NewFrame);
videoSource_NewFrame is the event handler in case there is a new frame.