Videos-to-MP3
EN
Advanced

FFmpeg: extract audio from video – the commands you need

Copy-paste FFmpeg commands to extract audio to MP3, M4A, WAV or FLAC, copy without re-encoding, trim, choose a track, normalize volume and batch-convert folders.

FFmpeg is the free, open-source Swiss army knife of audio and video, and the engine running behind Videos-to-MP3. If you are comfortable with a terminal, it lets you extract audio offline, without size limits, and automate everything. Here are the commands that cover 95 % of needs.

Install FFmpeg

  • Windows: winget install ffmpeg (or download a build from ffmpeg.org and add it to PATH).
  • macOS: brew install ffmpeg.
  • Linux: sudo apt install ffmpeg (Debian/Ubuntu) or sudo dnf install ffmpeg (Fedora).

Check the installation with ffmpeg -version.

Look inside the file first

ffprobe -v error -show_entries stream=index,codec_type,codec_name,bit_rate,channels -of compact video.mp4

This shows each stream: you will see, for example, codec_type=audio|codec_name=aac|bit_rate=128000|channels=2. Knowing the codec tells you whether you can copy it without re-encoding.

Extract to MP3

ffmpeg -i video.mp4 -vn -c:a libmp3lame -b:a 192k audio.mp3
  • -vn: no video.
  • -c:a libmp3lame: LAME MP3 encoder.
  • -b:a 192k: constant bitrate of 192 kbps (use 128k, 256k or 320k as needed).

Variable bitrate (better quality per megabyte):

ffmpeg -i video.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3

-q:a 0 is the best quality (≈ 245 kbps), 2 ≈ 190 kbps, 4 ≈ 165 kbps.

Copy the audio without re-encoding

If the video contains AAC (the case for most MP4 and MOV files), put it in an M4A container – instant and lossless:

ffmpeg -i video.mp4 -vn -c:a copy audio.m4a

Same idea for Opus inside WEBM: ffmpeg -i video.webm -vn -c:a copy audio.opus. If FFmpeg reports an error, the codec does not fit the container – re-encode instead.

WAV and FLAC

ffmpeg -i video.mp4 -vn -c:a pcm_s16le audio.wav
ffmpeg -i video.mp4 -vn -c:a flac audio.flac

Add -ar 44100 to resample to 44.1 kHz (CD standard) or -ac 1 to make it mono.

Keep only part of the audio

ffmpeg -ss 00:01:30 -to 00:02:45 -i video.mp4 -vn -b:a 192k extract.mp3

Placing -ss before -i makes seeking fast. Use -t 30 instead of -to to specify a duration (30 seconds).

Choose an audio track

Films in MKV often contain several languages. Tracks are numbered from 0:

ffmpeg -i film.mkv -map 0:a:1 -vn -b:a 192k second-track.mp3

Normalize the volume

ffmpeg -i lecture.mp4 -vn -af loudnorm=I=-16:TP=-1.5:LRA=11 -b:a 128k lecture.mp3

This targets −16 LUFS, the usual loudness for podcasts and streaming. It is the same filter as the “Normalize volume” option of our converter.

Convert a whole folder

macOS / Linux (bash or zsh):

for f in *.mp4; do ffmpeg -i "$f" -vn -b:a 192k "${f%.*}.mp3"; done

Windows (Command Prompt):

for %f in (*.mp4) do ffmpeg -i "%f" -vn -b:a 192k "%~nf.mp3"

Windows (PowerShell):

Get-ChildItem *.mp4 | ForEach-Object { ffmpeg -i $_.FullName -vn -b:a 192k "$($_.BaseName).mp3" }

Add tags

ffmpeg -i video.mp4 -vn -b:a 192k -metadata title="Live at the park" -metadata artist="My Band" -id3v2_version 3 audio.mp3

Common errors

  • “Output file #0 does not contain any stream”: the video has no audio track.
  • “Could not find tag for codec … in stream”: you used -c:a copy with an incompatible container – remove it to re-encode.
  • “Unknown encoder 'libmp3lame'”: your FFmpeg build lacks LAME; install a full build.

Not in the mood for a terminal? Videos-to-MP3 runs these same commands for you, in your browser.

Questions & answers

How do I extract audio with FFmpeg without losing quality?

Use -c:a copy with a compatible container: .m4a for AAC, .opus or .ogg for Opus/Vorbis, .mp3 for MP3.

What does -vn mean in FFmpeg?

“Video none”: it tells FFmpeg not to include any video stream in the output.

How do I convert to MP3 at 320 kbps with FFmpeg?

ffmpeg -i in.mp4 -vn -c:a libmp3lame -b:a 320k out.mp3

Ready to extract your audio?

Free, no signup, files deleted right after conversion.

MKV to MP3 →