FFmpeg can pull the audio out of a video with one command, for example to keep only the sound of a meeting recording or to turn a video into an MP3. The main choice is between copying the audio as it is (no quality loss) and re-encoding it into another format.

Command Examples

1. Fastest: Lossless Copy (Zero Quality Loss)

This saves the audio in its original codec without re-encoding. It is the fastest method, and the quality does not change.

# Extract AAC from MP4 as .aac
ffmpeg -i input.mp4 -vn -c:a copy output.aac

# Same content as .m4a (better compatibility with Windows/phones)
ffmpeg -i input.mp4 -vn -c:a copy output.m4a
  • -vn — leave the video out of the output
  • -c:a copy — copy the audio data as it is, without decoding or encoding

2. Convert to MP3 (libmp3lame)

This re-encodes the audio to MP3, whatever the source format.

# VBR MP3 — best quality (recommended)
ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 0 output.mp3

# CBR MP3 at 320 kbps
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 320k output.mp3

# CBR MP3 at 128 kbps (smaller file)
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 128k output.mp3
  • -q:a 0 — quality for variable bitrate (VBR), from 0 to 9; lower is better, and 0 is the best
  • -b:a 320k — fixed (constant) bitrate

3. Extract as AAC

# AAC at 192 kbps (music / high quality)
ffmpeg -i input.mkv -vn -c:a aac -b:a 192k output.aac

# AAC at 128 kbps (general use)
ffmpeg -i input.mp4 -vn -c:a aac -b:a 128k output.aac

4. Extract as FLAC (Lossless Compressed)

# FLAC: lossless compression — ideal for archiving from PCM or lossless source
ffmpeg -i input.mkv -vn -c:a flac output.flac

5. Extract as WAV (Uncompressed PCM)

# 16-bit PCM WAV (standard)
ffmpeg -i input.mp4 -vn -c:a pcm_s16le output.wav

# 24-bit PCM WAV (high-quality recording / DAW use)
ffmpeg -i input.mp4 -vn -c:a pcm_s24le output.wav

6. Extract a Specific Time Range

# Lossless copy from 1:00 to 2:00
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -vn -c:a copy clip_audio.aac

# Re-encode 60 seconds starting at 30s as MP3
ffmpeg -ss 30 -i input.mp4 -t 60 -vn -c:a libmp3lame -q:a 2 output.mp3

7. Select a Specific Audio Track

# List all audio tracks
ffprobe -v quiet -select_streams a \
  -show_entries stream=index,codec_name,tags:stream_tags=language \
  -of default input.mkv

# Extract first audio track (0:a:0); .mka accepts any audio codec
ffmpeg -i input.mkv -map 0:a:0 -c:a copy track1.mka

# Extract second audio track (0:a:1 — e.g., English dub)
ffmpeg -i input.mkv -map 0:a:1 -c:a copy track2.mka

8. Batch Audio Extraction

for f in *.mp4; do
  ffmpeg -i "$f" -vn -c:a libmp3lame -q:a 2 "${f%.mp4}.mp3" -y
done

Format Comparison Table

Format Codec Compression File Size Best For
.aac / .m4a AAC Lossy Small General use, phone compatibility
.mp3 MP3 Lossy Small Plays almost everywhere: music, podcasts
.flac FLAC Lossless Medium Music archives, lossless storage
.wav PCM Uncompressed Large DAWs, audio editing, professional
.ogg Vorbis Lossy Small Games, web streaming
.opus Opus Lossy Smallest Low bitrate with high quality

Lossless Copy vs. Re-Encoding

Condition Recommendation
Output codec unchanged (AAC→AAC, etc.) -c:a copy (lossless, fast)
Output codec changes (AAC→MP3, etc.) Re-encode
Need different bitrate or sample rate Re-encode
Need filters (normalize, denoise, etc.) Re-encode

Copying keeps the audio exactly as it is. Re-encoding lossy audio (MP3, AAC) to another lossy format loses some more quality (generation loss). If the codec does not need to change, copy.

Container/Codec Compatibility

Input Container Audio Codec Compatible Lossless Output
.mp4 AAC .aac, .m4a
.mkv FLAC .flac
.mkv AAC .aac, .m4a
.avi MP3 .mp3
.mov AAC .aac, .m4a

Option Reference

Option Meaning Recommended Value
-vn Exclude video stream from output Always include for audio extraction
-c:a copy Lossless audio copy When codec stays the same
-c:a libmp3lame MP3 encoder For MP3 output
-q:a N VBR quality (0–9) 0 (best) to 2 (high quality)
-b:a Nk Fixed audio bitrate Music: 192k–320k / Voice: 64k–128k
-ac N Change channel count 1 (mono), 2 (stereo)
-ar N Change sample rate 44100 (CD), 48000 (video standard)
-map 0:a:N Select N-th audio track 0:a:0 (first track)

Troubleshooting

Problem 1: -c:a copy Errors Out (Container Incompatibility)

Symptom: Invalid audio stream. Exactly one MP3 audio stream is required. or Could not write header (incorrect codec parameters ?): Invalid argument
Cause: The output format cannot hold the input codec (for example, copying AAC into .mp3).
Fix:

# Check the actual codec first
ffprobe -v quiet -select_streams a -show_entries stream=codec_name input.mp4

# Use a compatible output extension for AAC
ffmpeg -i input.mp4 -vn -c:a copy output.aac  # not .mp3

Problem 2: Unknown encoder 'libmp3lame'

Cause: Your FFmpeg build does not include the libmp3lame encoder.
Fix: Install an FFmpeg build that includes it:

sudo apt install ffmpeg       # Ubuntu/Debian
brew install ffmpeg           # macOS

Problem 3: Extracted Audio Duration Is Off

Cause: With -ss before -i, FFmpeg jumps to the keyframe before the requested position, so the clip can start earlier than you asked.
Fix: Put -ss after -i for accurate seeking (slower, but precise), or re-encode instead of using -c:a copy.

Problem 4: Audio Came Out as Mono

Cause: The source was recorded in mono, or -ac 1 was passed by mistake.
Fix:

# Check input channel count
ffprobe -v quiet -select_streams a -show_entries stream=channels input.mp4

# Force stereo output
ffmpeg -i input.mp4 -vn -c:a aac -ac 2 output.aac

Problem 5: WAV File Is Enormous

Cause: WAV is uncompressed PCM, about 10 MB per minute at 44100 Hz, 16-bit stereo.
Fix: Use FLAC to compress without loss, or MP3 for lossy compression:

# Lossless compression with FLAC
ffmpeg -i input.mp4 -vn -c:a flac output.flac

FAQ

Q1. Should I always prefer lossless copy?
A. Yes, when the codec does not need to change. -c:a copy loses no quality and is much faster than re-encoding. Re-encode only when you need a different format or bitrate, or want to apply audio filters.

Q2. Does converting MP4 to MP3 degrade quality?
A. Yes. The audio in an MP4 is usually AAC. Converting it to MP3 means decoding the AAC and encoding it again, which loses some quality (generation loss). To keep the loss small, use -q:a 0 (best VBR) or -b:a 320k (high fixed bitrate).

Q3. How do I find how many audio tracks a video has?
A. Run this. Each codec_type=audio line it prints is one audio track:

ffprobe -v quiet -show_entries stream=index,codec_name,codec_type -of default input.mkv | grep audio

Q4. Can I normalize the audio volume during extraction?
A. Yes. Add the loudnorm filter. In a single pass like this, loudnorm raises the sample rate to 192 kHz, so set the output rate with -ar 48000:

ffmpeg -i input.mp4 -vn -af loudnorm=I=-16:LRA=11:TP=-1.5 -ar 48000 -c:a aac -b:a 192k output.aac

Q5. An app won’t open my .aac file — what should I do?
A. Use .m4a instead. It is the same AAC audio in an MPEG-4 container, which Windows Media Player and most apps play without extra software:

ffmpeg -i input.mp4 -vn -c:a copy output.m4a