First off, this article assumes you already know the basics of using the yum repositories, downloading & extracting tarballs, and compiling sources on a CentOS 5.x box.
So recently we were given the task of installing the latest version (14.3.0) of SoX (Sound eXchange); on a new CentOS 5.x machine.
The base of CentOS already comes with an older version of SoX (12.18.1), but it doesn’t have mp3 support built into it. Unfortunately there were no repos out there with the latest version. With almost every repo available to CentOS, they all reported that the latest available version was installed.
This version was okay, but trying to manipulate MP3s was impossible, and always kick back the error “SoX was compiled without MP3 decoding support”. So since we were gonna have to rebuild SoX anyway, why not just go with the latest and greatest?
To accomplish installing the latest version with MP3 support, DO NOT uninstall the base version and it pretty much contains all of the dependencies that you will need to compile the source of the latest version.
First off, you are going to need the Lame Encoder. You do not need to download and compile the source code, as you can use the rpm from the repos to install it.
code:
yum install lame
Next, you’re gonna need the MAD: MPeg Audio Decoder source. Note: this project has not been updated since 2004, however it is still the basis of what you need in order to turn on full MP3 support for SoX. You will need to download madplay-05.15.2b, libmad-05.15.1b, and libid3tag-05.15.1b. While there are yum based repos for madplay, libmad, & libid3tag, they will NOT be recognized as being installed by the latest version of the SoX compiler, so you must download these tarballs and compile them manually from scratch.
Install each one of these downloads. The order doesn’t really matter, though for best results, you should start with libmad first, then libid3tag, followed by madplay.
Once you have those three installed, grab the latest version of SoX, unpack it and just run “./configure”, then “make -s”, and finally “make install”. SoX will tell you to run “make -s && make install” together, but might break. Run them separately.
After running the “./configure”, you should see this towards the end of the output:
code:
OPTIONAL FILE FORMATS
amrnb......................no
amrwb......................no
ffmpeg.....................yes
flac.......................no
gsm........................yes (in-tree)
lpc10......................yes (in-tree)
mp3........................yes
id3tag....................yes
lame......................yes
dlopen lame...............no
mad.......................yes
dlopen mad................no
oggvorbis..................yes
sndfile....................no
wavpack....................no
That’s all you need.. to make sure “lame….yes”, “mad….yes”, and “id3tag…yes”, and it will install and run like a champ.
We put this out there because we had a tough time trying to use the repositories to complete this function, and just compiling it all from scratch worked out best.
-nw
Thank you for the write up. This has just saved me a world of pain.
You might want to remember folks to add “/usr/local/lib” to their ld.so.conf files.
Best regards
Arthur
See the link below if you get an error like:
madplay: error while loading shared libraries: libmad.so.0: cannot open
http://www.linuxquestions.org/questions/linux-newbie-8/problem-in-using-madplay-713341/
These were helpful. I had to install on Centos5.6, i386, to convert between mp3s and Asterisk-friendly wav files.
An update: yum install lame (at least via rpmforge) was not recognized by sox 14.3.2. Had to download and make lame, like the other mp3 dependencies, and then it worked fine.
I second the lib conf, plus sudo /sbin/ldconfig
Since this was the Number 1 result on google, I thought I’d help out and throw a comment on this.
You do not have to manually install the dependancies. You just need to install the -devel packages. Typically I recommend install the rpmforge repo then doing a:
yum install gcc-c++ libmad libmad-devel libid3tag libid3tag-devel lame lame-devel flac-devel libvorbis-devel
once those are all installed you should be all set to do your ./configure, make -s && make install
Thanks! Great stuff and it did what I needed for now. However, installing lame did not produce “lame…yes” for some reason and I cannot convert from * to mp3 (if I ever need to). Sox now converts from mp3 to ogg, however, which is what I need.
[...] and ogg format is now supported if you compiled sox with mp3 and ogg supported. You can follow this guide if your are using CentOS. Edit the parameter al_cmdsoxmp3 when your unix path is different than the [...]
I have an issue in that running sox still uses version 12, not the new version of 14.
A post on stack overflow has explained the issue, in that sox hasn’t installed to PATH, but I don’t know what this means or how to fix it
http://stackoverflow.com/questions/10824990/sox-still-doesnt-support-mp3-after-its-source-is-recompiled-with-mp3-support
I have it working by running /usr/local/bin/sox rather than just sox
The one-stop solution for CentOS 6.4 without mad or libid3tag (YMMV):
yum install -y sox lame
mkdir /usr/local/src/SoX
cd /usr/local/src/SoX
wget http://downloads.sourceforge.net/project/sox/sox/14.4.1/sox-14.4.1.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.1%2F&ts=1366019279&use_mirror=freefr
tar -xvzf sox-14.4.1.tar.gz
cd sox-14.4.1/
./configure
make -s
make install
echo “include /usr/local/lib” >> /etc/ld.so.conf
/sbin/ldconfig