Extracting audio with FFmpeg
Four commands cover almost everything, and the difference between the first two is the difference between instant and slow.
Free on iPhone and iPad, for the videos already in your camera roll. Works offline; one free conversion, then a subscription.
Four commands cover almost every case, and the difference between the first two is the difference between instant and slow. These are the commands this site runs: the extractor is FFmpeg compiled to WebAssembly, and the argument lists below are what it builds.
1. Take the audio out without re-encoding it
ffmpeg -i video.mp4 -vn -c:a copy audio.m4a
The important flag is -c:a copy: it tells FFmpeg not to decode anything, just to move the audio stream into a new container. -vn drops the picture. On a two-hour film this finishes in seconds, and the audio is identical to what was inside the video.
It only works when the container can hold that codec. AAC goes into .m4a (or .aac), MP3 into .mp3, Opus into .opus, FLAC into .flac. Ask for a mismatch and FFmpeg usually refuses with "could not find tag for codec" — but not always, which is the trap in the last section.
2. Convert to MP3
ffmpeg -i video.mp4 -vn -c:a libmp3lame -b:a 192k audio.mp3
This decodes the soundtrack and encodes it again, so it takes real time and costs a generation. Use -q:a 2 instead of -b:a 192k if you prefer VBR — the file is usually smaller for the same perceived quality.
For speech, this is the version worth knowing:
ffmpeg -i lecture.mp4 -vn -ac 1 -c:a libmp3lame -b:a 64k lecture.mp3
-ac 1 folds to mono, which halves the file again and costs nothing you would notice on a voice.
3. Pick one soundtrack out of several
First look at what is in the file:
ffmpeg -i film.mkv
FFmpeg prints the streams and exits with an error, which is expected — you asked for no output. You will see lines like:
Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1, 448 kb/s
Stream #0:2(deu): Audio: aac (LC), 48000 Hz, stereo, 128 kb/s
Stream #0:3(eng): Audio: aac (LC), 48000 Hz, stereo, 96 kb/s
Then map the one you want. Note that 0:a:1 means "the second audio stream", not "stream 1":
ffmpeg -i film.mkv -vn -map 0:a:1 -c:a copy german.m4a
Getting this wrong is how people end up with a perfectly good extraction of the director's commentary.
4. Take only part of it
ffmpeg -ss 00:01:30 -i video.mp4 -t 30 -vn -c:a copy clip.m4a
-ss before -i seeks first and then opens, which is orders of magnitude faster than seeking after the input is open. -t 30 takes thirty seconds from that point. With -c:a copy the cut lands on the nearest compressed frame — within about a fortieth of a second — because a frame cannot be split without decoding it.
Doing a folder
# macOS / Linux
for f in *.mp4; do ffmpeg -i "$f" -vn -c:a copy "${f%.mp4}.m4a"; done
# Windows PowerShell
Get-ChildItem *.mp4 | ForEach-Object {
ffmpeg -i $_.Name -vn -c:a copy "$($_.BaseName).m4a"
}
The trap worth knowing about
FFmpeg will let you copy an AAC stream into a WAV container:
ffmpeg -i video.mp4 -vn -c:a copy out.wav # exits 0, writes a file, plays nowhere
It exits successfully and produces a file with a WAV header wrapped around AAC frames. Nothing will play it. We hit this while testing, which is why this site keeps its own list of legal copy pairs rather than asking FFmpeg whether a conversion makes sense. If you are scripting, do the same: decide what is legal yourself rather than trusting a zero exit code.
Reading what is inside a file
ffprobe -v error -select_streams a -show_entries stream=index,codec_name,channels,bit_rate:stream_tags=language -of json film.mkv
That prints every audio stream with its codec, channel count, bitrate and language tag as JSON — the same information this site shows in its track picker, which is generated from exactly this data.
The same FFmpeg, without installing it
If you are here because you do not want to install anything, the extractor on this site is the same program compiled to WebAssembly. It builds these commands for you, tells you which of them it is about to run, and runs it in your browser tab with the file mounted rather than uploaded. How that works.
This site is FFmpeg compiled to WebAssembly. The commands below are the ones it runs.