ffmpeg Cheatsheet

ffmpeg is an incredibly powerful commandline media tool. Inspecting, decoding, encoding audio and video and its container formats.

Introduction to Media Containers

A media file (.mp3, .mp4, .mkv, .webm, .ogg, .opus, .avi) is a container for the media.

An .mp3 file has the audio stream and optionally descriptive metadata.

An .mp4 file can hold any number of

  • audio stream
  • video stream
  • subtitles
  • metadata

A Matroska .mkv file can hold any number of

  • audio stream
  • video stream
  • subtitles
  • chapters (referencing sections within the file or in other files)
  • metadata

You can inspect a file with ffmpeg -hide_banner -i <file>. (Or ffprobe -hide_banner <file>.)

Mapping Streams

Mapping is the process of selecting streams from the input streams and how they map to the output.

Stream references are 0-based indexes.

Parameter Description
-map_chapters -1 drop chapters
-map 0:v map all video streams ()
-map 0:v:0 map the first video stream
-map 0:a map all audio streams ()
-map 0:s map all subtitle streams ()


Parameters Description
-map_chapters -1 -map 0:v:0 -map 0:a:0 map the first video and audio streams, drop chapters

Lossless Copy

Parameter Description
-c copy Copy stream

-c for codec, -c:a for audio codec, -c:v for video codec

Note that a lossless copy works especially well for copying full streams (e.g. into a different container format, or while editing others), but if you are cutting/extracting a section it is not precise (video is encoded in key and intermediate frames, so specifying a timed section start or end may be offset).


For time-based cutting. Time specified in hh:mm:ss.nnn e.g. 1:45 or 1:45.200 or 13.800 etc.

Parameter Description
-ss <time> start time
-to <time> end time
-t <duration> duration (alternative to end)


Parameter Description
-pix_fmt yuv420p10le 10-bit

Format Recommendations

Intention Container Video Audio
Maximum Compatibility mp4 H.264 / AVC (Advanced Video Coding) / x264 AAC
Modern 10-bit H.265 / HEVC (High Efficiency Video Coding) / x265
Maximum Compression 10-bit x265 very slow preset
Browser/Web Video webm AV1 Opus

H.264 is another name for AVC. x264 is an open source encoder for H.264 / AVC.

Modern Target - 10-bit x265

Parameter Description
-c:v libx265 -pix_fmt yuv420p10le 10-bit x264

Modern Web Target - 10-bit AV1

  • Container .webm
  • Video Encoding - 10-bit AV1
    • -c:v libsvtav1 -pix_fmt yuv420p10le
    • -c:v librav1e -pix_fmt yuv420p10le
    • -c:v libaom-av1 -pix_fmt yuv420p10le
  • Audio Encoding - Opus
    • -c:a libopus

Burn Subtitles (Soft to Hard subtitles)

Soft subtitles are embedded in the container file. They get interpreted and rendered by the media player. This allows custom styling, fonts and sizes, as well as selecting between multiple subtitle tracks.

Hard subtitles are part of the video stream, of the image data. They are burned onto the video image.


A video file may have multiple subtitle tracks. Subtitle tracks may be marked as default or forced.

Media players may select a subtitle track through forced -> default -> user setting primary language -> system display language.

  • forced - no subtitles in videos primary spoken language, subtitles when a different language is spoken