FLAC

Read and write FLAC Vorbis comments and stream information.

Read more about FLAC at http://flac.sourceforge.net.

FLAC supports arbitrary metadata blocks. The two most interesting ones are the FLAC stream information block, and the Vorbis comment block; these are also the only ones Mutagen can currently read.

This module does not handle Ogg FLAC files.

Based off documentation available at http://flac.sourceforge.net/format.html

class mutagen.flac.FLAC(filename)

Bases: mutagen.FileType

A FLAC audio file.

Attributes:

  • info – stream information (length, bitrate, sample rate)
  • tags – metadata tags, if any
  • cuesheet – CueSheet object, if any
  • seektable – SeekTable object, if any
  • pictures – list of embedded pictures
add_picture(picture)

Add a new picture to the file.

add_tags()

Add a Vorbis comment block to the file.

add_vorbiscomment()

Add a Vorbis comment block to the file.

clear_pictures()

Delete all pictures from the file.

delete(filename=None)

Remove Vorbis comments from a file.

If no filename is given, the one most recently loaded is used.

load(filename)

Load file information from a filename.

pictures

List of embedded pictures

save(filename=None, deleteid3=False)

Save metadata blocks to a file.

If no filename is given, the one most recently loaded is used.

class mutagen.flac.StreamInfo(data)

FLAC stream information.

This contains information about the audio data in the FLAC file. Unlike most stream information objects in Mutagen, changes to this one will rewritten to the file when it is saved. Unless you are actually changing the audio stream itself, don’t change any attributes of this block.

Attributes:

  • min_blocksize – minimum audio block size
  • max_blocksize – maximum audio block size
  • sample_rate – audio sample rate in Hz
  • channels – audio channels (1 for mono, 2 for stereo)
  • bits_per_sample – bits per sample
  • total_samples – total samples in file
  • length – audio length in seconds
class mutagen.flac.Picture(data=None)

Read and write FLAC embed pictures.

Attributes:

  • type – picture type (same as types for ID3 APIC frames)
  • mime – MIME type of the picture
  • desc – picture’s description
  • width – width in pixels
  • height – height in pixels
  • depth – color depth in bits-per-pixel
  • colors – number of colors for indexed palettes (like GIF), 0 for non-indexed
  • data – picture data
class mutagen.flac.SeekTable(data)

Read and write FLAC seek tables.

Attributes:

  • seekpoints – list of SeekPoint objects
class mutagen.flac.CueSheet(data)

Read and write FLAC embedded cue sheets.

Number of tracks should be from 1 to 100. There should always be exactly one lead-out track and that track must be the last track in the cue sheet.

Attributes:

  • media_catalog_number – media catalog number in ASCII
  • lead_in_samples – number of lead-in samples
  • compact_disc – true if the cuesheet corresponds to a compact disc
  • tracks – list of CueSheetTrack objects
  • lead_out – lead-out as CueSheetTrack or None if lead-out was not found
class mutagen.flac.CueSheetTrack(track_number, start_offset, isrc='', type_=0, pre_emphasis=False)

A track in a cuesheet.

For CD-DA, track_numbers must be 1-99, or 170 for the lead-out. Track_numbers must be unique within a cue sheet. There must be atleast one index in every track except the lead-out track which must have none.

Attributes:

  • track_number – track number
  • start_offset – track offset in samples from start of FLAC stream
  • isrc – ISRC code
  • type – 0 for audio, 1 for digital data
  • pre_emphasis – true if the track is recorded with pre-emphasis
  • indexes – list of CueSheetTrackIndex objects
class mutagen.flac.CueSheetTrackIndex

Index for a track in a cuesheet.

For CD-DA, an index_number of 0 corresponds to the track pre-gap. The first index in a track must have a number of 0 or 1, and subsequently, index_numbers must increase by 1. Index_numbers must be unique within a track. And index_offset must be evenly divisible by 588 samples.

Attributes:

  • index_number – index point number
  • index_offset – offset in samples from track start

Previous topic

Frame Base Classes

Next topic

OGG

This Page