Media Source Metadata

Media source metadata is information about the contents of a presentation. It can apply to individual streams or to the entire presentation. There are two types of information that an application can get about a presentation:

  • Information about the media data in the file. Examples include the duration, the bit rate, encoding parameters, information from packet headers, and so forth. This type of information is called coded metadata.

  • Descriptive information about the content. Examples include song title, artist, and album name. This type of information is called descriptive metadata.

Coded Metadata

Generally, coded metadata is stored as attribute values on either the presentation descriptor or the stream descriptor. Use the IMFAttributes interface to get these attributes.

For a list of computed metadata attributes, see the following topics:

Some of the attributes listed there are specific to one kind of source, such as Windows Media files.

Descriptive Metadata

Descriptive metadata is retrieved using the IMFMetadata interface. Properties are stored as name/value pairs. Property names are wide-character strings, and property values are PROPVARIANTs. A source can provide properties in more than one language.

To use this interface, do the following:

  1. Call IMFMediaSource::CreatePresentationDescriptor to get the media source's presentation descriptor.

  2. Call MFGetService on the media source to get the IMFMetadataProvider interface. In the guidService parameter of MFGetService, pass the service GUID, MF_METADATA_PROVIDER_SERVICE.

  3. Call IMFMetadataProvider::GetMFMetadata and pass in a pointer to the presentation descriptor. To get stream-level metadata, specify the stream identifier. (You can find the stream identifier by calling IMFStreamDescriptor::GetStreamIdentifier.) To get presentation-level metadata, specify zero for the stream identifier. The GetMFMetadata method returns a pointer to the IMFMetadata interface.

  4. Optionally, call IMFMetadata::GetAllLanguages to get a list of the languages in which metadata is available. Languages are identified using RFC 1766-compliant language tags.

  5. Optionally, call IMFMetadata::SetLanguage to select the language.

  6. Optionally, call IMFMetadata::GetAllPropertyNames to get a list of the names of all the metadata properties for this stream or presentation.

  7. Call IMFMetadata::GetProperty to get a specific metadata property value, passing in the name of the property.

For Windows Media files, the available metadata properties are documented in the Windows Media Format SDK documentation.

The following code example gets the presentation-level metadata properties from a source and prints the name of each property to the debug window. This code example is only meant to illustrate these interfaces. It does not show how to get particular metadata properties or display the metadata to the user.

IMFMetadataProvider *pMetaProvider = NULL;
IMFMetadata *pMetadata = NULL;
IMFPresentationDescriptor *pPD = NULL;


// Get the source's presentation descriptor.
hr = pSource->CreatePresentationDescriptor(&pPD);

// Get the metadata provider service.
if (SUCCEEDED(hr))
    hr = MFGetService(

// Get the presentation-level metadata.
if (SUCCEEDED(hr))
    hr = pMetaProvider->GetMFMetadata(
        0,      // Stream id 0 == presentation-level metadata.
        0,      // Reserved

// Get the names of all the metadata properties.
if (SUCCEEDED(hr))
    hr = pMetadata->GetAllPropertyNames(&varNames);

// Print each name.
if (SUCCEEDED(hr))
    if (varNames.vt == (VT_VECTOR | VT_LPWSTR))
        ULONG cElements = varNames.calpwstr.cElems;
        for (ULONG i = 0; i < cElements; i++)

// Clean up.

See Also

Media Sources



Send comments about this topic to Microsoft

Build date: 12/14/2009