API Reference¶
The main methods of interacting with audio metadata are :func:load and :func:loads.
Core¶
-
audio_metadata.determine_format(data)[source]¶ Determine the format of a filepath, file-like object, or bytes-like object.
- Parameters
data (bytes-like object, str, os.PathLike, or file-like object) – A bytes-like object, filepath, path-like object or file-like object of an audio file.
- Returns
An appropriate audio format class if supported, else None.
- Return type
-
audio_metadata.load(f)[source]¶ Load audio metadata from a filepath or file-like object.
- Parameters
f (str, os.PathLike, or file-like object) – A filepath, path-like object or file-like object of an audio file.
- Returns
An audio format object of the appropriate type.
- Return type
- Raises
FormatError – If the audio file is not valid.
UnsupportedFormat – If the audio file is not of a supported format.
ValueError – If
fis not a valid str, path-like object, file-like object, or is unreadable.
-
audio_metadata.loads(b)[source]¶ Load audio metadata from a bytes-like object.
- Parameters
b (bytes-like object) – A bytes-like object of an audio file.
- Returns
An audio format object of the appropriate type.
- Return type
- Raises
FormatError – If the audio file is not valid.
UnsupportedFormat – If the audio file is not of a supported format.
ValueError – If
bis not a valid bytes-like object.
Exceptions¶
Base Classes¶
FLAC¶
-
class
audio_metadata.FLAC[source]¶ FLAC file format object.
Extends
Format.-
cuesheet¶ The cuesheet metadata block.
- Type
-
pictures¶ A list of
FLACPictureobjects.- Type
-
seektable¶ The seektable metadata block.
- Type
-
streaminfo¶ The audio stream information.
- Type
The Vorbis comment metadata block.
- Type
-
-
class
audio_metadata.FLACCueSheet(tracks, catalog_number, lead_in_samples, compact_disc)[source]¶ A FLAC cue sheet metadata block.
A list-like structure of
FLACCueSheetTrackobjects along with some information used in the cue sheet.-
lead_in_samples¶ The number of lead-in samples. This is only meaningful for CD-DA cuesheets. For others, it should be 0.
- Type
-
-
class
audio_metadata.FLACCueSheetIndex(*, number, offset)[source]¶ A FLAC cue sheet track index point.
-
number¶ The index point number.
The first index in a track must have a number of 0 or 1.
Index numbers must increase by 1 and be unique within a track.
For CD-DA, an index number of 0 corresponds to the track pre-gab.
- Type
-
-
class
audio_metadata.FLACCueSheetTrack(*, track_number, offset, isrc, type, pre_emphasis, indexes=NOTHING)[source]¶ A FLAC cue sheet track.
-
track_number¶ The track number of the track.
0 is not allowed to avoid conflicting with the CD-DA spec lead-in track.
For CD-DA, the track number must be 1-99 or 170 for the lead-out track.
For non-CD-DA, the track number must be 255 for the lead-out track.
Track numbers must be unique within a cue sheet.
- Type
-
indexes¶ The index points for the track as
FLACCueSheetIndexobjects.- Type
-
-
class
audio_metadata.FLACPicture(mapping=None, **kwargs)[source]¶ A FLAC picture object.
-
type¶ The picture type according to the ID3v2 APIC frame format.
- Type
ID3PictureType
-
mime_type¶ The mime type of the picture. May indicate that the picture data is an URL of the picture instead of picture data.
- Type
-
colors¶ For indexed-color pictures (e.g. GIF), the number of colors used. Should be 0 for non-indexed-color pictures.
- Type
-
ID3v1¶
ID3v2¶
MP3¶
-
class
audio_metadata.MP3[source]¶ MP3 file format object.
Extends
Format.-
streaminfo¶ The audio stream information.
- Type
The ID3v2 tag frames, if present.
- Type
-
-
class
audio_metadata.LAMEEncodingFlags(*, nogap_continuation, nogap_continued, nssafejoint, nspsytune)[source]¶
-
class
audio_metadata.LAMEHeader(*, crc, version, revision, ath_type, audio_crc, audio_size, bitrate, bitrate_mode, channel_mode, delay, encoding_flags, lowpass_filter, mp3_gain, noise_shaping, padding, preset, replay_gain, source_sample_rate, surround_info, unwise_settings_used)[source]¶
-
class
audio_metadata.LAMEReplayGain(*, peak, track_type, track_origin, track_adjustment, album_type, album_origin, album_adjustment)[source]¶
-
class
audio_metadata.MP3StreamInfo(*, start, end, size, vbri, xing, version, layer, protected, bitrate, bitrate_mode, channel_mode, channels, duration, sample_rate)[source]¶
-
class
audio_metadata.MPEGFrameHeader(*, start, size, vbri, xing, version, layer, protected, padded, bitrate, channel_mode, channels, sample_rate)[source]¶
Ogg¶
-
class
audio_metadata.Ogg[source]¶ Ogg file format object.
Extends
Format.Base class for various formats using an Ogg container.
-
class
audio_metadata.OggPage(*, header, is_complete, is_continued, is_first, is_last, position, serial_number, sequence_number, crc, num_segments, segments)[source]¶
Ogg Opus¶
-
class
audio_metadata.OggOpus[source]¶ Ogg Opus file format object.
Extends
Format.-
pictures¶ A list of
FLACPictureobjects.- Type
-
streaminfo¶ The audio stream information.
- Type
The Vorbis comment metadata block.
-
Ogg Vorbis¶
-
class
audio_metadata.OggVorbis[source]¶ Ogg Vorbis file format object.
Extends
Format.-
pictures¶ A list of
FLACPictureobjects.- Type
-
streaminfo¶ The audio stream information.
- Type
The Vorbis comment metadata block.
- Type
-
Vorbis¶
WAV¶
-
class
audio_metadata.WAVE[source]¶ WAVE file format object.
Extends
Format.-
streaminfo¶ The audio stream information.
- Type
WAVStreamInfo
The ID3v2 or RIFF tags, if present.
- Type
-