Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: CD archiving in linux with cue and flac (Read 12617 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

CD archiving in linux with cue and flac

There's a lot of talk about using flac with embedding cue sheets to archive cds, but most of it references EAC and/or other pieces that I've not been able to make work under linux. All the information on how to do this under linux is somewhere in this forum or elsewhere on the internet, but a piece here and a piece there and not all in one place. After much searching and experimenting, I've managed to come up with something that works, but I'm sure it can be improved upon. So I'm posting what I'm doing here both so that the next person can find it easier, and in the hopes that someone on this board will offer improvements on the process.

The tools that I've found helpful for this...
flac (duh)
cd paranoia
cdrdao
shntool
cue tools

First step is to get a cue sheet of the cd. I haven't found a tool yet that directly creates a cue sheet from a cd, so I use cdrdao to create a toc file and then convert that into a cue sheet. Although cdrdao comes with a program called toc2cue, I've not had much luck with it. Fortunatly, the cue tools programs seem to do just fine.
Some people complain about how long cdrdao takes to produce a toc file, but this appears to be because it's also reading the entire disc to make sure that the data matches what the toc file says it should. To me this seems like a resonable trade off (time for paranoia) for archiving.

$ cdrdao read-toc cd.toc --with-cddb
$ cueconvert -f cd.toc -f cd.cue

Next, read the disc into one big file, and encode that as a flac. In my case the machine I'm reading the cds from has a rather small hard drive, so I like to skip the big intermediate file. I use the time/sector notation for cdparnoia with the assumption that it'll get pre-gap/hidden tracks that might be missed using track number notation. I don't actually have a disc that has that sort of trick on it, so I've not been able to test that it actually works as expected in that case. If someone who has one of those discs wants to try it out and let me know, that would be cool.

$ cdparanoia "[::]-" - | flac -V -8 -s --cuesheet=cd.cue -o "Album Name.flac" -
$ metaflac "Album Name.flac" --add-replay-gain --set-vc-field=...

And thus we have a flac file with an embedded cue sheet. From here, there's two main things you may want to do with the resulting file (other than storing it somewhere safe). One is to burn it back to cd, in which case you'll need to extract the cuesheet (and probably decode the wav file as well).

$ metaflac "Album Name.flac" --export-cuesheet-to=cd.cue
$ flac -d "Album Name.flac"
(invoke cdrecord or the burning software of your choice here)

The other is to split it into it's individual tracks for listening/transcoding/whatever.

$ metaflac "Album Name.flac" --export-cuesheet-to=- | cuebreakpoints -t cue -f - | \
    shntool split -o flac "Album Name.flac"

(some mv and metaflac can be applied to the resulting files at this point.)

anyway, that's basically it. Comments, suggestions, or scripts to rename the split files are all welcome.

CD archiving in linux with cue and flac

Reply #1
I wrote a Python script to do something similar.

In a nutshell, I rip the cd in its entiretly with cdrdao. This gives me a .bin file and a .toc file.

The files go into a directory, say /rips

Then I have another script that watches that directory. I run this in the background, as a daemon. When a new .toc file appears, it starts encoding the corresponding bin file.

My encoding script reads the .toc file and queries freedb for track, artist and genre information. Then I loop through every track in the .toc and invoke FLAC with calculated values for --skip and --until. Of course, I tag each FLAC file with all the artist name, track number, genre, year, etc.

After the entire .bin file has been processed, it moves the .toc to the same directory with the FLAC files, deletes the .BIN file, and adds replay gain to the whole collection of tracks. Oh yeah, and then it ejects the disc. I never bother converting the toc file to a cuesheet, but I could do that at a future point, if needed.

My method uses only cdrdao, flac and a cd-eject program.

I've designed my script to mimic the behavior of grip, so it names the files and places them in directories exactly as grip would do. Why not use grip? I have actually had problems with cdparanoia and my hardware. Also, I want that toc file archived as well, and this method saves me a lot of time.

My script isn't super robust (it doesn't check for duplicate CDDB entries, etc), but I have encoded about 200 CDs with it.

The most 'interesting' thing about this whole program, IMO, is the part that reads the .TOC and queries CDDB. This could have some re-use potential down the road if I ever want to re-tag my music collection from my .TOC files.

CD archiving in linux with cue and flac

Reply #2
Would you be willing to share that little scrypt?

CD archiving in linux with cue and flac

Reply #3
Quote
The most 'interesting' thing about this whole program, IMO, is the part that reads the .TOC and queries CDDB.


Are you saying that you querry CDDB from your own script rather than using the --with-cddb option of cdrdao? If so, why?

CD archiving in linux with cue and flac

Reply #4
I thought about using cdrdao's CDDB query, but it does not handle the most recent CDDB protocol, which includes the genre and date. So I use a python library called cddb-py to query CDDB.

As for sharing the script, I'd post it here, but it's actually five separate source files. There are a few dependencies, obviously. The only weird one is cddb-py, which must be version 1.4. You can download it
here.

CD archiving in linux with cue and flac

Reply #5
Thanks, I'll take a peek at those scripts.

fwiw, I have been getting date from cdrdao (I assume from cddb lookup) but no genre. I've not found genre (particularly as it's listed on many cddb entries) to be particularly useful, so that works ok for me.