MediaInfoLib Documentation

repository·master·Indexed 21 days ago

https://github.com/mediaarea/mediainfolib

A 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.

Tokens
11.4K
Snippets
30
Records
48
Agent score
73%

What's inside MediaInfoLib

  1. Choose a binding interface for MediaInfo Java bindings

    master

    When 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.
  2. Choose between Unicode and Ansi function versions

    master

    When 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.
  3. Install JNative to run MediaInfo

    master

    To run MediaInfo in a Java environment, you must have the JNative library available. You can download the JNative jar 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:

    http://sourceforge.net/projects/retroweaver/

  4. Set up MediaInfo DLL binding for Java

    master

    To use the MediaInfo native library within a Java application via JNA, follow these steps:

    1. Download JNA: Obtain the JNA library from http://jna.dev.java.net.
    2. Configure Native Library Path: Ensure the MediaInfo native library is accessible to your application's library path:
      • Windows: Copy MediaInfo.dll into your working directory.
      • Linux: Install libmediainfo using the appropriate package manager for your distribution.
    3. Verify Installation: You can verify your setup by compiling and running the HowToUse_Dll example provided in the repository.
  5. Configure qmake build options

    master

    When 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"
  6. Choose between WASM and asm.js versions of MediaInfoLib

    master

    MediaInfoLib provides two different builds for web environments. Choose based on your performance requirements and browser support:

    1. 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.js and MediaInfoWasm.wasm.
    2. asm.js version: Compiled with Emscripten 1.x. It has fewer browser feature constraints but is much slower than the WASM version.

      • Files: MediaInfo.js and MediaInfo.js.mem.
  7. Configure format support with compilation macros

    master

    You can enable or disable support for specific media formats during compilation by using macro definitions.

    Use the pattern MEDIAINFO_XXX_NO to disable a format or MEDIAINFO_XXX_YES to enable it. If both are defined, the NO definition 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.