Encode MP3 with ffmpeg

MP3 encoding modes and practical ffmpeg commands.

MP3 Bitrate Modes

MP3 encoding usually uses one of three bitrate modes: VBR, ABR, and CBR.

CBR (Constant Bitrate)

CBR means the bitrate is fixed over time.
For example, with 128 kbps CBR, each second is encoded at 128 kb. File size is predictable.

VBR (Variable Bitrate)

VBR has no fixed bitrate. The encoder dynamically uses higher bitrate for complex audio and lower bitrate for simple parts.
This often gives better quality/size balance.

ABR (Average Bitrate)

ABR targets an average bitrate. It is a compromise between CBR and VBR.
Compared with CBR at the same nominal bitrate, ABR usually gives better quality at similar size.

Use ffmpeg to Encode

Variable bitrate (VBR)

1
2
3
4
5
6
7
8
ffmpeg -i sample.wav -vn -c:a libmp3lame -aq 4 -ac 2 sample.mp3

# Notes:
# -i   input file
# -vn  disable video
# -c:a audio codec (copy / libmp3lame / aac ...)
# -aq  VBR quality; smaller value usually means better quality and larger file
# -ac  channel count

Constant bitrate (CBR)

1
2
3
ffmpeg -i sample.wav -vn -c:a libmp3lame -b:a 192k -ac 2 sample.mp3

# -b:a fixed audio bitrate

Remove metadata

1
2
3
ffmpeg -i sample.wav -map_metadata -1 -vn -c:a libmp3lame -aq 8 -ac 2 sample.mp3

# -map_metadata -1 removes metadata
记录并分享
Built with Hugo
Theme Stack designed by Jimmy