Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a .mp3 file and need to convert that to an 1 channel 8kHz 8 bit wav file, anyone know how I can do that with mplayer ? If not, any other commandline tools I could use ?

share|improve this question
    
That might be obvious, but keep in mind that you cannot regain the quality that was lost when it the mp3 compression was applied. – ℝaphink Jan 12 '10 at 9:57
up vote 14 down vote accepted

ffmpeg should do the job. This line will convert to 8kHz 1 channel wav file.

ffmpeg -i input.mp3 -ar 8000 -ac 1 output.wav

http://ffmpeg.org/ffmpeg-doc.html#SEC11

I'm not sure about the 8 bits requirement - what are you referring to? It's not the bitrate surely?

share|improve this answer
    
it's the bits-per-sample, analagous to the color depth of a picture. CDDA-style PCM (std WAV) is 16-bit 44.1kHz stereo; he wants output of 8-bit 8kHz mono. – quack quixote Jan 12 '10 at 10:02
    
8 bit per sample – anonym Jan 12 '10 at 10:06
    
In that case the line should be: ffmpeg -i input.mp3 -ar 8000 -ac 1 -acodec pcm_u8 output.wav – Iain Jan 12 '10 at 10:14

lame, the command-line WAV to MP3 encoder, can also decode MP3 to WAV with the --decode switch.

share|improve this answer
    
As user-friendly tools are concerned, I also like mpg321 for decoding: mpg321 input.mp3 -w output.wav When I tried lame, it got the duration (play time) wrong in the output file, whereas with mpg321 it came out correct. – Jo Liss Jan 31 at 20:43

SoX can also do this; assuming your SoX is compiled with MP3 support, all you'd need is

sox input.mp3 -c 1 -r 8000 -1 output.wav

... although you might run into clipping issues, in which case you'd want to play with the vol and/or mixer effects to decrease the volume of the input channels before the resampling happens.

Without MP3-enabled SoX, use an MP3 decoder to convert your MP3 to WAV first, then the above command becomes:

sox input.wav -c 1 -r 8000 -1 output.wav
share|improve this answer
mplayer -srate 8000 -vo null -vc null -ao pcm:fast:file="$fn.wav" "$fn"

This will also work for extracting the audio track from videos, and any other media file mplayer was configured to handle.

share|improve this answer

protected by slhck Dec 28 '12 at 10:55

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?