Audio Format Conversion — WAV, MP3, AAC, and FLAC
Converting audio file formats is one of the most fundamental uses of FFmpeg. Depending on the situation, you may need WAV for importing into an editor, AAC or MP3 for distribution, or FLAC for archival purposes. This article systematically explains the major audio formats and the FFmpeg commands for converting between them.
Tested with: ffmpeg 6.1.1 / Ubuntu 24.04
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) cannot restore the original audio quality once converted. Lossless formats (WAV, FLAC), on the other hand, do not degrade in quality through repeated encode/decode cycles.
2. Convert WAV to MP3
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3
-c:a libmp3lame: Use the LAME-based MP3 encoder-q:a 2: VBR (variable bitrate) quality. Range is 0–9, lower values mean higher quality
To convert with a fixed bitrate, use -b:a:
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 (enables CBR mode)
To output as an M4A container (iTunes / Apple compatible), 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
This command is valid, but converting from MP3 (lossy) to FLAC (lossless) does not restore audio quality. FLAC simply stores the source data faithfully; it cannot recover information already lost through MP3 compression. Despite the larger FLAC file size, the actual audio quality remains that of the original MP3.
Lossless conversion is only meaningful when going from “lossless to lossless” (e.g., WAV to FLAC). Converting MP3 or AAC to FLAC for archival purposes is generally not recommended.
5. Convert FLAC to AAC
ffmpeg -i input.flac -c:a aac -b:a 256k output.aac
Converting from lossless to lossy is technically fine. This is a common workflow for compressing high-quality source audio for distribution or sharing.
6. Convert MP3 to WAV
ffmpeg -i input.mp3 -c:a pcm_s16le output.wav
pcm_s16le is 16-bit little-endian PCM, the standard WAV format. It is suitable for importing into editing software or using directly in a DAW. As noted above, audio quality lost through MP3 compression cannot be recovered.
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
According to the official documentation, -b:a is the option to “set bitrate in bits/s”. For the AAC encoder, setting -b:a automatically enables CBR (constant bitrate) mode. Use this when you need to calculate and control the output file size in advance.
-q:a: VBR Quality Specification
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3
-q:a sets the quality for VBR (variable bitrate) mode. Since the bitrate varies dynamically based on content complexity, it can result in more efficient file sizes for the same perceived quality. For libmp3lame, the valid range is 0–9, where 0 is the highest quality.
Which to use: Use -b:a when you need strict control over output size, and -q:a when quality is the priority.
8. Sample Rate Conversion: -ar
Use -ar when you need to change the sample rate.
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 |
The official documentation states “For output streams it is set by default to the frequency of the corresponding input stream”, so you can omit this option if no change is needed.
9. Checking Format Before Conversion
It is good practice to check the audio information of the input file before running conversion commands.
ffprobe -v error -select_streams a -show_entries stream=codec_name,sample_rate,bit_rate,channels -of default=noprint_wrappers=1 input.mp3
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 |
Related Articles
- Extract Audio from Video — When to Use Lossless Copy vs Re-encode
- What is FFmpeg? — Core Concepts and Use Cases
Tested with: ffmpeg 6.1.1 / Ubuntu 24.04 (GitHub Actions runner)
Primary sources: ffmpeg.org/ffmpeg.html / ffmpeg.org/ffmpeg-codecs.html / ffmpeg.org/ffmpeg-filters.html