How to Map All Video and Discard Audio in FFmpeg
This article provides a quick guide on how to use FFmpeg to select and map every video track from an input file while completely excluding all audio, subtitle, and other data tracks. You will learn the exact command-line syntax required to perform this stream selection efficiently without losing video quality.
To map all video tracks and discard all audio and subtitle tracks,
you need to use FFmpeg’s -map option combined with stream
specifiers.
Here is the standard command to achieve this:
ffmpeg -i input.mkv -map 0:v -c:v copy -an -sn output.mkvHow the Command Works
-i input.mkv: Specifies the path to your input file.-map 0:v: This is the core instruction. It tells FFmpeg to select all video streams (v) from the first input file (0). By manually defining a map, FFmpeg disables its default stream selection behavior, meaning any unmapped streams (like audio and subtitles) are automatically excluded.-c:v copy: Stream copies the video tracks. This copies the video payloads without re-encoding them, which preserves original quality and completes the process almost instantly. If you want to re-encode the video, replacecopywith your desired encoder (e.g.,libx264).-an: Explicitly disables all audio recording.-sn: Explicitly disables all subtitle recording.
While -map 0:v is technically sufficient on its own to
exclude other stream types, adding the -an and
-sn flags acts as an extra layer of instruction to ensure
absolutely no audio or subtitle metadata passes through to the output
file.