Map All Audio Streams from Input to Output in FFmpeg

By default, FFmpeg only selects a single video stream and a single audio stream when converting or copying files, ignoring any additional audio tracks like alternative languages or commentary. This article provides a straightforward guide on how to use the -map option in FFmpeg to ensure that every audio stream from your input file is successfully transferred to your output file.

The Default Behavior vs. Mapping All Streams

When you run a standard FFmpeg command without specifying stream selection, FFmpeg uses its default "stream selection" behavior. It automatically picks the "best" video stream and the "best" audio stream, discarding the rest.

To override this and map all audio streams, you must use the -map option followed by the input index and stream specifier 0:a.

The Command to Map All Video and Audio Streams

If you want to copy the video stream and all available audio streams from an input file without re-encoding them, use the following command:

ffmpeg -i input.mkv -map 0:v -map 0:a -c copy output.mkv

Command Breakdown:

  • -i input.mkv: Specifies the path to your input file.
  • -map 0:v: Instructs FFmpeg to include the video stream(s) from the first input file (index 0). If you have multiple video streams and only want the first one, use -map 0:v:0 instead.
  • -map 0:a: Instructs FFmpeg to select all audio streams from the first input file (index 0). The omission of a specific stream index after a tells FFmpeg to include every audio track.
  • -c copy: Enables "stream copy" mode for both video and audio. This copies the streams without re-encoding, preserving original quality and completing the process almost instantly.

Mapping All Audio Streams While Re-encoding

If you need to transcode the audio streams (for example, converting all audio tracks to AAC format) while retaining the original video, use this command:

ffmpeg -i input.mkv -map 0:v -map 0:a -c:v copy -c:a aac output.mp4

In this command:

  • -c:v copy copies the video stream without re-encoding.
  • -c:a aac encodes all selected audio streams into the AAC format.

Mapping Only Audio Streams (Audio-Only Output)

If you want to discard the video entirely and extract all audio streams into a single audio container (like MKA), run:

ffmpeg -i input.mkv -map 0:a -c copy output.mka

This will strip the video and copy all individual audio tracks into the destination file.