The most common audio operation: pull the audio out of a video file and save it as a standalone audio file. With stream copy, this is lossless and instant. With re-encoding, you can convert to a different audio format or sample rate.

The command

ffmpeg -i input.mp4 -vn -c:a copy output.aac

What it does

The -vn flag drops the video stream entirely; -c:a copy copies the audio packets without re-encoding. The output is a standalone audio file with the same codec as the source (AAC in this case, for a typical MP4).

When to use it

For ripping audio from a video without quality loss. Use it to extract a song from a music video, pull the audio from a recording for transcription, or get a clean audio track for editing. If the source's audio codec is what you want, stream copy is the right tool.

Video and audio requirements

The source must have an audio stream. The output format must accept the source's audio codec; MP4 typically holds AAC, which all common audio formats accept. For MKV source with FLAC audio, the output must also support FLAC (MKA, MP3 with re-encode, etc.).

Things to avoid

  • Forgetting -vn. Without it, FFmpeg re-encodes audio to video's codec, which is usually wrong. -vn is the key flag for this command.
  • Using a container that does not support the source codec. AAC inside WAV, for example, is not valid; .wav expects PCM. Re-encode with -c:a pcm_s16le or use a container that accepts AAC (M4A, MP4, MKV).
  • Assuming the source has only one audio track. With -c:a copy, only the first audio track is extracted. To extract a specific track, use -map 0:a:1 for the second track, etc.
  • Extracting audio from a DRM-protected source. Stream copy preserves the encryption; the extracted file is still protected and will not play in unencrypted players.