How to begin quickly with MediaInfo
What you should do
A quick example, explained line per line in the next chapters (note : with the DLL, and you must adapt it to your language):
Init (only one time):
MediaInfo Handle (for DLL :
For each file:
(for DLL only:
Too long? Try this!
This should be use only if you don't expect all error messages (there will be only one error message for all possible errors) and want to open only one file:
void* Hande=MediaInfo::OpenQuick("**FILENAME**", "**VERSION**;**APP_NAME**;**APP_VERSION**")
(for DLL only:
As for every modern library, MediaInfo(Lib) support Unicode
. With this, you don't mind of the location of your program to show text. This is internationalization (I18N)
, and you can show to the user multiple alphabets (Greek, russian, french...) without coding problems!
You should use the Unicode enabled library and make your program Unicode ready if you start a new program.
Exception : Microsoft Windows command line does not support Unicode, so if you use command line, let use MediaInfo without Unicode.
For the DLL, because only one version of it is released, you have:
- MediaInfo::XXX methods. They are Unicode enabled (2 or 4 bytes character).
MediaInfoA_XXX methods. Legacy version of above, with ANSI (one byte per character) characters in place of Unicode. The local codepage is used.
Note : in the DLL only, you can use UTF-8 codepage:
Init the library
MediaInfoLib tries to connect to an Internet server for availability of newer software, anonymous
statistics and retrieving information about a file (Later... To be done)
If for some reasons you don't want this connection, deactivate it.
The version of the library
First, you need to know the version of the DLL.
Because if you have a newer version, you can have crash or unwanted behaviour...
**VERSION** is the version of MediaInfo you have tested. Must be like this : "A.B.C.D" (example : "0.7.0.0")
**APP_NAME** is the unique name of your application. Examples : "MediaInfoGUI", "MediaInfoCmd".
**APP_VERSION** is the version of your application. Example : "0.7.0.0", "1.2", "1.26beta1".
Note : if during beta tests, you detect incompatibilities between the library and an old application, contact the MediaInfo developer, he will put the application version in a black list.
The returned string is:
- "MediaInfoLib - vA.B.C.D xxx" if there is no incompatibilities beween the version in the command and the version of the library (xxx may be URL, modification information of the DLL...).
- "" (empty string) if there is incompatibility between the version in the command and the version of the library. In this case you should exit the application (with a message "MediaInfo.dll is not compatible with this version, you must use MediaInfo.dll vX.X.X.X"
Set the language of the library
The library is by default set in English.
You can change the language with a language string.
**LANGUAGE_STRING** is CSV-like string :
Note : when developing, you can have internal names list with :
Create a new Handle
A Handle must be created before using MediaInfoLib :
"C" (DLL...) :
Open one or multiple files
Before retrieving information about one or multiples files, you must open them :
Get a pre-formated text
If you want a text output:
If you want a HTML output :
Default is a list of most used pieces of information. But you can customize it :
**YOUR_TEXT** is a list of items. you can have more information about Inform method
Get a piece of information
You can access directly to one wanted piece of information:
MediaInfo::Get ("**StreamKind**", "**StreamNumber**", "**Parameter**", "**InfoKind**")
**StreamKind** can be : Stream_General, Stream_Video, Stream_Audio, Stream_Text, Stream_Chapters
**StreamNumber** is the position of the stream you want. example for Audio : 0 if you want the first Audio, 1 if you want the second Audio.
**Parameter** is the name of the piece of information you want. example : "BitRate", "Width"...
**InfoKind** should be set to MediaInfo::Info_Text, except if you want a more advanced interface
Note : when developing, you can have parameters list with:
To release memory, you must delete the handle:
"C++" : Nothing to do, will be deleted at the end of the method
"C" (DLL...) :
Note : You can re-use the Handle for another
call without deleting something.