ffmpeg is an incredibly powerful commandline media tool. Inspecting, decoding, encoding audio and video and its container formats.
If you are unfamiliar with media container formats (.mp4, .mp3, .mkv, etc) and their content stream types, see Introduction to Media Containers.
|Modern & Rich||mkv||
|Compatible||mp4||(default; specify file
Modern x265 instead of AV1: While AV1 is preferable over x265, the encoding speed is much slower on current hardware and current (still evolving) encoders.
Webbrowsers do not support H.265, so we accept the slower encoding speed for compatibility.
libsvtav1 over other AV1 encoders: libsvtav1 currently is significantly faster than librav1e and libaom-av1.
||10-bit allows for greater compression, and the slow preset allows the encoding process to spend more time to find better compression|
Audio Codec Overview
|Audio Codec||Alternative Name||Description|
|Opus||Best choice if compatible; Free and open format|
|AAC||Used in mp4|
|mp3||MPEG-2 Audio Layer III, MPEG-1 Audio Layer III||Traditional most popular personal digital audio format|
|Vorbis||Free and open format|
Video Codec Overview
|Video Codec||Alternative Name|
|H.264||AVC - Advanced Video Coding, x264, MPEG-4 Part 10|
|H.265||HEVC - High Efficiency Video Coding, x265, MPEG-H Part 2|
|AV1||AOMedia Video 1||Open format|
Mapping is the process of selecting streams from the input streams and how they map to the output.
Stream references are 0-based indexes.
||map all video streams ()|
||map the first video stream|
||map all audio streams ()|
||map all subtitle streams ()|
||map the first video and audio streams, drop chapters|
-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.
||duration (alternative to end)|
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.
-i source.mkv subs.ass
-i source.mkv subs.srt
-i source.mkv subs.vtt
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
Using the video filter (
scale with target
-1 for auto determined.
To scale to 480x: