参考http://www.aforgenet.com/framework/features/avi_files.html
Reading/writing AVI files
AForge.NETframework provides simple API to read and write AVI video files throughVideo for Windowsinterface. Although the interface is quite old and marked as obsolete by Microsoft,
it is still supported and gives fairly simple API for accessing AVI video files.
AVIReaderclass
The class provides access to AVI video files and allows getting each video frame individually, as well as navigate through a video file specifying index of the next frame to receive:
// instantiate AVI reader
AVIReader reader = new AVIReader( );
// open video file
reader.Open( "test.avi" );
// read the video file
while ( reader.Position - reader.Start < reader.Length )
{
// get next frame
Bitmap image = reader.GetNextFrame( );
// .. process the frame somehow or display it
}
reader.Close( );
AVIWriterclass
The class provides simple API for writing AVI video files. All you need to do is to specify codec to use, video size and frame rate and then start adding frames:
// instantiate AVI writer, use WMV3 codec
AVIWriter writer = new AVIWriter( "wmv3" );
// create new AVI file and open it
writer.Open( "test.avi", 320, 240 );
// create frame image
Bitmap image = new Bitmap( 320, 240 );
for ( int i = 0; i < 240; i++ )
{
// update image
image.SetPixel( i, i, Color.Red );
// add the image as a new frame of video file
writer.AddFrame( image );
}
writer.Close( );
使用writer.Open( "test.avi", 320, 240 );的时候,抛出异常Failed creating compressed stream
原因是:(1)wmv3编码不能在64bit下运行(2)windows7没有相应的codec
解决方法:(1)将所有的项目,改为x86 (2)安装wmv9VCMsetup (下载地址:http://www.microsoft.com/en-us/download/details.aspx?id=6191)
本人由于是32位的win7系统,只安装了Winndows Media Video 9 VCM就解决了问题。
感谢Aforge开发摄像头监控的一些情况说明http://www.cnblogs.com/ddlzq/archive/2010/10/21/1857385.html
分享到:
相关推荐
AForge.NET 源码 有相机采集、相机处理、图像处理、机器视觉等等功能
AForge.Video.VideoException Message=Failed creating compressed stream. Source=AForge.Video.VFW 请将writer = new AVIWriter("wmv3") 改为writer = new AVIWriter( ), 即默认保存为.avi文件
c#实现录屏功能,使用Interop.WMEncoderLib.dll实现该录屏功能,测试正常。
使用AForge类库的视频播放C#例子,这个小工具使用AForge类库实现C# 操作摄像头, 代码超级简捷。
主要是使用Aforge打开摄像头,并拍照保存图片,感觉还比较不错,不过不知道是否还有更好的
AForge库集包含dll文件和解析:AForge.dll、AForge.Controls.dll、AForge.Imaging.dll、AForge.Video.dll、AForge.Video.FFMPEG.dll、AForge.Video.VFW.dll、AForge.Video.DirectShow.dll等。
using AForge.Video.DirectShow; using AForge.Video; namespace AForgeDemo { public partial class Form1 : Form { private bool DeviceExist = false; private FilterInfoCollection videoDevices; private...
C# WPF使用AForge类库操作USB摄像头拍照并保存.zip
C#使用AForge连接摄像头,并拍照
AForge.NET Framework-2.2.5
AForge.NET框架的使用,用实例介绍了AForge.NET框架的使用,方便初学者快速掌握AForge.NET框架
C# 程序使用AForge.Video.FFMPEG 基于.Net framework V4.0 录制视频需要的关联类库。
解决Aforge各种不服。 未能加载文件或程序集“AForge.Video, Version=2.1.5.0, Culture=neutral, Public.的原因 未能加载“AForge.Video.FFMPEG 或它的某个依赖项
使用AForge.net 2.2.5版本,可以使用不同分辨率截图,示例已包含dll文件; 官方下载地址http://www.aforgenet.com/framework/ 在线查看代码http://www.5525.org/item/636533513098525770
WPF使用Aforge实现USB摄像头拍照: WPF使用Aforge实现USB摄像头拍照,完整Demo
dll库文件 示例源码 core fuzzy genetic image machinelearning math neuro video vision AForge.Imaging —— 日常的图像处理和过滤器 AForge.Vision —— 计算机视觉应用类库 AForge.Neuro —— 神经网络计算库 ...
c# WinForm利用AForge、AForge.Controls、AForge.Video.DirectShow、AForge.Video.FFMPEG实现调用电脑摄像头进行拍照与录像功能
基于AForge摄像头视频捕捉C#源码,经测试可以正常运行。
基于winform,使用Aforge框架实现调用本地摄像头拍照,能够自定义摄像头分辨率,代码易懂,仅作参考