Skip to main content

Python library to inspect and export metadata from MP4/M4V/M4A, MP3 and FLAC media files.

Project description

Metaspector

Metaspector is a powerful Python library and command-line tool designed for inspecting and extracting metadata from various media file formats. Whether you need to programmatically access track information, album art, or simply get a quick overview of a file's properties, Metaspector provides a clean and consistent interface.


✨ Features

  • Comprehensive Metadata Extraction: Retrieve detailed information like title, artist, album, genre, release date, track numbers, and more.

  • Audio and Video Track Details: Get specifics about video/audio codecs, channels, sample rates, bitrates, video dimensions, and more.

  • Subtitle Track Details: Get a wide variety of subtitle specific metadata like "forced only", "auxiliary content", "language translation" etc.

  • Cover Art Extraction: Easily extract embedded cover art.

  • Multi-Format Support: Easily work with major media formats like:

    • 🎬 MP4/M4V/M4A (MPEG-4 incl. parsing of proprietary atoms often seen in M4V files distributed by Apple Inc.)

    • 🎵 MP3 (MPEG-1 Audio Layer III)

    • 🎧 FLAC (Free Lossless Audio Codec)

  • Multi-Codec Support: Easily work with major codec formats like:

    • 🎬 Video Codecs AVC1, HEVC, AV1, VP9 (incl. Dolby Vision)

    • 🎵 Audio Codecs E-AC3, AC3, AAC, MP3, FLAC (incl. Dolby Atmos)

    • 📺💬 Subtitles tx3g, cea-608, mp4s, subp, clcp, text

  • Flexible Output:

    • CLI: Get human-readable JSON output directly in your terminal.

    • API: Integrate seamlessly into your Python applications.

  • Section-Specific Output: Request only the metadata, video, audio, or subtitle sections for focused data retrieval.

  • Export Functionality: Export extracted metadata to JSON files or cover art to image files.

  • No Dependencies: Metaspector is a lightweight, self-contained library. It relies exclusively on built-in Python tools, requiring no external libraries to run.

  • Dolby Vision/Atoms Detection: Easily detect if a given video or audio track contains Dolby Vision or Atmos specific indicators

  • MP42Foundation oriented: Heavily oriented on MP42Foundation, also see https://github.com/SublerApp/MP42Foundation

  • ffmpeg oriented: Strives to be as compatible as possible with ffmpeg cli instructions


🚀 Installation

You can install metaspector directly from PyPI using pip:

pip install metaspector

For development or local usage, it's recommended to use a virtual environment.

# Create and activate a virtual environment (optional but recommended)
python3 -m venv .venv
source .venv/bin/activate

# Install in editable mode from your project's root directory
pip install -e .

💡 Usage

Command-Line Interface (CLI)

The metaspector CLI provides simple and direct access to the library's main functions.

Inspect a File

To inspect a file and print all of its metadata to the terminal as JSON, use the inspect command:

Using a local file path

metaspector inspect "/path/to/your/file.mp4"

Using a URL

metaspector inspect "https://some_example_url.com/path/to/your/file.mp4"

Inspect a Specific Section

You can specify a section to get a more focused output. For example, to view only the audio track details:

metaspector inspect "/path/to/your/file.m4a" --section audio

Export Metadata

To export the full metadata of a file to a JSON file, use the export command with the meta type:

metaspector export meta "/path/to/your/file.mp3" "./output/"

This command will create a file named your_file.json in the ./output/ directory.

Export Cover Art

To extract and save the embedded cover art, use the export command with the cover type:

metaspector export cover "/path/to/your/file.flac" "./output/"

This will save the image as your_file.jpg or your_file.png in the ./output/ directory.


Python API

Metaspector's API is designed for easy integration into your Python scripts.

Basic Inspection

To get all metadata from a file, instantiate MediaInspector and call the inspect() method:

from src.metaspector import MediaInspector

inspector = MediaInspector("/path/to/your/file.mp4")
metadata = inspector.inspect()

print(metadata)

Get Specific Sections

You can pass the section argument to the inspect() method to retrieve only a specific part of the metadata:

from src.metaspector import MediaInspector

inspector = MediaInspector("/path/to/your/file.m4a")
audio_data = inspector.inspect(section="audio")

print(audio_data)

Extract Cover Art

Use the get_cover_art() method to retrieve the raw image bytes, which you can then save to a file:

from src.metaspector import MediaInspector

inspector = MediaInspector("/path/to/your/file.flac")
cover_art_bytes = inspector.get_cover_art()

if cover_art_bytes:
    with open("cover.jpg", "wb") as f:
        f.write(cover_art_bytes)

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

metaspector-0.1.8.tar.gz (56.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metaspector-0.1.8-py3-none-any.whl (63.4 kB view details)

Uploaded Python 3

File details

Details for the file metaspector-0.1.8.tar.gz.

File metadata

  • Download URL: metaspector-0.1.8.tar.gz
  • Upload date:
  • Size: 56.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metaspector-0.1.8.tar.gz
Algorithm Hash digest
SHA256 7fd0273fa8c927e4f3c01423c864ce6ea9865d9592fe066c4511b4b4c4836795
MD5 f13e6251af5f85f0853d5070d182cd06
BLAKE2b-256 54db8e759df8d28e80ee8dc08acd34725dc2596b13c32e73f81aae919b42e3ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaspector-0.1.8.tar.gz:

Publisher: publish.yaml on rsmvdl/metaspector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metaspector-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: metaspector-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 63.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metaspector-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 48ed344d80e56d0139d0aee9158d73f81964f45f70401f9377f5e9f0387d47a2
MD5 b47e61677937a60b5ff4a6395cbadcee
BLAKE2b-256 54cbbdcab0ca2a2cc4b30e0684e42fa9a064387bb50c6901d68a90dc308aec17

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaspector-0.1.8-py3-none-any.whl:

Publisher: publish.yaml on rsmvdl/metaspector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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