Workflow for Offline Compression to FLAC+CUESHEET

Note: Since SlimServer 6 I have switched to using individual FLAC files for each track on an album rather than the single FLAC and CUESHEET method described here. I found that the support in SlimServer for FLAC+CUE was not totally reliable, and was broken more frequently by development changes than support for individual FLAC files. I still get gapless playback with individual FLAC files, which was originally my major motivation for FLAC+CUE, and whilst I may not be able to burn the exact same album if I ever had to recover from my backups, they'd be lossless and still be gapless. I've left this information here, however, as I think it's still useful for people who want FLAC+CUE, and I still don't think there's a comparable method to achieve this separated rip and encode workflow another way.

I store all of my music in the FLAC lossless format, and choose to store that in a single file per album. I do this so that tracks that lead into one-another do so seamlessly, just as they do in the original album (I always seemed to get a small click or gap if I stored individual tracks as separate files). So that individual tracks can be played, I combine each large FLAC file with a CUESHEET.

SlimServer, the server application that powers the Squeezebox, has good support for FLAC. Not only does it support it, with and without CUESHEETS, but it will also transcode to MP3 of an appropriate bitrate when I listen to the music remotely. The only trick has been finding a straightforward workflow to allow me to efficiently encode my few hundred CDs with the least manual faffing around possible.

I use Exact Audio Copy to extract the CDs, as this supports CUESHEETs and has excellent support for external compressors. Whilst it is possible to make EAC call FLAC to compress the CD image directly to FLAC, that wasn't ideal for me since my PC is not terribly fast and so I preferred the compression to be an offline task that could be run on the server. That way I can extract the CDs as quickly as possible without holding up that process by compressing at the same time.

Workflow Overview

In summary, this is the process I use for conversion to FLAC+CUESHEET using EAC:

  1. Use EAC to extract a CD to a single WAV file and CUESHEET, stored on my server;
  2. Repeat the above step for as many albums as I can get through in an evening;
  3. Run a script on the server to convert all of the albums it finds to single FLAC files and CUESHEET, moving them into a staging area;
  4. I manually find album art and add that to the converted albums;
  5. I them move the complete albums into my main music directory structure - this is a simple 'mv' as they are staged in the same directory tree structure already.

As you can see above, I don't automatically put the converted albums into my main music directory tree so that I can easily find them to add album art. After I've done this, I move them in myself.

Extracting CD (and tags) using EAC

Whilst you can simply create a WAV file and CUESHEET from EAC very easily, that has the drawback that it will lose any artist, title, genre or year tags as these are not supported by the WAV format. I didn't want to lose these as they are used heavily by SlimServer, and so I came up with a more ingenious (or, at least, complicated!) approach. To overcome this I've a simple Perl script to remember the tag information, and use that from EAC as follows:

  1. EAC extracts a whole CD to WAV+CUESHEET, stored in a temporary directory on my PC;
  2. EAC calls a Perl script I've written called eac-wav-cue-tags.pl. This script is configured as an external compressor. This script does the following:
    1. Creates a "<artist>/<album>" directory on my server (a Gentoo Linux server);
    2. Moves the WAV file to this directory, renaming it to the pattern "<artist> - <album>.wav" as it goes;
    3. Moves the CUESHEET to this directory, following the same naming convention;
    4. Creates a TAG file in this directory. This file is something I've made up to preserve the tags so that they are available later when I compress to FLAC. This file looks like the following:
      # Tags applicable to this audio file
      artist: Elvis Presley
      cdname: That's The Way It Is (Special Edition) (Disc 3 of 3)
      year: 1970 genre: Rock & Roll

I do this for as many CDs as I can get through in one go; they all end up in their own directory on my Linux server with all the information necessary for me to convert them to FLAC. The reason I extract to a temporary directory on the PC first is that when EAC extracts to WAV+CUESHEET, it doesn't create the normal "/" directory hierarchy - instead it creates two files called CDImage.wav and CDImage.cue. This means that I would have had to manually created these directories 'by hand' for each CD to prevent the previously-extracted one being overwritten. As the external compression script is written in Perl, I have ActiveState's ActivePerl installed.

Offline Compression on Server

On the server, I have another script called flacify.pl. The purpose of this script is to find all of the raw WAV+CUESHEET albums that the above process has left, and convert them to FLAC+CUESHEET, picking up the appropriate tags. This script works as follows:

  1. It searches through the directory tree that the above script would create, looking for albums to convert;
  2. For each one, it converts it as follows:
    1. It reads the tags stored in the *.tags file, checking that all the correct tags are defined;
    2. It modifies the CUESHEET, making sure that the FILE line now references the *.flac converted file, rather than the *.wav file it previously pointed to;
    3. It converts the artist from "Various" to "Various Artists". This is a personal choice; EAC uses the former when the "Various Artists" option is set for the album, but I prefer the latter in my music library;
    4. It creates a directory in my target staging area, with the same "/" name;
    5. It moves the modified CUESHEET to this target directory;
    6. It runs FLAC with appropriate options to compress the WAV file to FLAC, and making sure that the tags are set;
    7. Finally, it removes the WAV version that was uploaded from EAC, and its associated TAG file.

Final Steps

After conversion, once the flacify.pl script has finished, I search through the target directory tree and put appropriate album image files in each directory. The SlimServer will pick these up and display them from its web interface. The final thing I do is to move these converted directories into my main music directory tree, completing the process.

Configuring and Using EAC

I've mentioned that I use a script configured as an external compressor in EAC. To do this, use the "File->Compression Options" menuitem, and configure it as follows:

External compression dialog

Note the program executed is configured to be the Perl compiler/interpreter. The additional arguments that I use are as follows:

"C:\Documents and Settings\Stuart Hickinbottom\My Documents\My Code\EAC WAV-CUE-TAGS Encoder\eac-wav-cue-tags.pl" --source-filename=%s --original-filename=%o --artist="%a" --cdname="%g" --year="%y" --genre="%m" --output-directory="\discovery\NewMusic"

You will probably want to change the location of the Perl script, and also where the converted albums are stored (the --output-directory option). The other arguments are mainly there so that EAC may pass in its tag information.

Once this is done, it is possible to extract the album simply using the "Copy Image & Create CUE Sheet-->Compressed" option, as follows:

Running EAC

Conclusions

Whilst this process may seem long and complex, that is probably just the way I have described it. In reality, I just extract albums using EAC pretty much as usual, and then run a script on my server every now and again. I could even automate the latter using a cron job, but I prefer to choose when it is going to perform the conversion.

History

  • 9/1/2005. Updated flacify.pl script to work on Windows (with ActivePerl); thanks to Jay for the suggestion and testing. This version is also a little more tollerant of potentially-troublesome characters in filenames.
  • 5/9/2004. Initial version.

Downloads

You are free to download and make use of my scripts in any way you like - just credit me if you make something more useful out of them.

  • eac-flac-cue-tags.pl. The script that is used by EAC to move the files to the server and record the tags;
  • flacify.pl. The script that is run on the server to convert to FLAC+CUESHEET all of the albums that have been written with the above script.

I recommend right-clicking and choosing your browser's "save link as" option rather than browsing to these scripts and then choosing to save them, to prevent the browser corrupting the scripts. If you get errors mentioning things like "&gt;" when you try to run them, then this is probably what you need to do to fix the problem.

While these scripts are configurable by command-line switches (try --help to see them), the defaults are specific to my installation. You may like to change them for yours - they should be easy to identify in the scripts themselves.

AttachmentSize
eac-wav-cue-tags.pl4.75 KB
flacify.pl8.85 KB