Convert Audio to MP3 with ffmpeg and libmp3lame
Turn M4A, WAV, or FLAC audio into MP3 files from the terminal with ffmpeg's LAME encoder.
Run ffmpeg -i song.m4a -c:a libmp3lame -q:a 2 song.mp3 to convert any audio file to a high-quality MP3.
01Command
Command
$ ffmpeg -i song.m4a -c:a libmp3lame -q:a 2 song.mp302What it does
ffmpeg reads the input file's format automatically, and -c:a libmp3lame selects the LAME MP3 encoder for the output. The -q:a 2 setting uses a VBR quality scale from 0 (best) to 9 (smallest) — level 2 lands around 190 kbps, which is transparent for most listening. To batch-convert a folder: for f in *.m4a; do ffmpeg -i "$f" "${f%.m4a}.mp3"; done.
03Risk
!Warning: Converting to MP3 is lossy — going from one lossy format (M4A/AAC) to MP3 loses a bit more quality, so keep the original file if you may need it later.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- ffmpeg DocumentationEvidence: The documentation describes -i as the input file option and -c:a as the audio codec selection option used with encoders such as libmp3lame.
- FFmpeg FAQEvidence: The FAQ references the libmp3lame encoder for producing MP3 output files with ffmpeg.
Last verified: 2026-09-19 · Category: Media