Read and write MPEG-4 audio files with iTunes metadata.
This module will read MPEG-4 audio information and metadata, as found in Apple’s MP4 (aka M4A, M4B, M4P) files.
There is no official specification for this format. The source code for TagLib, FAAD, and various MPEG specifications at
were all consulted.
Bases: mutagen.FileType
MP4(filething)
An MPEG-4 audio file, probably containing AAC.
If more than one track is present in the file, the first is used. Only audio (‘soun’) tracks will be read.
Parameters: | (filething) (filething) – |
---|
Bases: mutagen._util.DictProxy, mutagen.Tags
MP4Tags()
Dictionary containing Apple iTunes metadata list key/values.
Keys are four byte identifiers, except for freeform (‘—-‘) keys. Values are usually unicode strings, but some atoms have a special structure:
Text values (multiple values per key are supported):
Boolean values:
Tuples of ints (multiple values per key are supported):
Integer values:
Others:
The freeform ‘—-‘ frames use a key in the format ‘—-:mean:name’ where ‘mean’ is usually ‘com.apple.iTunes’ and ‘name’ is a unique identifier for this frame. The value is a str, but is probably text that can be decoded as UTF-8. Multiple values per key are supported.
MP4 tag data cannot exist outside of the structure of an MP4 file, so this class should not be manually instantiated.
Unknown non-text tags and tags that failed to parse will be written back as is.
Remove the metadata from the given filename.
Bases: mutagen.StreamInfo
MP4Info()
MPEG-4 stream information.
int
bitrate in bits per second, as an int
float
file length in seconds, as a float
int
number of audio channels
int
audio sampling rate in Hz
int
bits per sample
e.g. "mp4a", "alac", "mp4a.40.2", "ac-3" etc.
Name of the codec used (ALAC, AAC LC, AC-3...). Values might change in the future, use for display purposes only.
A cover artwork.
format of the image (either FORMAT_JPEG or FORMAT_PNG)
x.__hash__() <==> hash(x)
A freeform value.
format of the data (see AtomDataType)
x.__hash__() <==> hash(x)
Enum for dataformat attribute of MP4FreeForm.
New in version 1.25.
for use with tags for which no type needs to be indicated because only one type is allowed
without any count or null terminator
also known as UTF-16BE
deprecated unless it is needed for special Japanese characters
the HTML file header specifies which HTML version
the XML header must identify the DTD or schemas
also known as GUID; stored as 16 bytes in binary (valid as an ID)
stored as UTF-8 text (valid as an ID)
stored as UTF-8 text (valid as an ID)
(deprecated) a GIF image
a JPEG image
PNG image
absolute, in UTF-8 characters
in milliseconds, 32-bit integer
in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits
a list of enumerated values
a signed big-endian integer with length one of { 1,2,3,4,8 } bytes
RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit ingteger
Universal Product Code, in text UTF-8 format (valid as an ID)
Windows bitmap image
Bases: mutagen.mp4.MP4
EasyMP4(filelike)
Like MP4, but uses EasyMP4Tags for tags.
Register a text key.
If the key you need to register is a simple one-to-one mapping of MP4 atom name to EasyMP4Tags key, then you can use this function:
EasyMP4Tags.RegisterTextKey("artist", "©ART")
Register a new key mapping.
A key mapping is four functions, a getter, setter, deleter, and lister. The key may be either a string or a glob pattern.
The getter, deleted, and lister receive an MP4Tags instance and the requested key name. The setter also receives the desired value, which will be a list of strings.
The getter, setter, and deleter are used to implement __getitem__, __setitem__, and __delitem__.
The lister is used to implement keys(). It should return a list of keys that are actually in the MP4 instance, provided by its associated getter.
Bases: mutagen._util.DictMixin, mutagen.Tags
EasyMP4Tags()
A file with MPEG-4 iTunes metadata.
Like Vorbis comments, EasyMP4Tags keys are case-insensitive ASCII strings, and values are a list of Unicode strings (and these lists are always of length 0 or 1).
If you need access to the full MP4 metadata feature set, you should use MP4, not EasyMP4.
Register a new key mapping.
A key mapping is four functions, a getter, setter, deleter, and lister. The key may be either a string or a glob pattern.
The getter, deleted, and lister receive an MP4Tags instance and the requested key name. The setter also receives the desired value, which will be a list of strings.
The getter, setter, and deleter are used to implement __getitem__, __setitem__, and __delitem__.
The lister is used to implement keys(). It should return a list of keys that are actually in the MP4 instance, provided by its associated getter.
Register a text key.
If the key you need to register is a simple one-to-one mapping of MP4 atom name to EasyMP4Tags key, then you can use this function:
EasyMP4Tags.RegisterTextKey("artist", "©ART")
Register a scalar integer key.
Register a text key.
If the key you need to register is a simple one-to-one mapping of MP4 freeform atom (—-) and name to EasyMP4Tags key, then you can use this function:
EasyMP4Tags.RegisterFreeformKey(
"musicbrainz_artistid", "MusicBrainz Artist Id")
Print tag key=value pairs.