Use ffmpeg to transcode .wav to .aac files in bulk

In order to reduce the size of local data for my recent iPhone application, I have to transcode the voice files from .wav to .aac extension. We all know that by using iTunes we could easily convert .wav files to .m4a as long as we change the Import Settings of iTunes’ Preference. Well, an .aac file is the raw data inside a .m4a container, as described here. Command lines are easy to use, however, my problem is I need something to transcode a lot of files all at once.

The following .bat files is the one I used to do so all at once for the following file directory:

for %%A IN (*.wav) DO ffmpeg -i "%%A" "b\%%A.aac"

The generated .aac files are all saved inside ¥b directory, which is something like the following.

a
|_mycmd.bat
|_ffmpeg.exe
|_x.wav
|_y.wav
|:
|:
|_b
  |_x.wav.aac
  |_y.wav.aac

After the transcoding, the ¥b directory contains all the .aac files, however, they all have a .wav.aac at the end of their names. To solve this problem, I used a command line ‘rename’, because all my file names are in regular expressions. If not, you have to use another .bat file to rename the files.

ffmpeg is a quite a good tool to transform lots of sound files to other format, unbelievable easy to use and handy.

Leave a Comment