FFmpeg recipe
FFmpeg: Extract Audio from an MP4 (Lossless)
Stream-copy extracts the audio without decoding/re-encoding. Bit-identical to the source. Container changes from MP4 to whatever the audio codec's native container is.
Command
ffmpeg -i input.mp4 -vn -c:a copy -y output.m4aPrefer no terminal?
Use the Extract Audio in your browser
What each flag does
| -i | Input file. Can be a video, audio, or image. Repeat for multiple inputs. |
|---|---|
| -vn | Strip video (no video in output) — useful for audio-only extraction. |
| -c:a | Audio codec for output. e.g. aac, libmp3lame, copy. |
| -y | Overwrite output file without confirmation. |
Notes & gotchas
- Most MP4 audio is AAC, so the output extension is .m4a (AAC in MP4 container).
- For MP3 output, re-encode with -c:a libmp3lame -b:a 192k -y output.mp3.
- For WAV output (lossless PCM), use -c:a pcm_s16le -y output.wav.
Check it worked
ffprobe -v error -show_entries stream=codec_name,channels,sample_rate -of csv=p=0 output.aacThe codec you asked for, with the channel count and sample rate matching the source.
What to change
| -c copy means no quality loss | The audio is lifted out untouched. Re-encoding it to MP3 here would throw away quality for nothing. |
|---|---|
| The extension must match the codec | AAC from an MP4 belongs in .m4a. Naming it .mp3 produces a file that many players refuse. |
| Check what is actually in there | ffprobe first. Some files carry AC-3 or Opus, which need a different container again. |
If it fails
Output file is empty or zero bytes.
Why: The input has no audio stream, which is common with screen recordings made without audio capture.
Fix: Check first with ffprobe. If there is no audio stream, there is nothing to extract.
The extension does not match what came out.
Why: -c:a copy keeps whatever codec the video held, which is usually AAC rather than the format your extension implies.
Fix: Either name the file to match the real codec, or re-encode explicitly with -c:a libmp3lame for an MP3.