---
title: "Reading Metadata"
canonical: https://www.graphicsmill.com/docs/gm5/ReadingMetadata.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# Reading Metadata
 
In terms of Media Processor Add-on, metadata is a set of data that are stored in a file and describe this file. There is no single metadata schema for multimedia, as media files in different formats provide different metadata. However, Media Processor Add-on exposes a universal interface to get such information.
 
Despite the format variety, there are three main kinds of metadata that are generally used:
 
- Simple fields with text values.
- Synchronized lyrics.
- Non-text fields—bitmap images.

Let us look at them one by one.
 
## Reading Text Data
  
In Media Processor Add-on, readers are the main source of information about files that are opened with them. No wonder, the readers are used to get file metadata too.
 
**Note** 
Media Processor Add-on allows reading of additional data only for files that are opened with [QTReader](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_QTReader.htm.md) or [WMReader](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_WMReader.htm.md).
 
These readers support different sets of fields, and some fields that can be read by one of them, cannot be read by another.
 
In order to read simple text metadata, do the following:
 
1. Get the [MediaProcessorMetadataDictionary](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_MediaProcessorMetadataDictionary.htm.md) instance stored in the [QTReader.Metadata](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_QTReader_Metadata.htm.md) or the [WMReader.Metadata](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_WMReader_Metadata.htm.md) property, depending on the type of the reader you use.
2. Read values in the way that is convenient to you:
    - Read certain fields that you are interested in. For that pass the corresponding keys to the [Item(Object)](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Item_1_d02429b3.htm.md) property. To check if the required fields are stored with the file, call the [Contains(Object)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Contains_1_d02429b3.htm.md) method.
    - Loop through all fields using the [Keys](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Keys.htm.md) collection.

For the list of available MediaProcessorMetadataDictionary fields, see the [MediaProcessorMetadataDictionary Fields](https://www.graphicsmill.com/docs/gm5/Fields_T_Aurigma_GraphicsMill_Codecs_MediaProcessorMetadataDictionary.htm.md) topic. This set of fields is based mostly on the [ID3v2 standard↗](http://www.id3.org/).
 
The following sample shows how to get an MediaProcessorMetadataDictionary object with metadata for the opened file and print all text fields.
 
```
'Get all metadata
Private Sub GetMetadata(ByVal fileName As String)
    Dim _reader As New WMReader(fileName)
    Dim tags As MediaProcessorMetadataDictionary = _reader.Metadata
    
    'Print all text fields
    For Each key As Object In tags.Keys
        If key <> MediaProcessorMetadataDictionary.SynchronizedLyrics And _
            key <> MediaProcessorMetadataDictionary.AttachedPicture Then
            Console.WriteLine(tags.GetKeyDescription(key).ToString() & _
            ": " & tags(key).ToString())
        End If
    Next
End Sub
```
 
```csharp
//Get all metadata
private void GetMetadata(String fileName)
{
    WMReader _reader = new WMReader(fileName);
    MediaProcessorMetadataDictionary tags = _reader.Metadata;
    
    //Print all text fields
    foreach (System.Object key in tags.Keys)
        if (!key.Equals(MediaProcessorMetadataDictionary.SynchronizedLyrics) &&
            !key.Equals(MediaProcessorMetadataDictionary.AttachedPicture))
            Console.WriteLine(tags.GetKeyDescription(key).ToString() +
                ": " + tags[key].ToString());
}
```
 
## Reading Synchronized Lyrics
  
Synchronized lyrics are different from simple text metadata, as they are intended to appear during song playback at certain points of time. So they contain not only text, but also timestamps.
 
**Note** 
This field is currently supported only by WMReader.
 
In order to read synchronized lyrics, do the following:
 
1. Get the MediaProcessorMetadataDictionary instance, as described above.
2. Check if the SynchronizedLyrics field is stored with the file calling the Contains(Object) method. Another option is to iterate through the Keys collection until you find a key of this type.
3. Read the value of the SynchronizedLyrics field into the variable of the [ID3SynchronisedLyrics](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_ID3SynchronisedLyrics.htm.md) type. This object is also a dictionary. Its keys are time values in the [TimestampFormat](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_ID3SynchronisedLyrics_TimestampFormat.htm.md), and its values are lyrics.

```
'Get synchronized lyrics
Private Sub GetLyrics(ByVal metadata As MediaProcessorMetadataDictionary)
    'Check if lyrics are present
    If metadata.Contains(MediaProcessorMetadataDictionary.SynchronizedLyrics) Then
        Dim lyrics As ID3SynchronisedLyrics = CType(metadata _
            (MediaProcessorMetadataDictionary.SynchronizedLyrics), _
            ID3SynchronisedLyrics)
        'Process lyrics
        '...
        Return
    End If
    MessageBox.Show("Lyrics are absent", "Error", MessageBoxButtons.OK, _
        MessageBoxIcon.Error)
End Sub
```
 
```csharp
//Get synchronized lyrics
private void GetLyrics(MediaProcessorMetadataDictionary metadata)
{
    //Check if lyrics are present
    if (metadata.Contains(MediaProcessorMetadataDictionary.SynchronizedLyrics))
    {
        ID3SynchronisedLyrics lyrics = (ID3SynchronisedLyrics)metadata
            [MediaProcessorMetadataDictionary.SynchronizedLyrics];
        //Process lyrics
        //...
        return;
    }
    MessageBox.Show("Lyrics are absent", "Error", MessageBoxButtons.OK,
        MessageBoxIcon.Error);
}
```
 
## Reading Bitmap Images
  
Some media files include bitmap images among other metadata. Such images usually represent album covers, performer photographs, and so on.
 
There are two ways of reading bitmap images.
 
The first approach is to apply the standard frame-by-frame reading technique. It is described in the [Reading Video Files Frame by Frame](https://www.graphicsmill.com/docs/gm5/ReadingVideoFrameByFrame.htm.md) topic.
 
The other method involves a metadata dictionary:
 
1. Get the MediaProcessorMetadataDictionary instance, as described above.
2. Check if the AttachedPicture field is stored with the file calling the Contains(Object) method. Another option is to iterate through the Keys collection until you find a key of this type.
3. Read the value of the AttachedPicture field into the variable of the [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md) type.

```
'Get attached picture
Private Sub GetPicture(ByVal metadata As MediaProcessorMetadataDictionary)
    'Check if picture is present
    If metadata.Contains(MediaProcessorMetadataDictionary.AttachedPicture) Then
        Dim picture As Aurigma.GraphicsMill.Bitmap = CType(metadata _
            (MediaProcessorMetadataDictionary.AttachedPicture), _
            Aurigma.GraphicsMill.Bitmap)
        'Process picture
        '...
        Return
    End If
    MessageBox.Show("Picture is absent", "Error", MessageBoxButtons.OK, _
        MessageBoxIcon.Error)
End Sub
```
 
```csharp
//Get attached picture
private void GetPicture(MediaProcessorMetadataDictionary metadata)
{
    //Check if picture is present
    if (metadata.Contains(MediaProcessorMetadataDictionary.AttachedPicture))
    {
        Aurigma.GraphicsMill.Bitmap picture = (Aurigma.GraphicsMill.Bitmap)
            metadata[MediaProcessorMetadataDictionary.AttachedPicture];
        //Process picture
        //...
        return;
    }
    MessageBox.Show("Picture is absent", "Error", MessageBoxButtons.OK,
        MessageBoxIcon.Error);
}
```
 
## See Also
  
### Samples
 
- [Reading ID3 Tags](https://www.graphicsmill.com/docs/gm5/ReadingID3.htm.md)
- [Determining Audio/Video File Length](https://www.graphicsmill.com/docs/gm5/DeterminingAudioVideoStreamLength.htm.md)

### Reference
 
- [QTReader Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_QTReader.htm.md)
- [WMReader Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_WMReader.htm.md)
- [MediaProcessorMetadataDictionary Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_MediaProcessorMetadataDictionary.htm.md)
- [QTReader.Metadata Property](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_QTReader_Metadata.htm.md)
- [WMReader.Metadata Property](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_WMReader_Metadata.htm.md)
- [MediaProcessorMetadataDictionary Members](https://www.graphicsmill.com/docs/gm5/Fields_T_Aurigma_GraphicsMill_Codecs_MediaProcessorMetadataDictionary.htm.md)
- [Contains(Object) Method](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Contains_1_d02429b3.htm.md)
- [Keys Property](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Keys.htm.md)
- [SynchronizedLyrics](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_MediaProcessorMetadataDictionary.htm.md)
- [GetKeyDescription(Object) Method](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_MetadataDictionary_GetKeyDescription_1_d02429b3.htm.md)
- [ID3SynchronisedLyrics Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_ID3SynchronisedLyrics.htm.md)
- [TimestampFormat Property](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_ID3SynchronisedLyrics_TimestampFormat.htm.md)
- [AttachedPicture](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_MediaProcessorMetadataDictionary.htm.md)
- [Aurigma.GraphicsMill.Bitmap Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md)

### Manual
 
- [Media Processor Add-on Concepts](https://www.graphicsmill.com/docs/gm5/MediaProcessorAddonConcepts.htm.md)
- [Reading Video Files Frame by Frame](https://www.graphicsmill.com/docs/gm5/ReadingVideoFrameByFrame.htm.md)
