`
923723914
  • 浏览: 639354 次
文章分类
社区版块
存档分类
最新评论

使用aforge的AVIWriter打开或创建文件异常Failed creating compressed stream的解决办法

 
阅读更多

参考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




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics