MediaInfoLib Documentation
repository·master·Indexed 21 days ago
https://github.com/mediaarea/mediainfolibA library for extracting technical and tag metadata from video and audio files. It includes an Emscripten port (libmediainfo v26.5) with WASM and asm.js builds for web environments, Node.js wrappers (mimovie and node-mediainfo), and Java bindings via JNI, JNA, and JNAtive. The library supports analyzing local files and memory buffers for streaming or seeking.
What's inside MediaInfoLib
- MediaInfoLib provides a unified display of technical and tag data for video and audio files. It is designed to extract and present the most relevant metadata from various media formats.
Choose a binding interface for MediaInfo Java bindings
masterWhen using the MediaInfo Java bindings to interface with the MediaInfo DLL or SO, you can choose from three different binding interfaces depending on your requirements:
- JNI (Java Native Interface): The standard, built-in way to call native code from Java. It typically offers the highest performance but requires more boilerplate code and compilation steps.
- JNA (Java Native Access): A library that allows calling native functions without writing JNI glue code. It is generally easier to use and faster to implement than JNI, though it may have a slight performance overhead.
- JNAtive: An alternative native interface option provided by the JNative project.
Choose between Unicode and Ansi function versions
masterWhen using the MediaInfo dynamic library (DLL), you must choose between two function naming conventions based on your character encoding requirements:
MediaInfoLib_XXX(Unicode version): This is the main, recommended version. It uses UTF16 (2-byte characters) and supports international character sets (e.g., Chinese, French, German) simultaneously.MediaInfoLibA_XXX(Ansi version): This version is deprecated. It uses localized UTF8 (1-byte characters). Use this only if you are linking legacy code that requires Ansi compatibility.
Build MediaInfoLib with qmake
masterTo build the library using
qmake, execute the following commands in your terminal. This process will generate the static library fileLibrary/libmediainfo.a.qmake makeInstall mimovie via npm
masterTo use
mimoviein your Node.js project, install it using npm:npm install mimovieInstall JNative to run MediaInfo
masterTo run MediaInfo in a Java environment, you must have the
JNativelibrary available. You can download theJNativejar file from the official source:http://jnative.sourceforge.net
If you are using an older environment with Java 1.4.2, you will need to use Retroweaver to make JNative compatible with Java RE 1.4.2. Retroweaver can be found at:
Compile MediaInfo with required dependencies
masterTo compile the MediaInfo library successfully, you must link or include the following two extra libraries:
zenlib.libzlib.lib
Choose a binding interface for Java integration
masterWhen integrating the MediaInfo DLL/SO with Java, you can use one of two primary binding interfaces depending on your requirements:
- JNA (Java Native Access): http://jna.dev.java.net
- JNAtive: http://jnative.sourceforge.net
Set up MediaInfo DLL binding for Java
masterTo use the MediaInfo native library within a Java application via JNA, follow these steps:
- Download JNA: Obtain the JNA library from http://jna.dev.java.net.
- Configure Native Library Path: Ensure the MediaInfo native library is accessible to your application's library path:
- Windows: Copy
MediaInfo.dllinto your working directory. - Linux: Install
libmediainfousing the appropriate package manager for your distribution.
- Windows: Copy
- Verify Installation: You can verify your setup by compiling and running the
HowToUse_Dllexample provided in the repository.
Configure qmake build options
masterWhen building with
qmake, you can pass specific configuration options to manage C++ standards and suppress specific compiler warnings.To build using the C++11 standard and suppress common warnings (such as unused private fields, unused constant variables, pointer sign mismatches, and invalid source encoding), use the following command:
qmake CONFIG="c++11" QMAKE_CXXFLAGS_WARN_ON="-Wno-unused-private-field -Wno-unused-const-variable -Wno-pointer-sign -Wno-invalid-source-encoding -Wno-pointer-sign"Choose between WASM and asm.js versions of MediaInfoLib
masterMediaInfoLib provides two different builds for web environments. Choose based on your performance requirements and browser support:
WASM version: Compiled with Emscripten 2.x. It is significantly faster but requires a browser that supports WebAssembly (WASM) and JavaScript Promises.
- Required Browsers: Chrome 57+, Firefox 52+, Edge 16+, Safari 11+.
- Files:
MediaInfoWasm.jsandMediaInfoWasm.wasm.
asm.js version: Compiled with Emscripten 1.x. It has fewer browser feature constraints but is much slower than the WASM version.
- Files:
MediaInfo.jsandMediaInfo.js.mem.
- Files:
Configure format support with compilation macros
masterYou can enable or disable support for specific media formats during compilation by using macro definitions.
Use the pattern
MEDIAINFO_XXX_NOto disable a format orMEDIAINFO_XXX_YESto enable it. If both are defined, theNOdefinition takes precedence.Supported format identifiers (
XXX) include:VIDEO(all videos)AUDIO(all audios)RIFF(Microsoft Avi, Wav...)OGG(Ogg, Ogm...)MPEG(Mpg, Mpeg, Vob...)MPEG4(Mp4, M4a, M4v...)MPEGA(mpa, mp2, mp3...)MPEGV(mpv, m2v...)WM(Wma, Wmv...)QT(Qt, Mov...)RM(Rm, Rmvb...)DVDV(Ifo of DVD)AAC(Aac)DTS(Dts)AC3(Ac3)MK(Matroska)APE(Monkey Audio, Ape, Mac...)FLAC(Flac)SNDFILE(SndFile related)- ...and others.