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

AviReader Class

This class is used to read frames from AVI files.

Namespace: Aurigma.GraphicsMill.Codecs
Assembly: Aurigma.GraphicsMill.Codecs.AviProcessor (in Aurigma.GraphicsMill.Codecs.AviProcessor.dll)

Syntax

Visual Basic
Public NotInheritable Class AviReader _
	Inherits FormatReader _
	Implements ITimeReader
C#
public sealed class AviReader : FormatReader, ITimeReader

Remarks

AVI stands for Audio Video Interleave. This is a file format for video movies which can contain both video and audio data. Inside the AVI file these data is organized into so-called data streams. One AVI file can store several video and audio streams. When an video player software plays the AVI file, it uses one video and one audio stream at one time (allowing the user to switch between streams). AVI Processor add-on supports only one video and any number of audio streams.

Video streams are presented as a sequense of images which are called frames. The AviReader class enables you to extract frames using the LoadFrame(Int32) method. Also, the reader object can be interpreted as a collection of frames, and therefore you can enumerate frames using the foreach statement.

Note

AVI Processor add-on is based on Microsoft API called Video for Windows (VfW). This API imposes some limitations, in particular for the AVI file size. It cannot get all frames from the video which is larger than 1GB (it will fail to get those frames which position in video stream exceeds 1GB). VfW does not support any modifications of AVI format which overcome this limitation (in particular, DV type 1). You should keep this fact in mind when reading AVI movies.

To work with audio streams, you should use the AviAudioManager object returned through the AudioManager property. It enables you to extract sound tracks of the movie to the separate WAV file. Also, you can use it to retrieve audio data from one AVI file to another.

Since plain sequense of bitmaps occupies too much space, it is usually video compression is used. Compression is implemented in separate DLLs (so-called VfW-codecs, represented as AviCompressor class in AVI Processor) and they are independant on the AVI Processor. Some codecs are installed on each system by default, another ones should be obtained from independent vendors. Each such codec is identified by the so-called FOURCC code (4-byte string value). If to interpret the FOURCC bytes sequence as an integer value rather than string, you will get so-called compressor handler. To identify what compressor was used to create the AVI file opened in the reader object, use the CompressorHandler property.

You can use the AviReader object not only to read audio or video data, but also to extract some information about the AVI file. For example, you can get its:

In general the reader usage workflow should be the following:

  1. Create the AviReader instance.
  2. Open the reader using the Open(String) method.
    Note

    You cannot get any data from the reader until you open it on the necessary file.

  3. If necessary, read Duration, FramesPerSecond, etc.
  4. Iterate through each frame in the reader using the LoadFrame(Int32) method. It will return an AviFrame class instance. To extract the image from the frame, use its method called GetBitmap(Bitmap).

    To get the total number of frames in the reader, you can use the FrameCount property.

  5. If you need to get audio tracks, use the AudioManager property. Read the AviAudioManager class overview for more details how to work with it.

Inheritance Hierarchy

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

Object Model





See Also

Reference