← All posts

How to Extract Audio from Video with FFmpeg

Learn to extract audio from video using FFmpeg — convert to MP3, AAC, FLAC, WAV, control bitrate, handle multi-track audio, and preserve metadata.

FFHub·2026-04-24
How to Extract Audio from Video with FFmpeg

Extracting audio from video with FFmpeg is straightforward — convert to MP3, AAC, FLAC, WAV, or Opus with full control over bitrate, sample rate, and metadata. Whether you're pulling a podcast from a video recording, ripping a music track, or extracting dialogue for transcription, this guide covers every scenario you'll hit.

Try it in your browser

Drop a video, pick a format (MP3 / AAC / FLAC / WAV), download the audio. No FFmpeg installation, runs in browser.

Basic Audio Extraction

The simplest extraction uses stream copy to pull audio without re-encoding:

# Extract audio without re-encoding (keeps original format)
ffmpeg -i input.mp4 -vn -c:a copy output.aac
  • -vn disables video recording (extracts audio only)
  • -c:a copy copies the audio stream as-is (no quality loss, instant)

You need to know the source audio format to pick the right extension (if you're unfamiliar with FFmpeg, check out our beginner's guide to FFmpeg first). Check it first:

# Check what audio codec the video uses
ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=nw=1 input.mp4

This might output codec_name=aac, telling you to use .aac or .m4a as the extension.

Extract to Specific Formats

MP3 — Universal Compatibility

# Extract to MP3 at 192 kbps
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k output.mp3

# Extract to MP3 using VBR quality (recommended)
ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3

MP3 VBR quality scale: 0 (best, ~245 kbps) to 9 (worst, ~65 kbps). A value of 2 (~190 kbps) is a good balance. If you also need to convert between video formats, the same codec and bitrate concepts apply.

AAC — Best for Apple and Web

# Extract to AAC at 192 kbps
ffmpeg -i input.mp4 -vn -c:a aac -b:a 192k output.m4a

# Higher quality AAC
ffmpeg -i input.mp4 -vn -c:a aac -b:a 256k output.m4a

Opus — Best Quality per Bit

Opus delivers superior audio quality at lower bitrates, especially for speech.

# Extract to Opus at 128 kbps (excellent quality)
ffmpeg -i input.mp4 -vn -c:a libopus -b:a 128k output.opus

# Opus for speech content (lower bitrate is fine)
ffmpeg -i input.mp4 -vn -c:a libopus -b:a 64k output.opus

FLAC — Lossless Compression

# Extract to FLAC (lossless, smaller than WAV)
ffmpeg -i input.mp4 -vn -c:a flac output.flac

WAV — Uncompressed

# Extract to WAV (PCM 16-bit)
ffmpeg -i input.mp4 -vn -c:a pcm_s16le output.wav

# Extract to WAV (PCM 24-bit for higher precision)
ffmpeg -i input.mp4 -vn -c:a pcm_s24le output.wav

Format Comparison

FormatTypeQuality at 128 kbpsFile SizeBest For
MP3LossyGoodSmallUniversal playback
AACLossyBetterSmallApple, web, streaming
OpusLossyExcellentSmallestWeb, VoIP, podcasts
VorbisLossyGoodSmallOpen-source projects
FLACLosslessPerfectMediumArchiving, audiophiles
WAVUncompressedPerfectLargeEditing, production
ALACLosslessPerfectMediumApple ecosystem

Bitrate and Quality Settings

Choosing the Right Bitrate

The ideal bitrate depends on the content type and target format:

ContentMP3AACOpus
Speech/podcasts96-128 kbps64-96 kbps48-64 kbps
Music (casual)192 kbps128 kbps96-128 kbps
Music (high quality)320 kbps256 kbps160-192 kbps
ArchivingUse FLACUse FLACUse FLAC

Sample Rate Control

You can change the sample rate during extraction:

# Downsample to 22050 Hz (suitable for speech)
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 96k -ar 22050 output.mp3

# Keep standard CD quality (44100 Hz)
ffmpeg -i input.mp4 -vn -c:a flac -ar 44100 output.flac

Channel Control

# Convert to mono (good for speech, halves file size)
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 96k -ac 1 output.mp3

# Force stereo output
ffmpeg -i input.mp4 -vn -c:a aac -b:a 192k -ac 2 output.m4a

Extract a Specific Audio Track

Videos can contain multiple audio tracks (different languages, commentary, etc.). Use -map to select a specific one:

# List all streams in the file
ffprobe -v error -show_streams -of json input.mkv | grep -E "index|codec_name|codec_type|language"

# Extract the first audio track (default)
ffmpeg -i input.mkv -map 0:a:0 -c:a copy output_track1.aac

# Extract the second audio track
ffmpeg -i input.mkv -map 0:a:1 -c:a copy output_track2.aac

# Extract all audio tracks as separate files
ffmpeg -i input.mkv -map 0:a:0 track1.mp3 -map 0:a:1 track2.mp3

The syntax 0:a:0 means: first input file (0), audio streams (a), first audio stream (0).

Extract Audio from a Specific Time Range

# Extract audio from 1:30 to 3:45
ffmpeg -i input.mp4 -vn -ss 00:01:30 -to 00:03:45 -c:a libmp3lame -b:a 192k output.mp3

# Extract the first 60 seconds of audio
ffmpeg -i input.mp4 -vn -t 60 -c:a copy output.aac

Place -ss before -i for faster seeking (may be less accurate) or after -i for frame-accurate seeking.

Preserve Metadata

By default, FFmpeg carries over metadata. You can also explicitly control it:

# Extract audio with all metadata preserved
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -map_metadata 0 output.mp3

# Extract audio and add/override metadata
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k \
  -metadata title="Episode 42" \
  -metadata artist="My Podcast" \
  -metadata album="Season 2" \
  -metadata date="2026" \
  output.mp3

# Extract audio and strip all metadata
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -map_metadata -1 output.mp3

Extract and Embed Album Art

# Extract audio with thumbnail from video
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k \
  -c:v copy -disposition:v attached_pic output.mp3

This takes the first video frame (often a thumbnail in music videos) and embeds it as album art.

Batch Extraction

Extract Audio from All Videos in a Directory

# Extract all MP4 files to MP3
for f in *.mp4; do
  ffmpeg -i "$f" -vn -c:a libmp3lame -b:a 192k "${f%.mp4}.mp3"
done

# Extract all video files (mixed formats) to AAC
for f in *.mp4 *.mkv *.avi *.mov; do
  [ -f "$f" ] || continue
  name="${f%.*}"
  ffmpeg -i "$f" -vn -c:a aac -b:a 192k "${name}.m4a"
done

Batch Extract with Quality Presets

#!/bin/bash
# Extract audio from all videos in current directory
# Usage: ./extract_audio.sh [quality]
# quality: low (96k), medium (192k), high (320k), lossless

QUALITY="${1:-medium}"

case "$QUALITY" in
  low)     CODEC="-c:a libmp3lame -b:a 96k";  EXT="mp3" ;;
  medium)  CODEC="-c:a libmp3lame -b:a 192k"; EXT="mp3" ;;
  high)    CODEC="-c:a libmp3lame -b:a 320k"; EXT="mp3" ;;
  lossless) CODEC="-c:a flac";                 EXT="flac" ;;
esac

for f in *.mp4 *.mkv *.avi *.mov *.webm; do
  [ -f "$f" ] || continue
  echo "Extracting: $f"
  ffmpeg -i "$f" -vn $CODEC "${f%.*}.$EXT"
done

Volume Adjustment During Extraction

You can normalize or adjust volume while extracting:

# Increase volume by 50%
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -af "volume=1.5" output.mp3

# Decrease volume by half
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k -af "volume=0.5" output.mp3

# Normalize audio loudness (EBU R128 standard)
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k \
  -af "loudnorm=I=-16:TP=-1.5:LRA=11" output.mp3

The loudnorm filter is especially useful for podcast and speech content where consistent loudness matters. For more on optimizing media file sizes, see our video compression best practices.

Extract Audio from Streaming URLs

FFmpeg can extract audio directly from URLs:

# Extract audio from a direct video URL
ffmpeg -i "https://example.com/video.mp4" -vn -c:a libmp3lame -b:a 192k output.mp3

Troubleshooting

"Stream copy" produces a file that won't play — The extracted codec may not be supported in the chosen container. For example, extracting Opus audio to .mp3 won't work with -c:a copy. Use the correct extension or re-encode.

Output audio is silent — The video might have multiple audio tracks, and the default one is empty. Use ffprobe to identify tracks, then -map to select the correct one.

"Discarding packet" warnings — Usually harmless, but if audio is corrupted, try re-encoding instead of stream copy.

Audio and timestamps are out of sync — Add -async 1 to fix timing issues:

ffmpeg -i input.mp4 -vn -async 1 -c:a libmp3lame -b:a 192k output.mp3

Summary

  • Use -c:a copy to extract without re-encoding (fastest, lossless)
  • Choose MP3 for universal compatibility, Opus for best quality, FLAC for lossless
  • Use ffprobe to inspect audio tracks before extraction
  • Use -map 0:a:N to select a specific audio track
  • Apply -af loudnorm to normalize volume for consistent playback
  • Use batch scripts to process entire directories at once
Try it in your browser

Skip the command line — drop a video into FFHub and pick a format. The same FFmpeg flags work behind the scenes, but you don't need to install anything.

FAQ

How do I extract audio from an MP4 without re-encoding?

Use ffmpeg -i input.mp4 -vn -c:a copy output.aac. The -vn flag drops the video stream, -c:a copy keeps the audio bitstream unchanged (lossless and instant). Pick the output extension that matches the source codec — run ffprobe -v error -select_streams a:0 -show_entries stream=codec_name input.mp4 to check what's inside.

What's the best audio format for podcasts?

For speech-only podcasts, Opus at 48-64 kbps delivers excellent quality at roughly half the size of MP3. If you need universal compatibility across all players and platforms, MP3 at 128 kbps is the safest choice. AAC at 96 kbps sits between the two — great for the Apple ecosystem and modern browsers.

Can FFmpeg extract audio from a video URL directly?

Yes. FFmpeg accepts HTTP(S) URLs as input: ffmpeg -i "https://example.com/video.mp4" -vn -c:a libmp3lame -b:a 192k output.mp3. No need to download the video first. This works with any direct video URL FFmpeg can probe.

How do I extract a specific audio track from a multi-track video?

Use -map 0:a:N where N is the track index (zero-based). For example, ffmpeg -i input.mkv -map 0:a:1 -c:a copy second_track.aac extracts the second audio track. Use ffprobe -v error -show_streams input.mkv first to list all tracks and their language tags.

Why is my extracted audio silent or corrupted?

Usually because the default audio track is empty (common in screen recordings or videos with multiple language tracks). Run ffprobe to identify all audio streams, then use -map 0:a:N to select the right one. If you see "discarding packet" warnings, replace -c:a copy with a real codec like -c:a libmp3lame to force re-encoding.

Should I use lossless (FLAC) or lossy (MP3) extraction?

Use FLAC if you're archiving, doing further editing, or extracting from a lossless source. Use MP3 or Opus for playback, podcasts, sharing, or web delivery — the size savings vastly outweigh the imperceptible quality difference at reasonable bitrates (192 kbps MP3, 96 kbps Opus).

Related Articles

How to Extract Audio from Video with FFmpeg | FFHub