Converting WAV to MP3

I keep forgetting this, so here it is for all posterity:

afconvert -f mp4f -d aac -b 128000 input.wav output.mp3

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:

# command line test:
# 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

  • Peter DulliƤ

    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.

blog comments powered by Disqus