33

Please, help to choose solution for converting any mp3 file to special .wav - I'm a newbie with Linux command line tools, so It's hard for me right now.

I need to get wav with 16khz mono 16bit sound properties from any mp3 file. I was trying

ffmpeg -i 111.mp3 -ab 16k out.wav,

but I got wav with the same rate as mp3 (22k).

Please, help to construct right command line

Alve
  • 1,077
  • 2
  • 15
  • 16

2 Answers2

73

kdazzle's solution is almost there - it still output a stereo wav, here is a slightly modified version that generate mono:

ffmpeg -i 111.mp3 -acodec pcm_s16le -ac 1 -ar 16000 out.wav

also, if this is for pre-processing speech data for sphinx 4 see here: Convert audio files for CMU Sphinx 4 input

Community
  • 1
  • 1
Bill
  • 921
  • 8
  • 13
  • will this mix both channels or just split and use the 1st one? – Aquarius Power Dec 07 '14 at 20:51
  • 1
    This will mix the two channels into one - I just confirmed it. BTW, looks like on current Ubuntu 14.10, ffmpeg is now renamed to avconv – Bill Dec 08 '14 at 15:54
  • 1
    if needed, we must balance the channels before the mix as one may become too low volume, but in general it works great! – Aquarius Power Dec 08 '14 at 16:32
  • Here's some more info on how ffmpeg handles manipulating audio channels: https://trac.ffmpeg.org/wiki/AudioChannelManipulation – siannopollo Oct 21 '16 at 18:37
  • Can't get this working for some reason, the -ar changes Hz no problem, but -acodec pcm_s16e doesn't seem to do anything – Garglesoap Aug 10 '19 at 19:30
  • looks like current ffmpeg (4.1.3) defaults to pcm_s16le output audio codec - i just tested both versions (with or without -acodec pcm_s16le) and compared the output file formats to be the same. thanks for pointing this out! – Bill Aug 11 '19 at 01:54
8

Try this:

ffmpeg -i 111.mp3 -acodec pcm_s16le -ar 16000 out.wav
kdazzle
  • 3,943
  • 3
  • 21
  • 25