Here is how to convert any audio file to WAV using ffmpeg.
Step 1:Which PCM output format?
Decide on which PCM format to use. Here is how to get a list:
$ ffmpeg -formats | grep PCM DE alaw PCM A-law DE f32be PCM 32-bit floating-point big-endian DE f32le PCM 32-bit floating-point little-endian DE f64be PCM 64-bit floating-point big-endian DE f64le PCM 64-bit floating-point little-endian DE mulaw PCM mu-law DE s16be PCM signed 16-bit big-endian DE s16le PCM signed 16-bit little-endian DE s24be PCM signed 24-bit big-endian DE s24le PCM signed 24-bit little-endian DE s32be PCM signed 32-bit big-endian DE s32le PCM signed 32-bit little-endian DE s8 PCM signed 8-bit DE u16be PCM unsigned 16-bit big-endian DE u16le PCM unsigned 16-bit little-endian DE u24be PCM unsigned 24-bit big-endian DE u24le PCM unsigned 24-bit little-endian DE u32be PCM unsigned 32-bit big-endian DE u32le PCM unsigned 32-bit little-endian DE u8 PCM unsigned 8-bit
If you don’t know which format to use:
s16le is the most common. You have to put the prefix
pcm_ in front of the chosen value when calling ffmpeg.
Step 2: What sampling rate?
The best option is to use the exact same sampling rate as the input file. You can use the
ffprobe command to get the original value:
$ ffprobe 01.mp3 Input #0, mp3, from '01.mp3': Metadata: title : Sample Title artist : Sample Artist Duration: 00:05:51.71, start: 0.025057, bitrate: 196 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 196 kb/s Metadata: encoder : LAME3.97 Side data: replaygain: track gain - -8.600000, track peak - unknown, album gain - unknown, album peak - unknown,
If you don’t know which value to use,
44100 is very common.
Step 3: Convert
Now that you know all your parameters, you can convert any audio file to WAV using ffmpeg. Here’s an example command:
ffmpeg -i input.mp3 -acodec pcm_s16 -ar 44100 output.wav