API Reference¶
The main methods of interacting with audio metadata are load
and 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
f
is 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
b
is not a valid bytes-like object.
Exceptions¶
-
exception
audio_metadata.
UnsupportedFormat
[source]¶ An unsupported format, version, or profile was encountered.
Base Classes¶
-
class
audio_metadata.
StreamInfo
(mapping=None, **kwargs)[source]¶ Base class for stream information objects.
-
class
audio_metadata.
Tags
(mapping=None, **kwargs)[source]¶ Base class for tags objects.
-
FIELD_MAP
¶ A mapping of format-specific field names to common aliases.
- Type
frozenbidict
-
FLAC¶
-
class
audio_metadata.
FLAC
[source]¶ FLAC file format object.
Extends
Format
.-
cuesheet
¶ The cuesheet metadata block.
- Type
-
pictures
¶ A list of
FLACPicture
objects.- 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
FLACCueSheetTrack
objects 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
FLACCueSheetIndex
objects.- 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
-
-
class
audio_metadata.
FLACStreamInfo
(*, start, size, min_block_size, max_block_size, min_frame_size, max_frame_size, bit_depth, bitrate, channels, duration, md5, sample_rate)[source]¶
ID3v1¶
ID3v2¶
-
class
audio_metadata.
ID3v2Flags
(*, unsync=False, compressed=False, extended=False, experimental=False, footer=False)[source]¶
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]¶
-
class
audio_metadata.
VBRIHeader
(*, version, delay, quality, num_bytes, num_frames, num_toc_entries, toc_scale_factor, toc_entry_num_bytes, toc_entry_num_frames, toc)[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]¶
-
class
audio_metadata.
OggPageHeader
(*, start, version, is_continued, is_first, is_last, position, serial_number, sequence_number, crc, num_segments)[source]¶
Ogg Opus¶
-
class
audio_metadata.
OggOpus
[source]¶ Ogg Opus file format object.
Extends
Format
.-
pictures
¶ A list of
FLACPicture
objects.- Type
-
streaminfo
¶ The audio stream information.
- Type
The Vorbis comment metadata block.
-
-
class
audio_metadata.
OggOpusStreamInfo
(*, start, size, version, bitrate, channel_map, channels, duration, output_gain, pre_skip, sample_rate=48000, source_sample_rate)[source]¶
Ogg Opus¶
-
class
audio_metadata.
OggVorbis
[source]¶ Ogg Vorbis file format object.
Extends
Format
.-
pictures
¶ A list of
FLACPicture
objects.- Type
-
streaminfo
¶ The audio stream information.
- Type
The Vorbis comment metadata block.
- Type
-
-
class
audio_metadata.
OggVorbisStreamInfo
(*, start, size, version, bitrate, channels, duration, max_bitrate, min_bitrate, nominal_bitrate, sample_rate)[source]¶
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
-