How can I add support for .flac files in SoX?

I want SoX to record audio in .flac files. When I do:

rec -t flac ~/Desktop/myrec.flac

…it gives the following error:

rec FAIL formats: no handler for given file type `flac'

I have installed SoX from 'brew' and and I do have flac 1.2.1 installed.

I have gone though man pages at http://sox.sourceforge.net/sox.pdf but did not get the information that I am looking for.

How can I add support for .flac files?

I am on OS X 10.9.3


Keeping it simple.

Removing it using brew like so :

brew remove sox

Then installing it again with specific options, like so, did the trick for me:

brew install sox --with-lame --with-flac --with-libvorbis

You may want to remove the --with-lame option if you won't be using MP3s, or the --with-libvorbis if you won't be using OGG.

I hope this helps someone.


Try this:

brew remove libogg flac sox
brew update
brew doctor
brew install libogg flac
brew install sox

This should recompile sox with libogg and flac present, and it will then find the FLAC support.

~$ brew info sox
sox: stable 14.4.1
http://sox.sourceforge.net/
/usr/local/Cellar/sox/14.4.1_1 (15 files, 2.1M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/sox.rb
==> Dependencies
Build: pkg-config ✔
Required: libpng ✔, mad ✔
Optional: opencore-amr ✘, libvorbis ✔, flac ✔, libsndfile ✔, libao ✘, lame ✔
==> Options
--with-flac
    Build with flac support
--with-lame
    Build with lame support
--with-libao
    Build with libao support
--with-libsndfile
    Build with libsndfile support
--with-libvorbis
    Build with libvorbis support
--with-opencore-amr
    Build with opencore-amr support