Question

My server threw this error

Sox::Error (sox FAIL formats: no handler for file extension `mp3'
)

This person (https://superuser.com/questions/421153/how-to-add-a-mp3-handler-to-sox) had a similar issue. The solution listed there was

sudo apt-get install libsox-fmt-mp3

After running this I still was getting the same error, so I uninstalled sox (sudo apt-get remove sox) and then reinstalled it. At this point I'm confident they're both installed with the newest versions since any attempt to install them yields this

libsox-fmt-mp3 is already the newest version.
sox is already the newest version.

However, I still am receiving the same error.

Any idea what I'm missing?

Edit:

I'm using the ruby-sox gem (https://github.com/TMXCredit/ruby-sox) which says the below should be sufficient.

apt-get install libsox-fmt-all sox libchromaprint-dev

But all those are installed and still no dice.

Edit:

The only way I can figure this to happen is if sox is looking for the lib files in the wrong place. With that in mind these details might be helpful,

sudo find / -name sox
/usr/bin/sox
/usr/lib/x86_64-linux-gnu/sox
/usr/lib/mime/packages/sox
/usr/share/doc/sox
/home/deployer/apps/eko/shared/bundle/ruby/2.1.0/gems/ruby-sox-0.0.1/lib/sox

sudo find / -name libsox-fmt-mp3
/usr/share/doc/libsox-fmt-mp3

When I uninstall sox (apt-get remove sox) then I get this when I search for sox

ubuntu@ip-10-0-0-9:~$ sudo find / -name sox
/usr/lib/x86_64-linux-gnu/sox
/home/deployer/apps/eko/shared/bundle/ruby/2.1.0/gems/ruby-sox-0.0.1/lib/sox

To get rid of this sox and hopefully return to a no sox anywhere except the gem experience, I tried

sudo apt-get remove libsox-dev 

which told me a)libsox-dev wasn't installed and b) I needed to

sudo apt-get autoremove

to remove a host of files related to sox that were no longer needed. At this point, besides the gem, there were no sox files. I then

apt-get install libsox-fmt-all sox libchromaprint-dev

As the gem suggested.

No dice. Same error.

Was it helpful?

Solution

Ult decided to just use wavs. Months later (aka now) requirements changed and in order to support IE I had to get mp3 support up and running. All of the above issues still applied.

Ended up using lame.

system "lame -b 32 --resample 8 -a #{Rails.root.join("tmp",@filename)} #{Rails.root.join("tmp",@output_file_name)}"

OTHER TIPS

I ran into this issue as well. For me the problem is that I was receiving an audio stream that I thought was mp3 but which was actually aac. Sox doesn't have a handler for aac, but switching to ffmpeg worked like a charm:

ffmpeg -i input.aac output.wav

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top