Is there a way in Ubuntu to rip a CD to FLAC and add ReplayGain tags automatically?
Full disclosure: I am one of the former maintainers of abcde.
The command line ripper abcde
has this ability. To install simply run the following command in a Terminal window:
sudo apt-get install abcde cdparanoia flac metaflac imagemagick glyrc
Then place the following configuration in a file ~/.abcde.conf
:
# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# FLAC using abcde version 2.7.2
#
# Modified for AskUbuntu http://askubuntu.com/q/867593/57576
# to allow ReplayGain as well as Album Art retrieval...
#
# http://andrews-corner.org/linux/abcde/index.html
# -------------------------------------------------- #
# Encode tracks immediately after reading. Saves disk space, gives
# better reading of 'scratchy' disks and better troubleshooting of
# encoding process but slows the operation of abcde quite a bit:
LOWDISK=y
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb
# Make a local cache of cddb entries and then volunteer to use
# these entries when and if they match the cd:
CDDBCOPYLOCAL="y"
CDDBLOCALDIR="$HOME/.cddb"
CDDBLOCALRECURSIVE="y"
CDDBUSELOCAL="y"
# Specify the encoder to use for FLAC. In this case
# flac is the only choice.
FLACENCODERSYNTAX=flac
# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/flac
FLAC=flac
# Specify your required encoding options here. Multiple options can
# be selected as '--best --another-option' etc.
# Overall bitrate is about 880 kbs/s with level 8.
FLACOPTS='-s -e -V -8'
# Output type for FLAC.
OUTPUTTYPE="flac"
# Options to pass to metaflac for ReplayGain:
FLACGAINOPTS="--add-replay-gain"
# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac. New to abcde 2.7 is 'libcdio'.
CDROMREADERSYNTAX=cdparanoia
# Give the location of the ripping program and pass any extra options,
# if using libcdio set 'CD_PARANOIA=cd-paranoia'.
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"
# Give the location of the CD identification program:
CDDISCID=cd-discid
# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/Music"
# The default actions that abcde will take.
ACTIONS=cddb,getalbumart,playlist,read,replaygain,encode,tag,move,clean
# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'
# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'
# This function takes out dots preceding the album name, and removes a grab
# bag of illegal characters. It allows spaces, if you do not wish spaces add
# in -e 's/ /_/g' after the first sed command.
mungefilename ()
{
echo "$@" | sed -e 's/^\.*//' | tr -d ":><|*/\"'?[:cntrl:]"
}
# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=2 # Useful for debugging
COMMENT='abcde version 2.7.2' # Place a comment...
EJECTCD=y # Please eject cd when finished :-)
This is a basic configuration and many, many more options are available including:
- Automatic embedding of the downloaded album art
- Many, many other options for album art downloading
- Different flac encoding options
- The possibility of encoding to multiple other codecs simultaneously
- Different file naming, folder locations etc
But this basic configuration may very well be enough for your purposes. If so simply insert you Audio CD and run the command:
abcde
And all should be well!
Note: Values are stored for both track and album gain, see the mediainfo
output below. I have highlighted album and track values with a <-----:
General
Complete name : 01.Speak To Me Breathe.flac
Format : FLAC
Format/Info : Free Lossless Audio Codec
File size : 20.2 MiB
Duration : 4 min 0 s
Overall bit rate mode : Variable
Overall bit rate : 705 kb/s
Album replay gain : -3.68 dB <-----
Album replay gain peak : 0.968201 <-----
Album : Dark Side Of The Moon 1992 remaster
Track name : Speak To Me Breathe
Track name/Position : 01
Track name/Total : 09
Performer : Pink Floyd
Genre : Psychedelic Rock
Recorded date : 1973
Cover : Yes
Cover type : Cover (front)
Cover MIME : image/jpeg
Comment : abcde version 2.7.2
CDDB : 710a1109
Audio
Format : FLAC
Format/Info : Free Lossless Audio Codec
Duration : 4 min 0 s
Bit rate mode : Variable
Bit rate : 705 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 44.1 kHz
Bit depth : 16 bits
Replay gain : -0.48 dB <-----
Replay gain peak : 0.679779 <-----
Stream size : 20.2 MiB (100%)
Writing library : libFLAC 1.3.1 (UTC 2014-11-25)
References:
- abcde: Downloading Album Art...
- abcde: Ripping with lossless codecs...