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::Options("Info_Version", "**VERSION**;**APP_NAME**;**APP_VERSION**")
    MediaInfo Handle (for DLL : void* Handle=MediaInfo::New())
  • For each file:
    (for DLL only: MediaInfo::Delete(Handle))

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: MediaInfo::Delete(Handle))


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: MediaInfoA_Options("CodePage", "UTF-8")

Init the library

Internet connection

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.
MediaInfo::Options("Internet", "No")

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...
MediaInfo::Options("Info_Version", "**VERSION**;**APP_NAME**;**APP_VERSION**")
**VERSION** is the version of MediaInfo you have tested. Must be like this : "A.B.C.D" (example : "")
**APP_NAME** is the unique name of your application. Examples : "MediaInfoGUI", "MediaInfoCmd".
**APP_VERSION** is the version of your application. Example : "", "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.
MediaInfo::Options("Language", "**LANGUAGE_STRING**")
**LANGUAGE_STRING** is CSV-like string :
Internal name1;translation1
Internal name2;translation2
Note : when developing, you can have internal names list with :

Create a new Handle

A Handle must be created before using MediaInfoLib :
"C++" : MediaInfo Handle;
"C" (DLL...) : void* Handle=MediaInfo::New();

Open one or multiple files

Before retrieving information about one or multiples files, you must open them :

Get information

Get a pre-formated text

Standart output

If you want a text output:

If you want a HTML output :

Customize it

Default is a list of most used pieces of information. But you can customize it :
MediaInfo::Option("Inform", "**YOUR_TEXT**")
**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:

Release memory

To release memory, you must delete the handle:
"C++" : Nothing to do, will be deleted at the end of the method
"C" (DLL...) : MediaInfo::Delete(Handle);

Note : You can re-use the Handle for another MediaInfo::Open("**FILENAME**") call without deleting something.