Aurigma Graphics Mill 5.5 for .NET
Splitting Video Files to JPEGs
Splitting video files to frames is an essential feature of Media Processor Add-on. When working with individual frames one by one, you can easily resize them, apply effects to them or edit in other ways.
This basic example merely saves video frames into separate JPEG files.
The function that will save frames should perform the following operations:
- Create a reader and open the source file.
- Create an empty instance of the Aurigma.GraphicsMill.Bitmap object.
- Loop through all frames in the reader:
- Call the Frame.GetBitmap(Bitmap) method to save each frame to the Bitmap object.
- Save the Bitmap object as a file.
- Close the reader.
Visual Basic
Public Sub SplitToJpegs(ByVal inputFilename As String, ByVal _
outputBaseFilename As String)
Try
'Create the reader
Dim reader As IFormatReader = MediaFormatManager.CreateFormatReader _
(inputFilename)
'Create the bitmap
Dim image As Aurigma.GraphicsMill.Bitmap = New _
Aurigma.GraphicsMill.Bitmap
Dim index As Int32 = 0
'Save frames
Dim frame As IFrame
For Each frame In reader
frame.GetBitmap(image)
'File type selection is based on the extension
image.Save(outputBaseFilename + index.ToString() + ".jpg")
index = index + 1
Next
image.Dispose()
reader.Dispose()
Catch ex As Exception
Console.WriteLine(ex)
End Try
End Sub
C#
public static void SplitToJpegs(string inputFilename, string outputBaseFilename)
{
try
{
//Create the reader
IFormatReader reader = MediaFormatManager.CreateFormatReader(inputFilename);
//Create the bitmap
Aurigma.GraphicsMill.Bitmap image = new Aurigma.GraphicsMill.Bitmap();
Int32 index = 0;
//Save frames
foreach (IFrame frame in reader)
{
frame.GetBitmap(image);
//File type selection is based on the extension
image.Save(outputBaseFilename + index.ToString() + @".jpg");
index++;
}
image.Dispose();
reader.Dispose();
}
catch (System.Exception ex)
{
Console.WriteLine(ex);
}
}