This documentation is for the old version. Go to the latest Graphics Mill docs

Taking Video File to Separate Images

It is often necessary to split the video file to separate images. For example, it is required if you need to process each frame of the video (e.g. resize, convert to grayscale, apply some effects, etc). Also, it is possible you need to reuse these frames to build another video movie. Another example - when you need to analyze these frames (e.g. detect motion, etc).

It is very easy with AVI Processor Add-on for Graphics Mill. You need to follow these steps:

  1. Create an AVI reader object and open it on the necessary file.
  2. Create empty instance of the Aurigma.GraphicsMill.Bitmap object.
  3. Iterate each frame in the reader (which can be interpreted as a collection of the AVI frames).
  4. Pass the bitmap created on the step 2 to the GetBitmap(Bitmap) method of the frame to initialize this bitmap by the current frame.
  5. Save this bitmap to disk or apply whatever else operations on it using Graphics Mill for .NET features.
  6. Close the reader.

The following code snippet shows how to split video file to frames:

Visual Basic
Public Shared Sub SplitToFrames(ByVal inputAviFilename As String, _
 ByVal outputPath As String)

    Dim reader As New Aurigma.GraphicsMill.Codecs.AviReader

    Dim bitmap As New Aurigma.GraphicsMill.Bitmap

    Dim I As Integer = 0
    Dim frame As Aurigma.GraphicsMill.Codecs.IFrame
    For Each frame In reader
        bitmap.Save(outputPath & "\frame_" & I.ToString & ".jpg")
        I = I + 1

End Sub
public static void SplitToFrames(string inputAviFilename, 
    string outputPath)
    Aurigma.GraphicsMill.Codecs.AviReader reader = 
        new Aurigma.GraphicsMill.Codecs.AviReader(inputAviFilename);
    Aurigma.GraphicsMill.Bitmap bitmap = 
        new Aurigma.GraphicsMill.Bitmap();
    int i = 0;
    foreach (Aurigma.GraphicsMill.Codecs.IFrame frame in reader)
        bitmap.Save(outputPath + @"\frame_" + i.ToString() + ".jpg");

See Also