Skip to content

Instantly share code, notes, and snippets.

@vunb
Created November 7, 2013 04:52
Show Gist options
  • Star 59 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save vunb/7349145 to your computer and use it in GitHub Desktop.
Save vunb/7349145 to your computer and use it in GitHub Desktop.
Convert mp3 to wave format using ffmpeg
ffmpeg -i input.mp3 -acodec pcm_s16le -ac 1 -ar 16000 output.wav
# To convert all mp3 files in a directory in Linux:
for f in *.mp3; do ffmpeg -i "$f" -acodec pcm_s16le -ac 1 -ar 16000 "${f%.mp3}.wav"; done
# Or Windows:
for /r %i in (*) do ffmpeg -i %i -acodec pcm_s16le -ac 1 -ar 16000 %i.wav
# You can see file information with file, ffmpeg, ffprobe, mediainfo among other utilities:
$ file hjl0bC.wav
hjl0bC.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
$ ffmpeg -i hjl0bC.wav
[...]
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
@vishal516
Copy link

thanks

@rotim
Copy link

rotim commented Sep 6, 2020

probably the most accurate information I've seen in a long time.

@androiddeveloper007
Copy link

i had try it,it works.

@ikequan
Copy link

ikequan commented Oct 22, 2022

thanks

@omermutlu29
Copy link

omermutlu29 commented Jan 19, 2023

Works like a charm!

@kiquenet
Copy link

to convert to WAV file, with attributes A-Law, 8000Hz, 64kbps, mono ?

@fahnub
Copy link

fahnub commented Apr 6, 2023

Thankss

@baibhavKumar1
Copy link

How to use this?

@Adorp94
Copy link

Adorp94 commented May 8, 2023

How to use this?

Hey Wholesomebruh, these were the steps I took:

Converting one file

  1. Open cmd.
  2. Used cd to navigate to the folder with the mp3.
  3. Run the following code:
    ffmpeg -i "C:\path\songname.mp3" -acodec pcm_s16le -ac 1 -ar 16000 output.wav

This will generate a new .wav file on the current folder.

Converting as batch

  1. Open a new text file (notepad).
  2. Paste the following code:
    for %%a in ("C:\path\*.mp3") do ffmpeg -i "%%a" -acodec pcm_s16le -ac 1 -ar 16000 "C:\path\%%~na.wav"
  3. Save your file as .bat
  4. Open cmd and run the file. Use cd to go the folder and the just write the file name and press enter.

@Liknus
Copy link

Liknus commented Jan 17, 2024

@Adorp94 Awesome! Really thanks. It worked flawlessly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment