Converting WAV to MP3
I keep forgetting this, so here it is for all posterity:
I’m working on Bingueau-Android, and need to change literally hundreds of little wav files to mp3.
And if you want a little command-line Ruby script to do it in batches:
# afconvert -f mp4f -d aac -b 128000 douche.wav douche.mp3
path = "/Users/banane/dev/workspace/bingueau/res/raw/sounds/"
Dir.chdir(path)
Dir.foreach(path) do |entry|
puts entry
system("afconvert -f mp4f -d aac -b 128000 "+entry + " " + entry.gsub(/\.wav/,".mp3"))
puts "Convert a success for: "+entry
end
Comment by Peter Dulliä
Posted on May 11, 2013 at 1:49 pm
Well, this does not create a real MP3 file. You just get a MP4 (AAC) file with a .mp3 extension. It seems Apple does not ship a CLI MP3 encoder with OSX. Unfortunately, afconvert does not cut it.