Skip to main content

CFFI interface for libmediainfo

Project description

This library provides a convenient CFFI wrapper for libmediainfo, a lightweight library that displays information about video and audio files. Supported attributes here.

Quickstart

Easy enough:

from libmediainfo_cffi import get_metadata_as_dict
metadata_dict = get_metadata_as_dict('path/to/file')

And voilà, you get a dict with the following structure:

  • keys are track types (General/Audio/Video)

  • values are dicts “{tag: tag_value}”

If you want to parse the MediaInfo returned String yourself you can do it with:

from libmediainfo_cffi import get_metadata
metadata_string = get_metadata(path)

Now you have a formatted string, happy parsing!

Differences between this and pymediainfo

The main difference is that this library uses the API mode of CFFI, while pymediainfo uses the ABI mode. Libmediainfo_cffi approach is safer and faster but it’s a bit more complicated to debug, since you need to wrap the C++ mediainfo library in C to comunicate with Python.
On the other hand pymediainfo is more tested, Python only, so a bit easier to read (don’t be mistaken, this library is PyPy compatible too, and it works great!) and supports Python 2 (while this library doesn’t and won’t) and has crossplatform capabilities (since it uses ABI mode).

Installation

pip install libmediainfo_cffi

Development

Download the source, launch make setup and start tinkering.
Note: the .cpp and .h file in the libmediainfo_cffi directory are not used directly, but read as strings and fed to CFFI. They are useful only for IDE code hinting. Don’t try to compile them with CMake, it won’t work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libmediainfo_cffi-2.0.0.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page