This is a command line tool showcasing the Windows 7 Media Foundation APIs to read media source attributes and metadata. It also shows how to leverage the Windows Media Format SDK to read DRM properties. The source code can be useful for learning about Media Foundation. The built executable can be useful for dumping media file properties for debugging, or simply to get information about a media file, such as the frame size, frame rate, bit rate, or sample rate.
This sample can display properties for any media file format that is supported by Media Foundation.
Media Foundation does not currently have support for reading DRM properties, so the legacy Format SDK is used for that reason in the sample. Using Format SDK is otherwise discouraged, as it supports only Windows Media file formats and has some other key disadvantages. Media Foundation supports a much wider set of media file formats.
Here’s a sample screenshot of MFMediaPropDump:
Figure 1. Dumping media properties of a WMV file using MFMediaPropDump
Techniques:
Media files contain numerous properties that apply to the file as a whole. Some properties specify the parameters with which the file was encoded (media source attributes), some contain descriptive information (metadata), and some contain information on usage restrictions (DRM properties).
Although metadata contains descriptive information for the media content, it might also contain information about the file encoding. Sometimes it’s faster to access file-encoding information through metadata than through media source attributes.
DRM properties are available only for a Windows Media DRM protected file and reside in the DRM license.
Examples of encoding parameters are encoding algorithm (media subtype), video frame size, video frame rate, audio bit rate, and audio sample rate. Encoding parameters are read using MF attributes.
Examples of metadata are title, artist, composer, genre, and movie director. There are two ways to read metadata: by using Media Foundation with the IMFMetadata interface (Media Foundation metadata), and by using the Windows Shell IPropertyStore interface (shell metadata). Media Foundation metadata and shell metadata complement each other. Shell metadata pertains not only to media files but to a much wider range of files on the system and the set of properties even for media files is richer than Media Foundation metadata. Media Foundation metadata on the other hand pertains only to media files and has support for per-stream metadata in a media file that shell metadata doesn’t have.
Examples of DRM properties are the number of allowed playbacks and the number of synchronizations to portable devices.
How to read media source attributes:
How to read metadata:
How to read DRM properties:
To read more about presentation descriptors and stream descriptors: http://msdn.microsoft.com/en-us/library/ms698961(VS.85).aspx
To read more about media types: http://msdn.microsoft.com/en-us/library/bb530109(VS.85).aspx
To read more about media attributes: http://msdn.microsoft.com/en-us/library/dd206754(VS.85).aspx
To read more about media properties: http://msdn.microsoft.com/en-us/library/dd206755(VS.85).aspx
To read more about metadata: http://msdn.microsoft.com/en-us/library/aa368930(VS.85).aspx
To read more about reading DRM properties: http://msdn.microsoft.com/en-us/library/dd743976(VS.85).aspx
Project Structure:
Usage:
MFMediaPropDump.exe [-?] -f file
Examples:
Limitations:
Downloading the Sample
You can download MFMediaPropDump from http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=mfblog&DownloadId=8757.
Follow the instructions at http://code.msdn.microsoft.com/mfblog for tips and instructions to build the sample.
This posting is provided "AS IS" with no warranties and confers no rights.