mediafile

raw JSON →
0.17.0 verified Mon Apr 27 auth: no python

A simple, cross-format library for reading and writing media file metadata. Current version 0.17.0, requires Python >=3.10. Part of the beets ecosystem, with monthly releases.

pip install mediafile
error ModuleNotFoundError: No module named 'mediafile'
cause mediafile not installed.
fix
pip install mediafile
error ImportError: cannot import name 'MediaFile' from 'mediafile'
cause Multiple mediafile packages in environment or wrong import path.
fix
Ensure correct package: from mediafile import MediaFile. If conflicting package exists, uninstall: pip uninstall mediafile then pip install mediafile
error FileTypeError: WAV file uses unsupported compression format
cause WAV file with non-PCM format (e.g., MP3 in WAV).
fix
Open with raise_on_unsupported_wav=False: MediaFile('file.wav', raise_on_unsupported_wav=False)
breaking Dropped support for Python 3.7, 3.8, 3.9 in v0.14.0. Requires Python >=3.10.
fix Upgrade Python to 3.10 or later.
breaking MediaFile moved from monolithic mediafile.py to package structure in v0.14.0. Import paths unchanged but internal API may differ.
fix Update imports: from mediafile import MediaFile (no change needed for basic usage).
gotcha Fields like 'composers', 'lyricists', 'arrangers' introduced in v0.16.0 are list fields. Assigning a string may fail.
fix Assign lists: mf.composers = ['Composer A', 'Composer B'].
gotcha Unsupported WAV files (e.g., MPEG layer 3 WAV) raise FileTypeError by default since v0.16.1. Use raise_on_unsupported_wav=False to ignore.
fix MediaFile('file.wav', raise_on_unsupported_wav=False)

Basic reading and writing of audio metadata.

from mediafile import MediaFile

# Open a file
mf = MediaFile('audio.mp3')
print(mf.title)
print(mf.artist)

# Modify metadata
mf.title = 'New Title'
mf.save()