How to convert .aif audio files to mp3?

I have audio files with .aif extensions (AIFF/Amiga/Mac audio). How to play them and, more important: how to convert them to mp3 or other more common audio format?


update: trying to run a command found here, namely for i in *.aif; do sox "$i" "$i.wav"; done, and having sox already installed, i get an error like

sox FAIL formats: can't open input file 'filename': Unsupported AIFC compression type `ima4'


exiftool provides info such as:

File Size                       : 41 MB
File Modification Date/Time     : 2013:04:23 15:54:02+02:00
File Permissions                : rw-r--r--
File Type                       : AIFC
MIME Type                       : audio/x-aiff
Format Version Time             : 1990:05:23 14:40:00
Num Channels                    : 1
Num Sample Frames               : 1257382
Sample Size                     : 0
Sample Rate                     : 16000
Compression Type                : Unknown (ima4)

for some reason sudo apt-get install ffmpeg libavcodec-unstripped-52 would not work (Unable to locate package - but Multiverse is enabled)


Solution 1:

Following Toon's Unix Recipes, for example (and the above examples):

sudo apt-get install ffmpeg
ffmpeg -i track1.aiff -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 track1.mp3

(Older versions of Ubuntu can use avconv instead of ffmpeg.)

Solution 2:

Finding this solution here (also recommended in comments), for some reason sudo apt-get install ffmpeg libavcodec-unstripped-52 would not work (Unable to locate package - but Multiverse is enabled).

But in Synaptic I have seen that I had libavcodec53 installed, but not libavcodec-extra-53. Installing the later has uninstalled the former, and then the command ffmpeg -i inputfile.aif -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 outputfile.mp3 worked.

So,

~$ sudo apt-get install libavcodec-extra-53
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libavutil-extra-51 libdirac-encoder0 libopencore-amrnb0 libopencore-amrwb0
  libopenjpeg2 libvo-aacenc0 libvo-amrwbenc0 libx264-123
The following packages will be REMOVED:
  libavcodec53 libavutil51
The following NEW packages will be installed:
  libavcodec-extra-53 libavutil-extra-51 libdirac-encoder0 libopencore-amrnb0
  libopencore-amrwb0 libopenjpeg2 libvo-aacenc0 libvo-amrwbenc0 libx264-123
0 upgraded, 9 newly installed, 2 to remove and 0 not upgraded.
Need to get 7,656 kB of archives.

After this, other commands and actions are now working, including those to convert to mp3, like avconv -i %f %f.mp3. To see that in Terminal, I have added to Thunar custom actions: gnome-terminal --window-with-profile=new1 -e "avconv -i %f %f.mp3". (In Gnome Terminal, create a new profile called "new1" and edit it ('Edit/Profiles/Title and Command') to 'When command exits: Hold the Terminal open'.)

Even after this, the aif files cannot be played by Totem, Parole, Xine, DeaDBeeF, Banshee or VLC; even in Audacity the sound is badly distorted, just like in Audacious. But mplayer (SMPlayer, Gnome Player, Mplayer) can play them just fine.

Solution 3:

There is one more program named assoundconverter and you can install it with your terminal
sudo apt-get install soundconverter .

from the EDIT -> Preferences options you can customize it as you want. enter image description here

This will convert any format to mp3 and other. hope that helps.

Solution 4:

To convert to FLAC:

flac [INPUTFILE]

(If you find flac isn’t installed: sudo apt-get install flac.)

flac man page here, showing options.


Similarly, in order to convert to mp3:

sudo apt-get install lame

lame [inputfile]