Version 3 (modified by llogan, 6 years ago) (diff)

explicitly use libmp3lame, add tags

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

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

Option -q:a needs a parameter, that tells ffmpeg something about expected "audio quality". This parameter has a different meaning for each audio encoder used, and we are now describing the libmp3lame encoder.

The table for LAME option -V <number> is shown here (and that option is mapped to the -q:a option in ffmpeg): VBR (variable bitrate) settings for LAME.

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

So, in our example above, we selected -q:a 2, meaning we used LAME's option -V 2, which gives a VBR mp3 audio in the approximate range of 170-210 kbit/s.

If you want constant bit rate (CBR) mp3 audio, instead of using -q:a option, you need to use the -b:a option to set the preferred "audio bit rate" in bits per second, like -b:a 256k if you want 256 kbit/s audio.