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.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

1 Comment »

  1. 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.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>