wiki:

Encode

/

MP3


Version 4 (modified by slhck, 4 years ago) (diff)

copyedit

To encode VBR MP3 audio with ffmpeg, using the libmp3lame library, we would specify a command like this:

ffmpeg -i input.wav -codec:a libmp3lame -q:a 2 output.mp3

The option -q:a needs a parameter that tells ffmpeg what audio quality we expect. This parameter has a different meaning for each audio encoder used, and we are now describing the libmp3lame encoder.

The table for the LAME -V option is shown in the following. The option is mapped to -q:a in ffmpeg.

Switch Kbit/s Bitrate range kbit/s
-b 320 320 320 CBR
-V 0 245 220...260
-V 1 225 190...250
-V 2 190 170...210
-V 3 175 150...195
-V 4 165 140...185
-V 5 130 120...150
-V 6 115 100...130
-V 7 100 80...120
-V 8 85 70...105
-V 9 65 45...85

In our example above, we selected -q:a 2, meaning we used LAME's option -V 2, which gives us a VBR MP3 audio stream with an average stereo bitrate of 170–210 kBit/s.

If you need constant bitrate (CBR) MP3 audio, you need to use the -b:a option instead of -q:a. Here you can specify the number of bits per second, for example -b:a 256k if you want 256 kBit/s audio.