Aug 15, 2017

Split video into frames

You can split video into frames with AForge libraries.

Add reference following libraries:
  • AForge.Video
  • AForge.Video.FFMPEG

// create instance of video reader
VideoFileReader reader = new VideoFileReader();
// open video file
reader.Open("C:\\test.mp4");
long framecount = reader.FrameCount; 

// read video frames 
for (int i = 0; i < framecount; i++)
{
 Bitmap videoFrame = reader.ReadVideoFrame();
 
 videoFrame.Save(Environment.CurrentDirectory + "\\" + i + ".bmp");

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

Quickwatch reader object
ReadVideoFrame: Read next video frame of the currently opened video file.

0 comments: