C# Saving video stream as image files

1.6k Views Asked by At

Is it possible to save out a video stream as image files using c# ?

I am able to save out one files easily, but can't keep up with the stream. I'm wondering if I can cache the bitmaps somehow before writing to disk to improve performance or something similar

1

There are 1 best solutions below

0
On

You need to use some 3rd part tools such as AForge. The example ectracted from AForge documentation

Sample code

// create instance of video reader
VideoFileReader reader = new VideoFileReader( );
// open video file
reader.Open( "test.avi" );
// read 100 video frames out of it
for ( int i = 0; i < 100; i++ )
 {
   Bitmap videoFrame = reader.ReadVideoFrame( );

    videoFrame.Save(i + ".bmp")

// dispose the frame when it is no longer required
videoFrame.Dispose( );
 }
 reader.Close( );