{"id":4195,"library":"pymediainfo","title":"Pymediainfo","description":"Pymediainfo is a Python wrapper for the MediaInfo library, providing an easy way to extract detailed metadata from multimedia files. It is actively maintained with frequent updates, including support for new Python versions and bundled MediaInfo library updates.","status":"active","version":"7.0.1","language":"en","source_language":"en","source_url":"https://github.com/sbraz/pymediainfo","tags":["media-analysis","metadata","video","audio","wrapper","ffmpeg-alternative"],"install":[{"cmd":"pip install pymediainfo","lang":"bash","label":"Install latest version"},{"cmd":"pip install pymediainfo --no-binary pymediainfo","lang":"bash","label":"Install without bundled MediaInfo library (uses system-wide MediaInfo)"}],"dependencies":[{"reason":"This is a wrapper for the external MediaInfo C++ library. While wheels for Linux x86-64/ARM64, macOS, and Windows include a bundled version, on other systems or when using `--no-binary`, the MediaInfo library must be installed separately (e.g., via system package manager like `apt install mediainfo` on Debian/Ubuntu, or `pacman -S libmediainfo` on Arch). Without it, only pre-generated XML can be parsed.","package":"MediaInfo (libmediainfo)"}],"imports":[{"symbol":"MediaInfo","correct":"from pymediainfo import MediaInfo"}],"quickstart":{"code":"from pymediainfo import MediaInfo\nimport os\n\n# Create a dummy media file for demonstration\ndummy_file_path = \"./dummy_media.txt\"\nwith open(dummy_file_path, \"w\") as f:\n    f.write(\"This is a dummy file to simulate media content.\\n\")\n    f.write(\"It won't have real media info, but demonstrates parsing.\")\n\ntry:\n    media_info = MediaInfo.parse(dummy_file_path)\n\n    # Iterate over all tracks and print basic information\n    if media_info.tracks:\n        print(f\"Analyzing: {os.path.basename(dummy_file_path)}\")\n        for track in media_info.tracks:\n            print(f\"  Track Type: {track.track_type}\")\n            if hasattr(track, 'format'):\n                print(f\"    Format: {track.format}\")\n            if hasattr(track, 'file_size'):\n                print(f\"    File Size: {track.file_size} bytes\")\n            # You can access many other attributes dynamically\n            # For example, for video: track.width, track.height\n            # For audio: track.channel_s, track.sampling_rate\n    else:\n        print(f\"No tracks found for {os.path.basename(dummy_file_path)}. This might happen for non-media files or if MediaInfo library isn't fully functional.\")\n\nfinally:\n    # Clean up the dummy file\n    if os.path.exists(dummy_file_path):\n        os.remove(dummy_file_path)","lang":"python","description":"This quickstart demonstrates how to use `pymediainfo` to parse a media file. It shows how to import the `MediaInfo` class and use its `parse` method to extract track-level metadata. The example creates a dummy file and attempts to parse it. Note that a real media file would yield more detailed information."},"warnings":[{"fix":"Upgrade Python to 3.9 or newer, or pin `pymediainfo<7.0.0`.","message":"Pymediainfo v7.0.0 dropped support for Python 3.7 and 3.8. The minimum required Python version is now 3.9.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Update calls to `MediaInfo.parse()` to explicitly use keyword arguments for all optional parameters (e.g., `MediaInfo.parse(filename, full=True)`).","message":"In v7.0.0, optional arguments to `MediaInfo.parse()` became positional-only. This means you must pass them as keyword arguments (`param=value`) rather than positional arguments (`value`).","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Upgrade Python to 3.7 or newer (preferably 3.9+ for v7.0.0+), or pin `pymediainfo<6.0.0`.","message":"Pymediainfo v6.0.0 dropped support for Python 3.6.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Ensure `MediaInfo` is installed on your operating system (e.g., `sudo apt install mediainfo` on Debian/Ubuntu, `brew install mediainfo` on macOS if not using wheels, or check your distribution's package manager). If you installed `pymediainfo` with `--no-binary`, you *must* install `MediaInfo` separately.","message":"The `pymediainfo` library is a wrapper and requires the underlying `MediaInfo` C++ library to be installed on the system to parse actual media files. Without it, only pre-generated XML can be processed. While wheels for some platforms bundle MediaInfo, Linux users often need to install `libmediainfo` separately.","severity":"gotcha","affected_versions":"all"},{"fix":"If multi-threading `MediaInfo.parse()`, ensure all calls use the same arguments for optional parameters, or use a synchronization mechanism (like a lock) to ensure only one thread calls `parse()` at a time if arguments vary.","message":"Due to how the underlying `MediaInfo` C++ library works, `MediaInfo.parse()` should not be called simultaneously from multiple threads with *different* arguments. Doing so can cause inconsistencies or failures because library options are shared across threads.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}