Registry / serialization / pymediainfo

pymediainfo

JSON →
library7.0.1pypypi✓ verified 27d ago

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.

pip install pymediainfo
INSTALL
IMPORT
SIG · PYMEDIAINFO
P
pymediainfo
serializationpythonv7.0.1
Install
2.2s avg
Import
157ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v7.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.159s · 17.8MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 2.2s · import 0.154s · 33MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MediaInfo
✓ from pymediainfo import MediaInfo

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.

from pymediainfo import MediaInfo import os # Create a dummy media file for demonstration dummy_file_path = "./dummy_media.txt" with open(dummy_file_path, "w") as f: f.write("This is a dummy file to simulate media content.\n") f.write("It won't have real media info, but demonstrates parsing.") try: media_info = MediaInfo.parse(dummy_file_path) # Iterate over all tracks and print basic information if media_info.tracks: print(f"Analyzing: {os.path.basename(dummy_file_path)}") for track in media_info.tracks: print(f" Track Type: {track.track_type}") if hasattr(track, 'format'): print(f" Format: {track.format}") if hasattr(track, 'file_size'): print(f" File Size: {track.file_size} bytes") # You can access many other attributes dynamically # For example, for video: track.width, track.height # For audio: track.channel_s, track.sampling_rate else: 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.") finally: # Clean up the dummy file if os.path.exists(dummy_file_path): os.remove(dummy_file_path)
Debug
Known issues
breakingPymediainfo v7.0.0 dropped support for Python 3.7 and 3.8. The minimum required Python version is now 3.9.
fix
Upgrade Python to 3.9 or newer, or pin `pymediainfo<7.0.0`.
affects: >=7.0.0
breakingIn 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`).
fix
Update calls to `MediaInfo.parse()` to explicitly use keyword arguments for all optional parameters (e.g., `MediaInfo.parse(filename, full=True)`).
affects: >=7.0.0
breakingPymediainfo v6.0.0 dropped support for Python 3.6.
fix
Upgrade Python to 3.7 or newer (preferably 3.9+ for v7.0.0+), or pin `pymediainfo<6.0.0`.
affects: >=6.0.0
gotchaThe `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.
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.
affects: all
gotchaDue 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.
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.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pymediainfo'
The 'pymediainfo' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install pymediainfo'.
WindowsError: [Error 126] The specified module could not be found
The MediaInfo.dll file is missing or not in the system's PATH.
fix
Download MediaInfo.dll from the official website and place it in the same directory as your script or add its location to the system's PATH.
TypeError: MediaInfo.parse() got an unexpected keyword argument 'full'
In pymediainfo v7.0.0, optional arguments to 'MediaInfo.parse()' became positional-only.
fix
Update calls to 'MediaInfo.parse()' to use positional arguments instead of keyword arguments for optional parameters.
ImportError: cannot import name 'MediaInfo' from 'pymediainfo'
The 'pymediainfo' package is not installed or not properly installed.
fix
Ensure 'pymediainfo' is installed correctly using pip: 'pip install pymediainfo'.
AttributeError: module 'pymediainfo' has no attribute 'parse'
Incorrect usage of the 'pymediainfo' module; 'parse' is a method of the 'MediaInfo' class, not the module.
fix
Use 'MediaInfo.parse()' after importing the 'MediaInfo' class: 'from pymediainfo import MediaInfo'.
Upgrade
Version history
7.0.1latest on PyPI · released Feb 12, 2025
Audit
Dependencies
MediaInfo (libmediainfo)requiredThis 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.
Agent activity
3 hits · last 30 days
node
2
Resources
pymediainfo — pip install pymediainfo · libregistry