FFmpeg extract audio from video: copy, MP3, or WAV

Extract audio from a video with FFmpeg: -vn drops the picture, then -c:a copy keeps the audio as it is, or an encoder writes WAV or MP3.

5 min readSume
All posts

To extract audio from a video with FFmpeg, drop the picture with -vn and choose what happens to the sound: copy the audio stream as it is with -c:a copy, which keeps its codec with no re-encode and no quality loss, or encode it to a new format such as WAV (-c:a pcm_s16le) or MP3 (-c:a libmp3lame).

The FFmpeg facts come from its ffmpeg, codecs, formats, and utilities documentation, and the Sume facts from the Audio detach and Video inspect docs, all read on 2026-09-28. Anything described as current behavior is read from Sume's code.

How do I extract audio without re-encoding it?

Copy the audio stream into an audio-only file. FFmpeg lists m4a among the MP4 family's file extensions, so AAC audio from an MP4 can go into .m4a:

  • -vn, as an output option, disables video recording: no video stream is selected or mapped for the output.
  • copy tells FFmpeg the stream is not to be re-encoded. With no decoding or encoding, FFmpeg's docs say, there is no quality loss.
  • A copy can fail. FFmpeg's docs say stream copy might not work in some cases, for example when information the target container needs isn't in the source, so the output extension has to be a container that can hold the codec you copy.
  • Cutting while copying is loose: FFmpeg's docs say most formats can't seek exactly, so with -ss before -i it seeks to the closest seek point before the position, and a stream copy keeps that extra segment instead of discarding it.
ffmpeg -i input.mp4 -vn -c:a copy output.m4a

How do I extract audio to WAV or MP3?

Name an audio encoder instead of copy. Encoding decodes the audio and encodes it again, which FFmpeg's docs say in most cases degrades quality, so copy when the original codec will do:

  • libmp3lame wraps the LAME MP3 encoder, and FFmpeg has it only when built with --enable-libmp3lame. -b:a 128k is the bitrate FFmpeg's own MP3 example uses.
  • -ac 1 sets one channel (mono) and -ar 16000 sets the sample rate. Without them, FFmpeg keeps the input's channel count and sample rate.
  • To stay in AAC, -c:a aac is FFmpeg's native AAC encoder, which uses 128 kbps when you don't set a bitrate.
# WAV: uncompressed PCM, signed 16-bit little-endian
ffmpeg -i input.mp4 -vn -c:a pcm_s16le output.wav

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

How do I pick one audio track or a time range?

  • -map 0:a:1 takes the second audio stream of the first input; counting starts at 0, so FFmpeg's docs select the third audio stream with 0:a:2.
  • -ss 30 before -i starts at 30 seconds, and -t 10 keeps 10 seconds. Times can be plain seconds such as 55 or 0.2, or HH:MM:SS.
  • When you encode, the start is exact: with -accurate_seek, the default, FFmpeg decodes and discards the part between the seek point and the position.

Can I extract audio with the Sume API instead?

Yes, for a video already in your workspace: POST /v1/audio-detach runs the encode path of these commands on the server. It never copies the source stream; it always writes a new WAV or MP3 file. In current code the options map to FFmpeg like this:

FFmpeg options from the ffmpeg documentation; Sume fields from Audio detach and its compiler as it runs today, read 2026-09-28.
ToFFmpegSume audio detach
Drop the picture-vnAlways, in current code
Take the first audio stream-map 0:a:0Always, in current code
Write 16-bit WAV-c:a pcm_s16leformat: "wav", the default
Write MP3-c:a libmp3lame -b:a 128kformat: "mp3", at 128 kbps
Mix to mono-ac 1channels: "mono"
Set the sample rate-ar 16000sample_rate: 16000, 44100, or 48000
Keep a time range-ss 30 -t 10range with start: 30 and end: 40
Copy without re-encoding-c:a copyNot offered
curl -X POST https://api.sume.com/v1/audio-detach \
  -H "Authorization: Bearer $SUME_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: audio-detach-mp3-001" \
  -d '{
    "video_url": "https://media.sume.com/artifacts/artf_demo/talk.mp4",
    "format": "mp3",
    "range": { "start": 30, "end": 40 }
  }'

What are the limits of audio detach?

  • video_url must be your workspace's media.sume.com artifact or asset, such as an earlier Sume job's output; which URLs each endpoint accepts explains the rule.
  • Sources run up to 1,800 seconds and each output up to 900 seconds, so a whole track past 900 seconds needs a range. In current code a source file over 300 MiB is refused with source_too_large.
  • A video with no audio track fails with detach_source_has_no_audio. Check probe.has_audio first with a frames: false video inspect.
  • Detach is billed per job, plus a 5.5% agent fee by default; the docs say to confirm the rate in GET /v1/catalog. Trim, filter, or detach audio covers the rest of the call.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume