Convert flac to aac with ffmpeg

I write this so I don't forget (Original Superuser thread)
  • Install ffmpeg with libfaac support
    brew reinstall ffmpeg --with-faac;
  • Convert them
    cd flac_directory
    for f in *.flac; do ffmpeg -i "$f" -acodec libfaac -aq 400 "${f%flac}m4a"; done
Certain files will throw an error: [libx264 @ 0x2f08120] height not divisible by 2 (500x489) In such case adding the following option did the trick for me:
-vf "scale=640:-2"
Taken from Stackoverflow - Maintaining ffmpeg aspect ratio