# MP3

MPEG audio stream information and tags.

class mutagen.mp3.MP3(filething)

  Bases: `ID3FileType`

  An MPEG audio (usually MPEG-1 Layer 3) file.

  Parameters:

    filething (filething)

  info
    Type:

      `MPEGInfo`

  tags
    Type:

      `mutagen.id3.ID3`

  property mime

    A list of mime types (`mutagen.text`)

  static score(filename, fileobj, header_data)

    Returns a score for how likely the file can be parsed by this type.

    Parameters:

      - filename (fspath) – a file path

      - fileobj (fileobj) – a file object open in rb mode. Position is undefined

      - header (bytes) – data of undefined length, starts with the start of the file.

    Returns:

      negative if definitely not a matching type, otherwise a score,

        the bigger the more certain that the file can be loaded.

    Return type:

      int

class mutagen.mp3.MPEGInfo

  Bases: `StreamInfo`

  MPEG audio stream information

  Parse information about an MPEG audio file. This also reads the Xing VBR header format.

  This code was implemented based on the format documentation at http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm.

  Useful attributes:

  length

    audio length, in seconds

    Type:

      `float`

  channels

    number of audio channels

    Type:

      `int`

  bitrate

    audio bitrate, in bits per second. In case `bitrate_mode` is `BitrateMode.UNKNOWN` the bitrate is guessed based on the first frame.

    Type:

      `int`

  sample_rate

    audio sample rate, in Hz

    Type:

      `int`

  encoder_info

    a string containing encoder name and possibly version. In case a lame tag is present this will start with `"LAME "`, if unknown it is empty, otherwise the text format is undefined.

    Type:

      `mutagen.text`

  encoder_settings

    a string containing a guess about the settings used for encoding. The format is undefined and depends on the encoder.

    Type:

      `mutagen.text`

  bitrate_mode

    a `BitrateMode`

    Type:

      `BitrateMode`

  track_gain

    replaygain track gain (89db) or None

    Type:

      `float` or `None`

  track_peak

    replaygain track peak or None

    Type:

      `float` or `None`

  album_gain

    replaygain album gain (89db) or None

    Type:

      `float` or `None`

  Useless attributes:

  version

    MPEG version (1, 2, 2.5)

    Type:

      `float`

  layer

    1, 2, or 3

    Type:

      `int`

  mode

    One of STEREO, JOINTSTEREO, DUALCHANNEL, or MONO (0-3)

    Type:

      `int`

  protected

    whether or not the file is “protected”

    Type:

      `bool`

  sketchy

    if true, the file may not be valid MPEG audio

    Type:

      `bool`

  pprint()
    Returns:

      Print stream information

    Return type:

      text

class mutagen.mp3.BitrateMode
  UNKNOWN = <BitrateMode.UNKNOWN: 0>

    Probably a CBR file, but not sure

  CBR = <BitrateMode.CBR: 1>

    Constant Bitrate

  VBR = <BitrateMode.VBR: 2>

    Variable Bitrate

  ABR = <BitrateMode.ABR: 3>

    Average Bitrate (a variant of VBR)

class mutagen.mp3.EasyMP3(filething)

  Bases: `MP3`

  Like MP3, but uses EasyID3 for tags.

  Parameters:

    filething (filething)

  info
    Type:

      `MPEGInfo`

  tags
    Type:

      `mutagen.easyid3.EasyID3`