Extract audio from a video with FFmpeg
-vn drops the video; the codec you choose decides the rest. Copy the existing AAC when you only need the file, transcode to MP3 or WAV when a tool requires it.
Verified with FFmpeg 9.0.1 on 26 August 2026. Search intent: ffmpeg extract audio.
ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3Keeps only the audio and encodes it with LAME at VBR quality 2, roughly 190 kbps on typical content. The 12 s test file produced a 12.0 s MP3 with the original 48 kHz sample rate.
Flags, explained
- -vn
- Disable video: no video stream is written to the output.
- -c:a libmp3lame
- Encode audio with the LAME MP3 encoder.
- -q:a 2
- LAME variable bitrate quality, 0 (best) to 9. 2 is the usual choice for near-transparent MP3. Use -b:a 192k for a constant bitrate instead.
- -c:a copy
- Copy the audio stream as it is. The output container must accept the codec (.m4a for AAC).
- -c:a pcm_s16le
- Signed 16-bit little-endian PCM, the standard WAV format.
- -ac 1 -ar 16000
- One channel, 16 kHz sample rate.
Variants
Copy the AAC track without re-encoding
ffmpeg -i input.mp4 -vn -c:a copy output.m4aMost MP4 and MOV files already carry AAC audio. Copying it into an .m4a is instant and lossless; the .mp3 extension would not work here because the MP3 container cannot hold AAC.
Uncompressed WAV for editing
ffmpeg -i input.mp4 -vn -c:a pcm_s16le output.wav16-bit PCM at the source sample rate. Large (1.15 MB for 12 s of mono 48 kHz here) but no generation loss.
Mono 16 kHz WAV for speech-to-text
ffmpeg -i input.mp4 -vn -ac 1 -ar 16000 -c:a pcm_s16le speech.wavThe format most transcription models expect. -ac 1 mixes down to mono and -ar 16000 resamples; the test file came out at 16,000 Hz, 1 channel, 384 KB.
Only a section of the soundtrack
ffmpeg -ss 3 -t 5 -i input.mp4 -vn -c:a libmp3lame -q:a 2 segment.mp3-ss and -t before the input select 5 s starting at 3 s. Output duration: 5.000 s.
Opus for the smallest files
ffmpeg -i input.mp4 -vn -c:a libopus -b:a 96k output.opusOpus at 96 kbps sounds as good as MP3 at much higher bitrates, but plays in fewer places (browsers and modern players, not older phones).
Pitfalls we hit
- You cannot copy AAC into an .mp3 file: FFmpeg stops with "Invalid audio stream. Exactly one MP3 audio stream is required." Use .m4a with -c:a copy, or re-encode with libmp3lame.
- Re-encoding AAC to MP3 loses a little quality and gains nothing if you only need the audio in a player. Copy when you can.
- WAV output is large: 16-bit stereo at 48 kHz is about 11.5 MB per minute.
- A video with several audio tracks yields only the first by default. Use -map 0:a:1 to pick the second.
How we verified it
Run with FFmpeg 9.0.1 on 26 August 2026 against a 12 s H.264 file with a mono 48 kHz AAC track. MP3 -q:a 2: mp3, 48,000 Hz, 12.000 s, 51,411 bytes. AAC copy: aac LC, 194,696 bytes. WAV: pcm_s16le, 1,152,078 bytes. Speech WAV: 16,000 Hz, 1 channel, 384,078 bytes. Segment: 5.000 s. Opus 96k: 178,108 bytes. AAC copied to .mp3 failed as described.
The same edit as a typed operation
extract_audio takes a format (mp3, wav or others) and returns the file: the codec, container and bitrate pairing is decided for you, so the AAC-into-MP3 mismatch cannot happen.
{
"inputs": [{ "id": "main", "url": "https://example.com/video.mp4" }],
"options": { "format": "mp3" }
}FAQ
How do I extract audio from a video without losing quality?
Copy the existing stream with -c:a copy into a container that accepts it (.m4a for AAC, .mp3 for MP3). Any re-encode to a lossy format loses something; WAV keeps the decoded audio intact.
What bitrate should the MP3 have?
-q:a 2 (roughly 190 kbps VBR) is transparent for most listeners. Use -q:a 4 or -b:a 128k for speech, -q:a 0 or -b:a 320k when the source is high-quality music.
How do I get audio in the format Whisper or another transcription model wants?
Mono, 16 kHz, 16-bit PCM WAV: the speech variant above. Smaller files transcribe just as well.
Can I extract audio from a specific time range?
Yes: put -ss (start) and -t (duration) or -to (end) before -i, as in the segment variant.
Related commands
- ffmpeg trim videoTrim a video with FFmpegRead
- ffmpeg compress videoCompress a video with FFmpegRead
- ffmpeg mov to mp4Convert MOV to MP4 with FFmpegRead