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

Media Processor Add-on Concepts

Media Processor Add-on for Graphics Mill is a module that extends features of Graphics Mill for .NET. This module contains classes for reading video files of different types, and metadata from audio and video files.

Features

Features introduced by Media Processor Add-on are:

  • Classes for reading video files of different formats, provided that appropriate codecs are installed. They allow:
    • Reading single frames.
    • Getting the number of frames and duration of the file.
    • Detecting frame properties like data format, sizes, and so on.
  • Classes for reading metadata from media files:
    • A class for reading all metadata
    • A special class for reading synchronized lyrics.

Classes

The structure of Media Processor Add-on classes conforms to the general architecture of codecs in Graphics Mill for .NET. Here is its brief description.

Media Processor Add-on can read audio and video files using three frameworks:

  • DirectShow
  • QuickTime
  • Windows Media

There is a corresponding reader object for each of these frameworks. Such readers can be created explicitly or using the MediaFormatManager class factory, which automatically detects the suitable framework based on the passed file. Classes for explicit reader creation are:

Each reader represents a collection of Frame objects, and there is a corresponding Frame descendant for each reader:

Moreover, each reader can return metadata associated with the opened file—description, length, track name, and so on. What data will be extracted particularly depends on the file type. The MediaProcessorMetadataDictionary class is used to read such metadata. There is also a special class, ID3SynchronisedLyrics, intended for reading synchronized lyrics from audio files.

Usage

This section briefly describes how to use Media Processor Add-on. More detailed explanations can be found in subsequent sections.

Reading Files

To read a media file content, you should create a reader object and open the desired file with it. The easiest way to do that is to use the MediaFormatManager.CreateFormatReader method, but you can also create the reader of the required type explicitly, using one of the reader classes mentioned above. After that you can extract frames either enumerating through the reader with the foreach statement, or using the LoadFrame(Int32) method to get a specific frame.

Note

When you open a file for reading, no data is actually loaded from it. The data is loaded only on demand, that is, when you get the image from the frame. This way Media Processor Add-on is memory-friendly.

However when the file is opened, it becomes locked by the application. No other application can remove or modify this file. That is why it is highly recommended to close or dispose the reader object as soon as possible.

As soon as you load the frame, you can get the bitmap image stored in it. Use the GetBitmap(Bitmap) method of this frame 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 call 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 first reading the bitmap and then retrieving appropriate properties from it.

Do not forget to close the reader with the Close() method. It will unlock the file and free all associated resources.

For more details about reading files, see the Reading Video Files Frame by Frame topic.

Reading Metadata

Media Processor Add-on allows reading audio and video files metadata only when using QuickTime and Windows Media frameworks. That means, the file should be opened with QTReader or WMReader.

The QTReader.Metadata or the WMReader.Metadata property—depending on the reader you use—contains an MediaProcessorMetadataDictionary object. You can simply get the required information reading the appropriate fields of this object.

For more details about reading metadata, see the Reading Metadata topic.

See Also

Reference

Manual