Aurigma Graphics Mill 5.5 for .NET
AVI Processor Add-on Concepts
AVI Processor Add-on is an additional module for Graphics Mill for .NET. It enables you to add AVI files processing functionality to your application. This add-on is highly integrated with Graphics Mill for .NET and reuses a number of its classes and data types.
Features of AVI Processor Add-on
Most important features of AVI Processor Add-on are highlighted below. You can:
- Get frames from AVI files to separate images;
- Read parameters of the AVI file (such as duration, frames per second, etc);
- Extract audio streams and save them as separate WAV files;
- Create new AVI files;
- Add frames to the AVI file (e.g. by loading them from separate image files, generating them with Graphics Mill, or extracting from another AVI file).
- Specify different encoding options like frame per second, compression, quality, etc when creating new AVI file.
- Add audio track from a separate WAV file or another AVI file. It is possible to append several audio files together.
- Put a watermark on each frame added to the AVI file. It can be:
- An image.
- Current date/time.
- Frame timing information.
- Add transition effects between frames:
- Stripe transition.
- Fade out transition (changing transparency).
- Custom transition.
- Possibility to enumerate installed codecs and get information about them.
AVI-related Classes
The structure of AVI Processor Add-on classes conform to general architecture of codecs of Graphics Mill for .NET. As for any other file format supported by Graphics Mill for .NET, the following classes are presented:
- Aurigma.GraphicsMill.Codecs.AviReader - the reader class. It is used to open the existing file and read different data from it. Read more detailed how to work with readers.
- Aurigma.GraphicsMill.Codecs.AviWriter - the writer class. It is used to create new AVI files. Read more detailed how to work with writers.
- Aurigma.GraphicsMill.Codecs.AviFrame - the frame class. It represents single video frame, including the image and other information. This class is used both by reader and writer.
Additionally, the following AVI-related classes are also included:
- Aurigma.GraphicsMill.Codecs.AviCompressor - incapsulates the functionality related with AVI codecs (or compressors). Read more detailed how to work with compressors.
- Aurigma.GraphicsMill.Codecs.AviAudioManager - the audio manager class. It incapsulates all audio-related features in AVI Processor. It is used both in reader and writer to extract/add audio tracks from/to the AVI files. Read more detailed how to work with audio.
- Aurigma.GraphicsMill.Codecs.AviWatermark - enables to put a watermark on the AVI file when it is being written. Read more detailed about watermarks.
Usage
This paragraph briefly describes how AVI Processor Add-on should be used. More detailed explanations can be found in subsequent sections.
To read the AVI file content, you should create the reader object and open it on this file (see the Open method for more details). After that you can extract frames either using foreach statement (the reader can be considered as a collection of frames in this case) or using the LoadFrame(Int32) method.
As soon as you get the frame, you can get the image stored in it. Use the GetBitmap(Bitmap) method to do it. It will return an instance of the Aurigma.GraphicsMill.Bitmap class. If you need to get a resized copy of this image, you can use the GetThumbnail(Bitmap, Int32, Int32) method instead. Also, you can get the dimensions and pixel format of the frame without loading the bitmap itself. It will be faster than receiving the bitmap first and retrieving appropriate properties from it.
If you need to extract the audio track, you need to get an audio manager object associated with the reader. You can do it using the AviReader.AudioManager property. It will return the Aurigma.GraphicsMill.Codecs.AviAudioManager class instance. It provides access to audio tracks (or streams) of the AVI file (note, one AVI file can contain several audio streams). To retrieve the number of audio streams in the AVI file, use the AudioStreamCount property. You can use this value to organize a loop to iterate each audio stream. All methods which retrieve the information about the audio stream require the number of the stream to get data for. Working with Audio Track topic provides more details on this.
To create new AVI file, you need to instantiate the writer object. After it you initialize the writer settings like compression handler (i.e. the number which identifies some codec, the same as FOURCC code, but in numeric form), etc. When the writer settings are initialized, you can open the writer on a new AVI file (it will be created automatically). As soon as the writer is opened, it is ready to be filled with the video data. Just call the AddFrame(IFrame) method for each frame you want to add. To put the image (Aurigma.GraphicsMill.Bitmap instance) into the frame, use the SetBitmap(Bitmap) method of the frame object.
If you need to add audio streams to the AVI file, you should use the AviWriter.AudioManager property. It will return the same Aurigma.GraphicsMill.Codecs.AviAudioManager object, but this time you should use AddAudioStream and AppendAudioStream methods to add/append the audio data. Note, audio data should be added after you put all necessary video data.