Sox returns an error when I try to handle mp3 files

mp3sox

Hello so here is the deal, I used:

$ yum install sox 

To install it in CentOS 6. After that I did a quick test:

$ sox test.mp3 test.amr

and this is what it returns:

$ sox formats: no handler for file extension `mp3'

I need this done with sox not lame because I will need to use it for mixing and other functions not available with lame.

Best Answer

The vanilla version of sox on CentOS doesn't support the mp3 codec. Here's a list of what it does support.

$ sox
...
AUDIO FILE FORMATS: 8svx aif aifc aiff aiffc al amb au avr caf cdda cdr cvs cvsd
cvu dat dvms f32 f4 f64 f8 fap flac fssd gsm gsrt hcom htk ima ircam la lpc 
lpc10 lu mat mat4 mat5 maud nist ogg paf prc pvf raw s1 s16 s2 s24 s3 s32 s4 s8 
sb sd2 sds sf sl smp snd sndfile sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 
u32 u4 u8 ub ul uw vms voc vorbis vox w64 wav wavpcm wv wve xa xi
PLAYLIST FORMATS: m3u pls
AUDIO DEVICE DRIVERS: alsa ao oss ossdsp pulseaudio

You can download the source RPM of sox and recompile with libmad and lame-devel libraries installed to add support for this feature.

This tutorial should help, titled: INSTALLING SOX W/ MP3 SUPPORT ON CENTOS 5.X, though it's for CentOS 5.x it should still apply. There are also steps in the comments of that post for compiling sox with mp3 support on CentOS 6.x.

Steps

From the comments.

The one-stop solution for CentOS 6.4 without mad or libid3tag (YMMV):

### as root

$ 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

Repo #1 - RPM Fusion

To be able to install lame you'll need to add an additional YUM Repo to your mix. The repo that contains lame is called RPM Fusion. At the time that I'm writing this the latest version of the RPM that will install the RPM Fusion repo is at: rpmfusion-nonfree-release-6-1.noarch. To install it:

$ sudo rpm -ivh http://download1.rpmfusion.org/nonfree/el/updates/6/x86_64/rpmfusion-nonfree-release-6-1.noarch.rpm

NOTE: You may need an RPM signing keys, specifically this one for EL6.

Repo #2 - EPEL

Installing the RPM Fusion repo requires another YUM repo called EPEL - Extra Packages for Enterprise Linux. You'll need to install this RPM as well, priror to installing RPM Fusion's RPM.

$ sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

NOTE: The version number on this repo changes from time to time so it's best to check what the lastest one is. Currently at the time of this post the latest version was 6.8. You can see these numbers in the package name above, "epel-release-6-8.noarch.rpm".

References

Related Question