Different jobs need different audio formats: WAV for importing into an editor, AAC or MP3 for sharing, and FLAC for archiving.
1. Overview of Major Audio Formats
| Format | Type | Characteristics |
|---|---|---|
| WAV | Uncompressed / Lossless | Highest quality, large file size. Suitable for editing |
| FLAC | Lossless compressed | Same quality as WAV, smaller file size |
| MP3 | Lossy compressed | High compatibility, small file size |
| AAC | Lossy compressed | More efficient than MP3, widely used in MP4/M4A |
Lossy formats (MP3, AAC) throw away part of the audio to make the file smaller, and the original quality cannot be restored. Lossless formats (WAV, FLAC) keep everything, so they do not lose quality no matter how often you encode and decode them.
2. Convert WAV to MP3
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3
-c:a libmp3lame: use the LAME MP3 encoder-q:a 2: variable bitrate (VBR) quality, from 0 to 9. Lower numbers mean higher quality
For a fixed bitrate, use -b:a instead:
ffmpeg -i input.wav -c:a libmp3lame -b:a 192k output.mp3
3. Convert WAV to AAC
ffmpeg -i input.wav -c:a aac -b:a 192k output.aac
-c:a aac: FFmpeg’s built-in AAC encoder-b:a 192k: sets the bitrate to 192 kbps and turns on constant bitrate (CBR) mode
A .aac file is a bare AAC stream. For an M4A file, which plays in iTunes and on Apple devices, use the .m4a extension:
ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a
4. Convert MP3 to FLAC (Lossy to Lossless — Important Note)
ffmpeg -i input.mp3 -c:a flac output.flac
The command works, but converting MP3 (lossy) to FLAC (lossless) does not bring back any quality. FLAC stores exactly what it receives, and the MP3 has already thrown data away. The FLAC file is larger, yet it sounds the same as the MP3.
A lossless format only helps when the source is lossless too, for example WAV to FLAC. Converting MP3 or AAC to FLAC for archiving is usually not worth it.
5. Convert FLAC to AAC
ffmpeg -i input.flac -c:a aac -b:a 256k output.aac
Going from lossless to lossy is fine. It is the usual way to make a small file from a high-quality source for sharing or distribution.
6. Convert MP3 to WAV
ffmpeg -i input.mp3 -c:a pcm_s16le output.wav
pcm_s16le is uncompressed 16-bit audio (PCM), the standard WAV format. Editing software and DAWs (music production programs) can import it directly. The quality the MP3 lost does not come back.
7. Difference Between -b:a (CBR/ABR) and -q:a (VBR)
-b:a: Bitrate Specification
ffmpeg -i input.wav -c:a libmp3lame -b:a 128k output.mp3
-b:a sets the bitrate in bits per second. With the AAC encoder, setting -b:a turns on constant bitrate (CBR) mode. Use it when you need to know and control the file size in advance.
-q:a: VBR Quality Specification
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3
-q:a sets a quality level and lets the bitrate vary (VBR). Complex passages get more bits and simple ones fewer, which often gives a smaller file for the same perceived quality. For libmp3lame the range is 0–9, and 0 is the highest quality.
Use -b:a when you need strict control over the file size, and -q:a when quality comes first.
8. Sample Rate Conversion: -ar
-ar changes the sample rate (the number of samples per second).
ffmpeg -i input.wav -ar 44100 -c:a libmp3lame -q:a 2 output.mp3
-ar 44100: sets the output sample rate to 44.1 kHz
Common sample rates:
| Rate | Use Case |
|---|---|
| 44100 | CD quality, general music |
| 48000 | Video, broadcast standard |
| 22050 | Low quality, mobile |
| 16000 | Speech recognition, VoIP |
Without -ar, the output uses the sample rate of the input. If the encoder does not support that rate, FFmpeg converts to one it supports (a 96 kHz WAV becomes 48 kHz as MP3). Leave -ar out when you don’t need a change.
9. Checking Format Before Conversion
Check the audio details of the input file before you convert it:
ffprobe -v error -select_streams a -show_entries stream=codec_name,sample_rate,bit_rate,channels -of default=noprint_wrappers=1 input.mp3
It prints the codec, sample rate, bitrate and number of channels.
Quick Reference: Conversion Patterns
| Source | Target | Example Command (key options) |
|---|---|---|
| WAV | MP3 | -c:a libmp3lame -q:a 2 |
| WAV | AAC | -c:a aac -b:a 192k |
| WAV | FLAC | -c:a flac |
| FLAC | AAC | -c:a aac -b:a 256k |
| MP3 | WAV | -c:a pcm_s16le |
| AAC | MP3 | -c:a libmp3lame -q:a 2 |