From MusicBrainz Wiki



The cd2flac script performs secure extraction of audio tracks from a compact disc, and encodes them in FLAC format. This script sports the following notable features:

  • multiple passes, MD5 hashing and matching to ensure accurate extraction
  • track 1 pregap "hidden" track detection and extraction
  • metadata editing, populated from MusicBrainz, based on calculated disc ID
  • track number offsetting to allow multi-disc releases to be compiled into a single album
  • sector offset correction



  • This script is tested on Ubuntu 8.10; mileage may vary on other platforms.




Usage: cd2flac [options] [tracks]


  • Option Description Default
    --cdparanoia=program Program to extract audio from CD cdparanoia
    --device=device CD-ROM device to extract from. /dev/cdrom
    --dir=directory Directory to output files.
    --flac=program Program to encode extracted audio into FLAC format. flac
    --help Display this help message.
    --log=file File where cd2flac appends logs results to.
    --[no]metadata Fetch and edit track metadata from MusicBrainz. metadata
    --metaedit=program Program to edit album metadata. metaedit
    --metaflac=program Program to manage metadata in FLAC files. metaflac
    --matches=number Extractions that must match identically to succeed. 2
    --offset=number Force shift of sector offset. 0
    --[no]overwrite Overwrite previous extract of tracks nooverwrite
    --passes=number Number of attempts to extract before failing 3
    --quiet Quiet operation, no screen output.
    --speed=number Speed to extract track from the disc.
    --tmp=directory Directory to store temporary files in. /tmp
    --trackadd=number Add track offset for multi-disc releases. 0
    --verbose Verbose output of progress information.


This script supports a flexible way of expressing the track numbers to extract. Ranges and commas supported. Example: 1-2,4,6-8,11-. If no tracks are specified, all are extracted.

Track offset

The --trackadd option allows multiple discs to be easily compiled into a single album. Set the value to what should be added to the track number of tracks on the disc. Negative values are also permitted.


An album template allows a template of metadata to be established so that the appropriate tags are displayed in the context. For more information, see the metaedit command help.

Configuration file

You can store persistent command-line options in a file called .cd2flac in your home directory. They will be read as defaults prior to processing any passed command-line options.


0.30 (2009-01-11)

  • Minor changes to output formatting.
  • Removed (unused) tag template functionality.

0.29 (2009-01-10)

  • Added --log option to log extraction results to file. (IRC: warp)

0.28 (2009-01-09)

  • Minor changes to output messages.

0.27 (2009-01-09)

  • Now supports suppression of MusicBrainz metadata retrieval and editing via --nometadata option. (IRC: warp)

0.26 (2009-01-07)

  • Initial version released to MusicBrainz.