Extract audio from a video
Pulls just the audio track out of a video file in seconds by stream-copying it into a new container, with no re-encoding or quality loss.
Last updated
ffmpeg -i input.mp4 -vn -c:a copy output.m4a
How it works
-vn ("no video") drops the video stream entirely, so ffmpeg only has to deal with audio. -c:a copy then copies the audio codec's bitstream as-is instead of decoding and re-encoding it — for an MP4 with AAC audio, that means remuxing into an .m4a container (also MPEG-4-based) takes seconds and loses nothing, versus a full re-encode that would take much longer and degrade quality slightly.
The .m4a extension matters here: it's the same container family as MP4, so it can hold the AAC stream directly. Pairing -c:a copy with an incompatible container (like .mp3) fails outright, because that format can't store an AAC bitstream verbatim.
Watch out for
- →If you actually need an MP3 file, drop -c:a copy and re-encode instead: ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3 — that's a real transcode, not a copy, so it takes longer and is technically lossy.
- →A source with multiple audio tracks (alternate languages, commentary) gets only the first one by default — add -map 0:a:0 (or the index you want) to pick a specific track explicitly.
- →This fails immediately, with no output file, if the source has no audio stream at all — expected behavior, but worth knowing before assuming something's broken.