Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What command should I use to convert a mp3 file to wav whose bitrate is variable. Or better how would I know whether that source audio is fixed bitrate or variable?

share|improve this question
1  
I don't think the WAV file format supports variable bit rates. Since all MP3 decoders must support it to be standards compliant, you should be able to convert any MP3 file into a fixed-bitrate WAV, although your results will vary depending on the quality of the source MP3 and the fixed-bitrate chosen for the WAV created. Most MP3 playing software provides a way to view the properties of the file being played, so you could use one to see what kind of source files you're dealing with. –  martineau Nov 13 '13 at 13:25
    
And what about the command? What do you recommend? –  Soham Dasgupta Nov 13 '13 at 17:27
    
Please read martineau's answer again. I corrected a few mistakes. Notably, you cannot set the bitrate for PCM-encoded WAV files. –  slhck Nov 14 '13 at 18:18

1 Answer 1

up vote 2 down vote accepted

You can get some info about the bitrate of your input files by using the ffprobe song.mp3 command. However this only tells you bitrate of the first frame. VBR in MP3 files is usually implemented simply by changing the bitrate for each frame, so whether it's being used can't be determined by just reading the header of first frame. I usually use some other audio file player software to determine whether VBR is being used, as many will display that (Foobar2000 does for example).

When you use lossy output codecs (such as MPEG-1 Layer III or AAC), ffmpeg chooses a default bitrate for the output stream, or a variable bitrate. It depends on the encoder itself.

For lossless codecs, you cannot set a bitrate, since each sample will take a predefined number of bits. ffmpeg -i song.mp3 song.wav will therefore get you a PCM-encoded WAV file with 44,100 Hz sample rate and 16 bits per sample. This results in about 1411 kBit/s for the entire container, likely much, much bigger than the MP3 input file.

If you want a smaller file size for the PCM-encoded WAV file, set a sample format with less bit depth (see -encoders option for a complete list of them) and/or choose a lower sample rate (-ar 22050 would use 22.05 kHz for example).

Here's an example of doing both:

ffmpeg -i song.mp3 -acodec pcm_u8 -ar 22050 song.wav
share|improve this answer
1  
If you encode PCM audio in a WAV container, you cannot set the bitrate. That does not make sense. PCM is an uncompressed format — you can't tell it to use more or fewer bits per second. The only way to adjust the size is to use a different sample size (see -sample_fmts option). -ar 128k means that the sample rate will be 128,000 Hz, instead of the usual 44,1 or 48 kHz. –  slhck Nov 14 '13 at 18:12
    
@slhck: Thanks for the corrections. –  martineau Nov 14 '13 at 20:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.