Information about a file or a stream is located into "info" node of an MFile or an MFReader object properties. The node contains parameters and their values and sub-nodes (for example, information about each video or audio track). So to get the information you should use a recursive method.
Note that the code is common for both MFile and MFReader objects.
Method to get information
private void GetFileInfo(string propertyNode)
{
int nCount = 0;
try
{
// get a number of properties
m_objMFReader.PropsGetCount(propertyNode, out nCount);
}
catch (Exception) { }
for (int i = 0; i < nCount; i++)
{
string sName;
string sValue;
int bNode = 0;
m_objMFReader.PropsGetByIndex(propertyNode, i, out sName, out sValue, out bNode);
// bNode flag indicates whether there are internal properties
// to collect a full node name we should separated it with "::", e.g. "info::video.0"
string sRelName = propertyNode.Length > 0 ? propertyNode + "::" + sName : sName;
if (bNode != 0)
{
GetFileInfo(sRelName); // call the method recursively in case of sub-nodes
}
else
{
fileInfo += sRelName + " = " + sValue + Environment.NewLine;
}
}
}
How to use the method?
// declare a string that contains information
private string fileInfo = string.Empty;
// call the method
GetFileInfo("");
Common fields
| Property name | Description |
|---|---|
| ts_programs | number of programs for multi-program transport stream |
| subtitle_tracks | number of subtitle tracks in the file |
| video_tracks | number of video tracks |
| audio_tracks | number of audio tracks |
| streams | total number of streams |
| format | file format |
| format_name | full name of the format |
| network | indicates whether the file is network stream or not |
| bitrate | bitrate of the file |
| video | this node contains information about the video track (height, width, codec, aspect ratio etc.). If the file contains more than one video track then nodes names are "video.0", "video.1" etc. |
| audio | this node contains information about the audio track (format, channels, codec etc.). If the file contains more than one audio track then nodes names are "audio.0", "audio.1" etc. |
| subtitle | this node contains information about subtitle track. If the file contains more than one subtitle track then nodes' names are "subtitle.0", "subtitle.1" etc. |
| ts_program | this node contain information about program for multi program transport stream (audio, video, program information). If ts_programs>0 then then nodes' names are "ts_program.0", "ts_program.1" etc. |
| duration | file duration in seconds. |
| start_time | file start time. |
| size | file size. |
| metadata | file metadata. May contain additional names divided by ".". |
| ts_program.used | Index of transport stream program that is currently used. |
| video_track.used | Index of the video track that is currently used. |
| audio_track.used | Index of the audio track that is currently used. |
| subtitle_track.used | Index of the subtitle track that is currently used. |
Other objects
The above method can be used to get all the available properties for any objects in MFormats and MPlatform SDKs.