المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : AForge.net writer.Open problem



C# Programming
07-01-2009, 10:01 PM
Good day

I'm having a problem with the writer.Open() method in the AForge library.

I've tried running Andrew Kirillov's code snippet (below) from his "Motion Detection Algorithms" article, on how to save video to a file, but when I attempt recording the program it jumps right into the exception (since "writer.Open()" isn't working).


SaveFileDialog sfd = new SaveFileDialog( );
if ( sfd.ShowDialog( ) == DialogResult.OK )
{
AVIWriter writer = new AVIWriter( "wmv3" );
try
{
writer.Open( sfd.FileName, 320, 240 );
Bitmap bmp = new Bitmap( 320, 240, PixelFormat.Format24bppRgb );
for ( int i = 0; i < 100; i++ )
{
bmp.SetPixel( i, i, Color.FromArgb( i, 0, 255 - i ) );
writer.AddFrame( bmp );
}
bmp.Dispose( );
}
catch ( ApplicationException ex )
{
}
writer.Dispose( );
}

When I removed the catch() at the bottom, I got a "Exception unhandled: Failed creating compressed stream" message

Can anyone please help me identify the problem so I can fix it.

I've tried running the entire source code, but opening and saving video doesn't work there either.

tvb