How to use CDex and FLAC together

Trav started using FLAC a while ago to archive his music. At the time, I called him silly names because I knew that MP3 would do the same job in 1/5 the space. But now when it comes time to archive my music, I instantly recognize that the choice is obvious. Gigabytes are cheap and getting cheaper, and I don’t know what format I’m going to want my music in the future; recompressing a lossy format like MP3 or even OGG can sometimes work out very poorly.

I’m convinced that OGG is a better lossy compression format than MP3 because it gets a higher quality sound for the bits it uses. 192 kbit OGG uses less space and has possibly higher sound quality than 256 kbit MP3. (I say “possibly” because I can’t discern an acoustic difference between them. They are both “near perfect”)

There are some non-obvious switches you have to set to use CDex and FLAC together. Here’s how:

CDex ripper1.5.1, FLAC compression1.1.2a

From DarkRyder on CDexos.sourceforge.net

Actually, ripping to FLAC is very easy in CDex, can be done on the fly, and doesn’t, thankfully, involve the CLI:

1. Install the FLAC encoder from http://flac.sourceforge.net/
2. In CDex, set the Encoder to “External Encoder”
3. Do not check “Don’t delete ripped WAV…”
4. Point the Encoder Path to flac.exe (mine is “C:\Program Files\FLAC\flac.exe”, which is probably the default)
5. Set the Parameter String to "-8 -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" -" (this is where the magic happens; see below)
6. Bitrate is irrelevant (I left mine at 128)
7. File Extension is “flac”
8. You can check “Hide DOS box…” if you want (I don’t because it show progress, but you might not care)
9. Check both “Send WAV header…” and “On-the-fly…”

Now ripping to FLAC will work just the same as ripping to any of the internally supported formats.

If you’re interested in that giganto parameter string, here’s the breakdown:
-8: Compression level — higher numbers mean more CPU usage but smaller files, lower ones mean less CPU and larger files. Can be 0-8
-o: Output file name. This is how CDex “tells” FLAC to follow the Filename Format from the Filename tab.
%%: These are CDex replacement tags. You can find the full list in the CDex help file under “External Encoder”. The only real drawback to this external encoders is that the track number always has leading zeroes. Doesn’t bother me, but it may bother some people.
-T: These set the “tags” in the compressed file for Artist, Album, etc. You can find the list of supported tags on the FLAC website.
-: The trailing dash tells FLAC to expect the WAV on stdin, which is what makes on-the-fly encoding possible.

And from some other folks:

It is also CRITICAL that you set the ID3 Tag version [in the Generic section] to NONE, as if you don’t, you’ll make an ogg that can’t be read by all the *nix folks, and that will piss us all off.

42 Comments

  1. TJIC says:

    Trav started using FLAC a while ago to archive his music. At the time, I called him silly names because I knew that MP3 would do the same job in 1/5 the space. But now when it comes time to archive my music, I instantly recognize that the choice is obvious. Gigabytes are cheap and getting cheaper

    Exactly!

    Buying extra disk hurts in the pocket for a few days…but lost bits are forever!

  2. Janimaku says:

    I also have the problem mentioned by dib in the forum with the on-the-fly method. Can anyone solve the problem?
    Thank you

    Have configured CDex as you detailed, however a 2kb file with a double file extension appears in the target directory, with the same name as the flac file…

    eg – .flac.flac

    Any ideas what this is?

  3. Jacob says:

    Have configured CDex as you detailed, however a 2kb file with a double file extension appears in the target directory, with the same name as the flac file…

    Had the same problem. But after setting ID3 Version to NONE, the problem vanished.

  4. Jim Kuzeja says:

    See also CD to Ogg Vorbis and FLAC conversion guide. The –replay-gain and -V flags seem like a good idea. –replay-gain won’t work if you get input from a pipe, though, so you have to use an intermediate .wav file instead. Or run VorbisGain afterwards.

    -Jim

  5. Wojtek says:

    Hi there –

    Just tried the above, installed FLAC 1.1.2 and changed CDex as above including-8 -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" – in the parameter string.

    When i tried my first cd, cdex started reading the cd but came up with a window saying it could not send data to the external encoder. I checked the path (fine).

    I tried turning off encoding on the fly but it didn’t make any difference. id3 version set to none.

    Any ideas where i might be going wrong ? Anyone else initially had the same problem?

    THanks everybody,
    Wojtek

    P.s. do you use ‘digital cd playback’ on cdex?

  6. Jacob says:

    Dont know if its the problem, but you might have forgotten the dash (-) sign in the end of the parameter. When I remove the dash, I get the excact same error.. My parameter is:

    -8 -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" -

    PS: No – I dont use Digital CD Playback.

    Good luck! and have a happy new year!
    Jacob

  7. Lee says:

    You might be missing a quote mark (“) at the end of that statement. Mine looks like so:

    -8 -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" -"

  8. Tony says:

    I think the software for this web site converts standard quotes in to smart quotes. To get FLAC encoding to work without the “could not send data to the external encoder” error, you should change the fancy looking smart quotes with the real quotation mark character (SHIFT+2 on my keyboard).

    -8 -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" -"

  9. Wojtek says:

    thanks everybody !

    in the end, it turns out that it IS the quotation marks! i cut&pasted them from the website and they are the wrong font, so when i replaced them with shift+2 everything now works fine.

    thanks again, i just wouldn’t have thought of that!

    ….now i can start tackling these huge boxes of cd’s that litter my room :)

    Happy New Year
    Wojtek, Edinburgh

  10. allen says:

    I had the exact same problem with the font of the quotation marks. couldn’t figure out the “shift+2” thing, so i had to do it manually, but it DID fix it. Thanks! Wish they’d put flac native support into CDex!!

  11. Tj says:

    Hey,
    I’m having the same problem (Cannot send to external encoder).

    I checked the quote issue, and it doesnt appear to be the problem. I even retyped it by hand (to ensure there were no strange characters).

    If I rip to wav or mp3 it works just fine. The really odd thing is that I ripped half the tracks from my cd to flac. Then my disk ran out of space. I freed up space, and tried to continue, and I’m now getting the “Cannot send to…” error.

    Any ideas?

  12. Tj says:

    Additionally, I also tried completely un/reinstalling cdex and flac. Still didnt seem to help.

  13. Tj says:

    How confoundingly bizarre…

    I was messing with the string, and tried this…
    -8 -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" -

    …and it works! No quote after the last hyphen (or space after it or anything). Quotes are replaced with normal quotes.

    Hope this helps someone else!

  14. Tj says:

    I hope these multiple posts are helpful and people don’t find them bothersome.

    Something else different I did (because I’m pretty sure I had tried that string before) was to run a wav extracted with cdex through the Flac Frontend application. It processed the wav just fine.

    Might it have somehow “reset” the flac encoder such that it is working now? I looked for some sort of temp txt log/progress/config file for flac that might’ve been generated from the failed earlier attempt that might be corrupt and causing problems, but couldnt find any such thing.

    Who knows… but in case my string doesnt work either, try the flac gui first (assuming you’re on windows).

    Regards

  15. Eliezer says:

    Hi! This is a useful thread!

    My current Flac string is:

    -8 -V -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" -"

    Well, as you all know the -V option is used to verify the encoding. I had no errors when I tried the “on the fly encoding” option with the -V, but I wonder if the verification is being performed. Can it actually verify something that was never a WAV file?

  16. Lee says:

    I don’t have time right now to look closely at the recent responses but I wanted to remind you that WordPress converts double-quotes into “smart quotes” if you don’t put it in a (code)(/code) tag. Notice how the following two “quotes” look different from one another. Instead of regular double-quotes, it’s an open-double-quote and close-double-quote.

    Inside a "code" tag, you don't have this problem.

    I went back over the previous entries and put all appropriate things in (code)(/code) tags. Tell me if this helps.

  17. Freight says:

    To all you out there.

    Dont forget to check the button “Send WAV header to stdin”. Flac seems to need this information when using “on-the-fly-encoding”.

  18. Freight says:

    When your using on-the-fly you have to set ID3-Tag to nonen. Also when you are creating an m3u playlist this is connected to the wrong files.

    Because of this i suggest: dont use on the fly. Then you have to replace the last “-” by “%1”:
    -8 -V -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn/%tt" -T "genre=%g" %1

  19. TommyZ says:

    RE could not send data to the external encoder.

    I had the same problem. Putting %2 into quotation marks solved them:

    HTH, TommyZ

  20. Louis Horvath says:

    Found an interesting bug … this explains a lot of the problems I was having – hopefully it will help others too.

    Well it looks like CDEX doesn’t mind getting quotes (“) from CDDB and then sends them to FLAC directly (duh!). This just confuses FLAC since the command line becomes unreadable. It so happens in Windows and DOS (perhaps other OSs too) you can’t use quotes in a filename so I suggest you just replace them by apostrophes anyways.

  21. Bryan says:

    FYI, the latest version of CDEx supports FLAC natively. It’s still in beta so try it at your own risk. I just ripped two CDs and it seemed to go smoothly.

  22. xavier says:

    Everyone’s comments so far have been useful to me. Thanks.

    Can someone please explain simply where I can find the logfiles and cuelists for flac files I’ve ripped from my CDs? Do I have to configre something in the options menu to be able to find these after I rip my flac files.

  23. Jay Moore says:

    For some strange reason, when I used the string posted here in CDex, FLAC encoded everything properly..and the files were complete…but te FLAC headers for each file had 3 hours 22 minutes…every single one. What’s strange is the CLI flac tool wouldn’t “test” the files since it said the md5 hash wasn’t there..the GUI FlacTest verified everything as ok…but it did nothing about the bad time listing. I searched for hours to attempt to fix it. The crazy part is the files weren’t corrupted in the least bit…all the data for the actual track was there..and when decoded, the WAV would be the right length.

    I’m not sure what option exactly caused this thing to misreport the length of the tracks…but i know recoding everything to q8 did take a little while. I wound up doing it with dbPowerAmp since the FLAC encoder wouldn’t handle a .FLAC input.

    CDex doesn’t make any LOG files in the same aspect that EAC does…and most of the elitist’s on the net have this theory that EAC rules and everything else sucks…..but if EAC is so good…why does it lock up on every scratched CD i own when cdEx’s cdparanoia engine rips it quickly and without problems.

  24. Rijk says:

    Jay: I see the same problem, I found the answer here:

    http://www.hydrogenaudio.org/forums/index.php?showtopic=52249

    Scroll down in that thread to see two possible parameter strings that work correctly with CDex.

  25. nivlacbot says:

    Thanks!

  26. Debi says:

    I followed the instructions above to get CDex to rip to FLAC files and everything seemed to be working OK until I played a particular track (Smash Mouth / Astro Lounge / All Star) and discovered that the first bit of the song is cut off. (It starts out at “omebody …”.) The CD plays fine in a CD player and a previously ripped mp3 file via CDex also works.

    Does anyone know what’s going on here or have any suggestions on how to fix this?

  27. allen says:

    the latest version of CDex has FLAC support baked in already. it’s technically in beta, but it’s been that way for like, 2 years?

    I would suggest either going that route (it’s easier, by the way); Or try ripping the track again. It’s computers, you never know what might throw it off. :D If you have the same ripping problems a second time, try ripping it as a WAV file. If it sounds clean as a wav, try converting the wave to flac. if it has the same clipping as wav, then…. well, not sure what to do then! :D good luck!

  28. Debi says:

    I tried using -0 and -5 and turning off normalize, none of which helped. I ripped a flac and a wav file. The wav file works fine, so it seems to be a problem with the flac conversion.

    I’ll try your other suggestions. Thanks for the help!

  29. Debi says:

    Looks like CDex 170b2 with built-in FLAC works fine.

  30. steele77 says:

    Enter Parameter as follows:

    1. If check following
    .On the fly
    .Transfer WAV to stdin

    “-8 -o %2 -T “artist=%a” -T “title=%t” -T “album=%b” -T “date=%y” -T “tracknumber=%tn/%tt” -T “genre=%g” -”

    (“” can be excluded)

    Where –
    -8: Compression level
    -o: Output file name, CDEX pass it to %2
    -T: Tag name
    last -: Get input data from stdin

    It will make a sampling rate error in this way. Use second way to correct this error.

    2. If uncheck following
    .On the fly
    .Transfer WAV to stdin

    “-8 -f -o %2 -T “artist=%a” -T “title=%t” -T “album=%b” -T “date=%y” -T “tracknumber=%tn/%tt” -T “genre=%g” %1″

    (“” can be excluded)

    Where –
    -f: Force to overwrite output file
    %1: Input file name, CDEX pass it to %1

  31. steele77 says:

    Debi Says:
    June 25th, 2008 at 7:07 am

    Looks like CDex 170b2 with built-in FLAC works fine.

    Actually CDex 170b2 with built-in FLAC has bug in writing ID3 tags. The ID3 tags is always blank.

  32. Tankie2 says:

    I just reinstalled CDex 151 and discovered the same troubles. Here is what I ended up with when I got it working.

    CDex version 1.51
    FLAC.exe version 1.2.1a (core install only)

    external encoder: flac.exe

    parameters:
    -8 -o %2 -T “artist=%a” -T “title=%t” -T “album=%b” -T “date=%y” -T “tracknumber=%tn/%tt” -T “genre=%g” –

    on-the-fly encoding: enabled
    send wav to stdn: enabled
    extension: flac

    Hide dos box is optional.

  33. Niels Stoltze says:

    Hi,

    I just tried with
    CDex version 1.51
    FLAC.exe 1.2.1b

    And the parameters mentioned above..

    But I could see, that the time in the files where totally wrong.. Eg with Eagles – Hell Freezes Over, all songs where 40:14 long..

    This was tested with EasyTAG 2.1
    But both Windows MediaPlayer and Squeezenter/Squeezebox reported the correct minutes for the songs..

    With CDex 1.70b2, and the builtin encoder, the time for each song is correct, when using EasyTAG 2.1

    Anyone else who has seen this problem..?


    /Stoltze

  34. nickless says:

    Solution for the length issue here.

  35. dypsis says:

    Is it possible to get CDex to format the file name with a dash between the track number, and the track title.

    So, it would look look like this (for example):

    01 – Black Dog.flac
    02 – Rock And Roll.flac
    03 – The Battle Of Evermore.flac
    04 – Stairway To Heaven.flac

  36. Jacob says:

    In settings -> filenames, just type:
    "%1 - %2\%7 - %4".

    I.e. add spaces before and after the dashes.

    I’m running 1.70b2

  37. Please update this with the correct string so it doesn’t show 202:53 in Winamp.

    Correct string:

    --force-raw-format --endian=little --channels=2 --sign=signed --sample-rate=44100 --bps=16 -8 -V -A tukey(0,5) -o %2 -T "artist=%a" -T "title=%t" -T "album=%b" -T "date=%y" -T "tracknumber=%tn" -T "genre=%g" -

    -Erica

  38. Alfugo says:

    Hello !

    Few weeks ago, I’ve updated the Flac encoder for CDex thank to this thread. I found the good parameters for an external Flac encoder (see Erica Douglass on 8/26/2009 at 12:03 am).
    Everything was fine until tonight… I really don’t understand why. I didn’t change anything to my parameters. I’ve spent 2 hours on my computer to find the problem. I’ve checked/uncheked buttons and re-install Flac & Cdex 1.70 b2. I’ve tested different CDs.

    I’ve noticed :
    – If I unchecked “On-the-fly encoding”, CDex is running but I have no file at the end of the ripping.
    – The dos box windows always appears and disappears very quickly without working (like with Flac frontend).

    Do you have the same problem? Could somebody help me?

    My eyes are burning. :)

    Thank you,
    AD

  39. Alfugo says:

    Hello,

    I’ve solved my problem. I don’t know why but it works.
    First, I needed to ripped a CD into Flac. CDex wasn’t working, so I used Foobar2000.
    After a while, I decided to use CDex again to understand why it didn’t work.
    Without changing any parameters… it works like before.

    Computers are strange sometimes.

    I hope to be helpful,
    AD

  40. lee says:

    Alfugo writes: Computers are strange sometimes

    Dare I truncate that to: Computers are strange

  41. Blake says:

    You forgot to add the option -S10s. Without seek points, most music players won’t know how long the song is and it kind of messes up seeking..

  42. Simon says:

    Hi I can’t get cdex to load the artist and track details! I know it must be simple, but can’t solve it!

    Thanks

Leave a Comment

Do not write "http://" in your comment, it will be blocked. It may take a few days for me to manually approve your first comment.

You can edit your comment after submitting it.