I want to play music in the terminal with sox.

# install sox/lame
sudo apt-get install sox
sudo apt-get install lame

# play music
play music.mp3
# play FAIL formats: no handler for file extension `mp3'

# mp3 -> wav
lame --decode music.mp3 music.wav

# play music
play music.wav

~ $ cat /etc/lsb-release 

~ $ sox --version
sox: SoX v14.3.2

The size of music.wav is +10 times larger than music.mp3.
I don't want to convert all *.mp3 to *.wav.
Is it possible to add mp3-handler to sox?

  • what linux distro are you on... and what version of the distro and sox are you running... also running sox -h reports codecs supported by the program... please check if mp3 is supported therein... Commented May 6, 2012 at 7:59
  • 2
    instead of the present accepted answer (lame/pipe), the correct/simplest answer is install libsox-fmt-all superuser.com/a/421168/73961
    – michael
    Commented Jun 24, 2016 at 4:33
  • Yup, that would explain why @kev's answer has more than fifty times as many upvotes as the accepted answer. Is this a stackexchange record?! 🤣
    – jaimet
    Commented Nov 20, 2023 at 13:23

2 Answers 2



lame --decode music.mp3 - | play -

Won't leave any trace.

  • 23
    The question was about a sox handler. This is definitely not sox :)
    – Elektordi
    Commented Aug 19, 2017 at 9:00
  • you can also pipe into sox
    – Scott
    Commented Nov 7, 2018 at 6:45
  • 3
    @Elektordi The play command is SoX. It's basically sox -d. Like ffmpeg vs. ffplay.
    – eepp
    Commented Sep 22, 2020 at 2:39
  • Sorry, I didn't know that... My bad... :/
    – Elektordi
    Commented Sep 25, 2020 at 12:36

Install libsox-fmt-mp3:

sudo apt-get install libsox-fmt-mp3
  • 2
    I found I also needed to upgrade sox after that; so it doesn't hurt to add "sox" to the above command. Commented Sep 12, 2012 at 5:44
  • This does not work for me. Even after aptitude reinstall sox I still get a SoX was compiled without MP3 encoding support when I try to run sox afterwards. (Though admittedly I'm still running Lucid, this might work better on a more modern Ubuntu.)
    – zrajm
    Commented Oct 23, 2013 at 8:06
  • 22
    @kev, you should select this as the accepted answer. Also, there is a libsox-fmt-all package that installs the mp3 format, as well as all other available formats.
    – naught101
    Commented Jan 11, 2014 at 23:23
  • 10
    +1, this should be the accepted answer because it allows for other things beyond playing as well, for example conversion (e.g. sox input.wav output.mp3 won't work without this package)
    – pascalhein
    Commented Jul 10, 2014 at 14:48
  • 3
    after installing libsox-fmt-mp3 and running it i get a : sox WARN mp3-util: MAD lost sync
    – kroe
    Commented Aug 24, 2015 at 23:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .