This calls for ffmpeg.
C:\enc>ffmpeg -acodec pcm_s16le -ar 44100 -i "input.mp3" outfile.wav
Input #0, mp3, from 'input.mp3':
Duration: 00:03:52.75, start: 0.000000, bitrate: 255 kb/s
Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 256 kb/s
Output #0, wav, to 'outfile.wav':
Stream #0.0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Of course it also takes CCITT A-Law, CCITT u-Law and almost anything .wav as input.
To downmix to mono, use -ac 1
(as in audio channels=1).
From a Unix-like (Linux, OSX, etc) commandline, ffmpeg can be used like this:
for f in *.wav; do ffmpeg -i "$f" -c:a libmp3lame -q:a 2 "${f/%wav/mp3}" -c:a libvorbis -q:a 4 "${f/%wav/ogg}"; done
This will convert every WAV in a directory into one MP3 and one OGG; note that it's case-sensitive (the above command will convert every file ending in .wav, but not .WAV). If you want a case-insensitive version:
for f in *.{wav,WAV}; do ffmpeg -i "$f" -c:a libmp3lame -q:a 2 "${f%.*}.mp3" -c:a libvorbis -q:a 4 "${f%.*}.ogg"; done
To convert every WAV in a directory recursively (that is: every WAV in the current directory, and all directories in the current directory), you could use find
:
find . -type f -name '*.wav' -exec bash -c 'ffmpeg -i "$0" -c:a libmp3lame -q:a 2 "${0/%wav/mp3}" -c:a libvorbis -q:a 4 "${f/%wav/ogg}' '{}' \;
(Max respect to Dennis for his response here for finding me a working implementation of find with ffmpeg)
For case-insensitive search with find, use -iname
instead of -name
.
A note on -q:a
: for MP3, the quality range is 0-9, where 0 is best quality, and 2 is good enough for most people for converting CD audio; for OGG, it's 1-10, where 10 is the best and 5 is equivalent to CD quality for most people.
Best Answer
If you want to go for a shell solution, you can do it with
ffmpeg
.Option 1: download
ffmpeg
and extract the executableffmpeg
file. Copy it to a directory that is in your executable path, e.g./usr/bin
.Option 2: Use Homebrew and
brew install ffmpeg
.Now, in the folder with the AIF files, run this: