Convert mp3 to wav using FFmpeg for VBR

aacaudioaudio conversionffmpegmp3

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?

Best Answer

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 variable bitrate, since each sample takes 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