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(filething)

Bases: mutagen.FileType

A FLAC audio file.

Parameters:filething (filething) –
cuesheet

CueSheet

if any or None

seektable

SeekTable

if any or None

pictures

List[Picture]

list of embedded pictures

info

StreamInfo

tags

mutagen._vorbis.VCommentDict

add_tags()

Add a Vorbis comment block to the file.

delete(*args, **kwargs)

Remove Vorbis comments from a file.

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

add_picture(picture)

Add a new picture to the file.

Parameters:picture (Picture) –
clear_pictures()

Delete all pictures from the file.

pictures
Returns:List of embedded pictures
Return type:List[Picture]
save(*args, **kwargs)

Save metadata blocks to a file.

Parameters:

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

class mutagen.flac.StreamInfo

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.

min_blocksize

int

minimum audio block size

max_blocksize

int

maximum audio block size

sample_rate

int

audio sample rate in Hz

channels

int

audio channels (1 for mono, 2 for stereo)

bits_per_sample

int

bits per sample

total_samples

int

total samples in file

length

float

audio length in seconds

bitrate

int

bitrate in bits per second, as an int

Bases:mutagen.StreamInfo
__hash__
class mutagen.flac.Picture

Read and write FLAC embed pictures.

type

id3.PictureType

picture type (same as types for ID3 APIC frames)

mime

text

MIME type of the picture

desc

text

picture’s description

width

int

width in pixels

height

int

height in pixels

depth

int

color depth in bits-per-pixel

colors

int

number of colors for indexed palettes (like GIF), 0 for non-indexed

data

bytes

picture data

To create a picture from file (in order to add to a FLAC file), instantiate this object without passing anything to the constructor and then set the properties manually:

p = Picture()

with open("Folder.jpg", "rb") as f:
    pic.data = f.read()

pic.type = id3.PictureType.COVER_FRONT
pic.mime = u"image/jpeg"
pic.width = 500
pic.height = 500
pic.depth = 16 # color depth
__hash__
class mutagen.flac.CueSheet

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.

media_catalog_number

text

media catalog number in ASCII, up to 128 characters

lead_in_samples

int

number of lead-in samples

compact_disc

bool

true if the cuesheet corresponds to a compact disc

tracks

List[mutagen.flac.CueSheetTrack]

list of CueSheetTrack objects

lead_out

mutagen.flac.CueSheetTrack or None

lead-out as CueSheetTrack or None if lead-out was not found

__hash__
class mutagen.flac.CueSheetTrack

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.

track_number

int

track number

start_offset

int

track offset in samples from start of FLAC stream

isrc

text

ISRC code, exactly 12 characters

type

int

0 for audio, 1 for digital data

pre_emphasis

bool

true if the track is recorded with pre-emphasis

indexes

List[mutagen.flac.CueSheetTrackIndex]

list of CueSheetTrackIndex objects

__hash__
class mutagen.flac.CueSheetTrackIndex(index_number, index_offset)

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.

index_number

int

index point number

index_offset

int

offset in samples from track start

class mutagen.flac.SeekTable(data)

Read and write FLAC seek tables.

seekpoints

list of SeekPoint objects

__hash__