daniebker

How to back up CDs in 2023

· [Daniel Baker]

I’ve slowly started to drift away from using music streaming services. In fact, I’ve moved away from most streaming in general, preferring to take a slower approach to consuming media. Services like Spotify have more choice than I could ever care to want and I often find myself listening to music that I already own on CD or the same albums over and over. I also have a regular habit of picking up music on Bandcamp since the artists that need the streaming money most are least likely to get any of it[1]​.

With all this in mind I decided to ditch all the streaming services I’ve was using and instead host my own private server. This way I can buy the content I want to see, which adds an extra layer of friction to help prevent over consumption of content. On top of that I can then view the media on any device in any way that I please. All this with only one subscription, the one for my VPS. First things first though, how do you rip CDs in 2023?

In this post I’ll go over how I rip CDs on Linux including cover art and all metadata for the CD.

Required Software

Before starting you’ll need to install a some software. Use these links to get everything installed and setup on your system.

abcde

A Better CD Encoder is the application we’ll use to perform a bunch of actions to rip the CD to the hard disk. The main benefit I’ve found is being able to rip multiple (up to 11!) formats at the same time. Sure, it takes longer, but the result is a fully customizable export of multiple formats. abcde also allows you to specify a set of actions to perform when ripping a CD. In my case I have it set up to download album art, make a playlist, tag tracks, fetch meta data, and set the metadata on the resulting files. It will also clean up after itself.

Exports are controlled by a configuration file that allows you to specify export formats and the options on a per format basis. It also allows you to control where each CD is ripped to, allowing you to keep a highly organised collection.

I use a modified version of andrews-corner.org abcde.conf file. For my needs I only want two formats, MP3 and FLAC. Here’s a bunch of other abcde.conf files.

# -----------------$HOME/.abcde.conf----------------- #
#
#  A sample configuration file to convert music cds to
#  multiple formats at the same time! Using abcde version
#  2.7.2 release version.
#
#   Acknowledgements to http://andrews-corner.org
# -------------------------------------------------- #

# 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

# With the demise of freedb (thanks for the years of service!)
# we move to an alternative:
CDDBURL="http://gnudb.gnudb.org/~cddb/cddb.cgi"

# 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"

MP3ENCODERSYNTAX=lame                   # Specify encoder for MP3
FLACENCODERSYNTAX=flac                  # Specify encoder for FLAC

LAME=lame                               # Path to MP3 encoder
FLAC=flac                               # Path to FLAC encoder

LAMEOPTS='-V 2'                         # Options for MP3
FLACOPTS='-s -e -V -8'                  # Options for FLAC

OUTPUTTYPE="mp3,flac"  # Encode to 2 formats!

# 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,playlist,getalbumart,read,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:]"
}

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 :-)

cdparanoia

cdparanoia is the program used to rip the files from the CD.

eyeD3

eyeD3 is a python application for modifying meta data of mp3 files. It’s used by abcde to write all the metadata to the mp3s that are exported. Without it you won’t be able to run abcde.

glyrc

glyrc is used to download album artwork for each CD. By default eyeD3 doesn’t write the cover to the metadata of the file so there’s one step after ripping a CD we need to take to add the cover to the file.

Bring it all together

Now we have everything setup and installed all you should need to do is run abcde and you’ll have the CD imported in FLAC and MP3 under the folder structures ~/Music/mp3/[ARTIST]/[ALBUM]/[NUM]_[SONG_TITLE].mp3 and ~/Music/flac/[ARTIST]/[ALBUM]/[NUM]_[SONG_TITLE].flac

This will give you a couple of options to proceed through, but in general you should only need to select y to everything since abcde will try to get all the info for a CD from the databases it has access to from the conf file.

Adding album art

Album art is not embedded by default. For that I use this script:

#!/bin/bash

for i in *.mp3; do
	eyeD3 --add-image cover.jpg:FRONT_COVER "$i";
done

Make it executable with chmod +x set_song_cover and put it somewhere on your path. Change to the directory with your MP3s and run set_song_cover the script should do the rest, providing there’s a cover.jpg in the folder.

Gotchas

Sometimes eyeD3 fails to set the metadata of a song. I’ve seen this happen when the Genre is unknown. When eyeD3 fails to write one thing the file has no metadata embedded into it. To fix this I wrote another script that extracts all the info we need from the file path of the MP3 and used the info to embed the metadata.

#!/bin/bash

TRACK_NUM=1
for i in *.mp3; do
  # Extract the song title from the filename format is 01_title.mp3
	TITLE=`echo ${i%.*} | awk -F "_" '{print $2}'`

  # Album name is the folder name
	ALBUM=$(basename "`pwd`")

  # Artist is the grand parents name
	ARTIST=$(basename "$(dirname "`pwd`")")

  # Total tracks is the number of mp3s in the folder
	TOTAL_TRACKS=$(ls *.mp3 -q -U | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $1}')

  # Write metadata using eyeD3
	eyeD3 --artist "$ARTIST" --album "$ALBUM" --title "$TITLE" -n $TRACK_NUM -N $TOTAL_TRACKS "$i"

  # Bump track num for the next round
	TRACK_NUM=$(($TRACK_NUM+1))
done

Put this script somewhere on your path and make it executable with chmod +x set_song_metadata then change to the directory with the broken MP3s. Run the script set_song_metadata and, providing you’re following the same folder structure as me, it will extract Artist, Album, Total Tracks, and Track Number from the folders.

That’s it, this is my whole automated process for importing and organising my CD collection. I’m sure there’s a way to dig into why eyeD3 is failing to add metadata on some albums, though for me it’s not a big deal to run the script to fix. I’m also sure there’s a way to automatically embed the album art, this does get tedious when doing it manually. If I come across a way to do this I’ll post a follow up.

Let me know if you have success using this method, or if you have your own way of doing it, I’d love to hear about it.