Guide
Burning in subtitles, extracting audio, how the position of -ss changes trimming, resizing, GIFs, MKV to MP4 remuxing, VFR to CFR, and basic x264, x265 and SVT-AV1 encoding. Each command comes with what its options mean and the usual mistakes.
FFmpeg has so many options that most people search and copy a command every time. This page collects 14 common jobs, one command each. Every command comes with a one-line description, what its options mean, and the mistakes people often make the first time.
In the commands, in.mp4 and out.mp4 are example file names, and numbers such as CRF 20, the presets and 12 fps are examples too. This page does not publish measured numbers. To pick a CRF for your quality target, use the CRF Recommender and our lab articles.
ffmpeg [input options] -i input [output options] output. An option applies to the file that comes right after it, so the same -ss means different things before or after -i (see “Trimming” below).-c copy moves the data as it is without re-encoding, so it is fast and loses no quality. In return, you can't combine it with filters (-vf), and the destination container has to accept the codec.-y early in the command to overwrite without asking, or -n to never overwrite.The standard recipe for an H.264 MP4, the most widely compatible format. Use it when you want the file to play on any device.
ffmpeg -i in.mp4 -c:v libx264 -crf 20 -preset medium -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart out.mp4-c:v libx264-crf 20-preset medium-pix_fmt yuv420p-c:a aac -b:a 128k-movflags +faststart-pix_fmt yuv420p as it is on HDR or 10-bit sources. Dropping to 8-bit can make the colors look washed out. HDR needs separate handling.Related tools and lessons: FFmpeg Command Builder · CRF Recommender · HandBrake RF to FFmpeg CRF and SVT-AV1 Conversion Chart (Equal-VMAF Measurements) · Encoding with ffmpeg: CRF, GOP, Profile, and Preset Options Explained · CRF vs. 2-pass vs. CQ: What Do You Fix?
An HEVC MP4 aimed at smaller files than H.264. Use it when the devices that will play it support HEVC.
ffmpeg -i in.mp4 -c:v libx265 -crf 24 -preset medium -tag:v hvc1 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart out.mp4-c:v libx265-crf 24-tag:v hvc1-pix_fmt yuv420pyuv420p10le.-tag:v hvc1, so the file won't play on Apple devices.Related tools and lessons: Codec Support Checker · CRF Recommender · Encoding 10-bit HDR10 with x265
The standard recipe for compressing to AV1. The encoder is libsvtav1.
ffmpeg -i in.mp4 -c:v libsvtav1 -crf 32 -preset 6 -pix_fmt yuv420p -c:a aac -b:a 128k out.mp4-c:v libsvtav1-crf 32-preset 6medium as an SVT-AV1 preset. SVT-AV1 takes numbers.Related tools and lessons: Codec Support Checker · Encoding Time Estimator · Choosing a Preset: The Value That Trades Time for Size
Shrinks the height to 720 while keeping the aspect ratio.
ffmpeg -i in.mp4 -vf scale=-2:720 -c:v libx264 -crf 20 -c:a copy out.mp4-vf scale=-2:720-2 tells FFmpeg to round the result to a multiple of 2.-c:v libx264 -crf 20-c:a copy-1 instead of -2. If the computed value is odd, yuv420p encoding can stop with an error.-c:v copy with -vf. A filter needs re-encoding, so the two can't be used together.Related tools and lessons: Size and Frame Rate: scale, zscale, fps · Filtergraph Syntax: -vf and -filter_complex · Video File Size & Bitrate Calculator
Cuts 30 seconds starting at the 1-minute mark without re-encoding. No quality loss and very fast, but the start may not be exact.
ffmpeg -ss 00:01:00 -i in.mp4 -t 30 -c copy out.mp4-ss 00:01:00 (before -i)-t 30-c copy-c copy can only cut at keyframes, so the start may slip back to a nearby earlier keyframe. For what a keyframe is, see the GOP structure lesson.-avoid_negative_ts make_zero.-c copy from this command to cut exactly. For an exact cut, name an encoder as in the next entry.Related tools and lessons: GOP Structure Explained: Keyframe Interval, Closed vs. Open GOP · Timestamps: PTS, DTS, and Timebase
Cuts from 1:00 to 1:30 with frame accuracy and encodes it anew.
ffmpeg -i in.mp4 -ss 00:01:00 -to 00:01:30 -c:v libx264 -crf 20 -c:a aac out.mp4-ss, -to (after -i)-c:v libx264 -crf 20-c:a aac-ss before -i but writing -to on the output side. It is read as the time elapsed since the start, so the clip comes out longer than expected. In that case give a length with -t instead of -to.-ss after -i, because everything before it is read and thrown away. When you re-encode, FFmpeg matches the exact frame by default even with -ss before -i (you can turn that off with -noaccurate_seek).Related tools and lessons: GOP Structure Explained: Keyframe Interval, Closed vs. Open GOP · Video File Size & Bitrate Calculator
Keeps the video and audio as they are and only changes the box from MKV to MP4. No quality loss, and it takes seconds.
ffmpeg -i in.mkv -map 0:v -map 0:a -c copy -movflags +faststart out.mp4-map 0:v -map 0:a-c copy-movflags +faststartRelated tools and lessons: MKV to MP4 Remux Feasibility Checker · Video File Info Viewer · Reading Structure with ffprobe, and What Remuxing Can and Can't Do · faststart: Why moov Needs to Come First
Turns a video with uneven frame spacing into a steady 30 fps. Use it when sync drifts in an editor.
ffmpeg -i in.mp4 -fps_mode cfr -r 30 -c:v libx264 -crf 20 -c:a copy out.mp4-fps_mode cfr-vsync cfr.-r 3030000/1001.-c:v libx264 -crf 20-c copy. It can't work, because frames have to be duplicated or dropped.-r 29.97. Writing it as a fraction is more exact.Related tools and lessons: Variable Frame Rate (VFR) Detector · Size and Frame Rate: scale, zscale, fps · Timestamps: PTS, DTS, and Timebase
Engraves the subtitles into the video's pixels. They show up in any player, but you can't turn them off.
ffmpeg -i in.mp4 -vf "subtitles=sub.srt" -c:v libx264 -crf 20 -c:a copy out.mp4-vf "subtitles=sub.srt"force_style='FontSize=24'subtitles=sub.srt:force_style='FontSize=24' to change styles such as font size.-c:a copyC:\... on Windows, where the filter misreads the colon and fails. It is easier to keep the subtitle file in the same folder as the video and use just the file name.subtitles. They are pictures and can't be read that way; use overlay.scale without thinking about the order. The size of the subtitle text changes.Related tools and lessons: Burning In Subtitles: subtitles, ass, overlay · Subtitle Sync Fixer
Puts the subtitles in the MP4 as a separate track. The video isn't re-encoded, and the player can switch the subtitles on and off.
ffmpeg -i in.mp4 -i sub.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=kor out.mp4-i in.mp4 -i sub.srt-map 0 -map 1-c copy -c:s mov_text-metadata:s:s:0 language=kor-c copy without naming a subtitle format and getting an error that MP4 can't hold SRT. For MP4 you have to convert to mov_text.Related tools and lessons: Subtitle Sync Fixer · Reading Structure with ffprobe, and What Remuxing Can and Can't Do
Pulls the sound out into a file without the video. If the audio is AAC, copying is enough; otherwise convert it, for example to mp3.
# AAC → m4a
ffmpeg -i in.mp4 -vn -c:a copy out.m4a
# mp3
ffmpeg -i in.mp4 -vn -c:a libmp3lame -q:a 2 out.mp3-vn-c:a copy.m4a.-c:a libmp3lame -q:a 2-q:a is the VBR quality value, and lower means higher quality. 2 is an example..m4a with -c:a copy when the source audio isn't AAC. The audio codec and the extension have to match. Check the audio codec first.-map 0:a:1.Related tools and lessons: Video File Info Viewer · Comparing Lossy Codecs: MP3, AAC (LC/HE), and Opus · Audio Compatibility by Container, and How to Check
Makes a 4-second GIF starting at 5 seconds. It builds a palette separately so the colors get muddied less.
ffmpeg -ss 5 -t 4 -i in.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 out.giffps=12scale=480:-1:flags=lanczospalettegen / paletteuse-loop 0out.gif without a palette. The colors tend to look muddy.Related tools and lessons: Filtergraph Syntax: -vf and -filter_complex · Size and Frame Rate: scale, zscale, fps
Saves one frame at a given time as an image, or one frame every second.
# one frame
ffmpeg -ss 00:00:05 -i in.mp4 -frames:v 1 frame.png
# one frame per second
ffmpeg -i in.mp4 -vf fps=1 frame_%03d.png-ss 00:00:05-frames:v 1-vf fps=1frame_%03d.png%03d is the slot that gets a number: 001, 002 and so on.%03d). The images overwrite each other and only one is left.-q:v, and lower means higher quality.Related tools and lessons: Pulling Out Suspect Segments: ffmpeg and Per-Frame VMAF
Joins several video files made with the same settings into one without re-encoding.
# list.txt
file 'part1.mp4'
file 'part2.mp4'
ffmpeg -f concat -safe 0 -i list.txt -c copy out.mp4list.txtfile 'name' per line.-f concat-safe 0-c copy-c copy. Playback can break. If the settings differ, use the concat filter, which re-encodes.Related tools and lessons: Timestamps: PTS, DTS, and Timebase · Filtergraph Syntax: -vf and -filter_complex
Even for the same “from the 1-minute mark”, the result depends on where -ss goes and whether you use -c copy. The table below summarizes how FFmpeg behaves; the speeds are not values measured on this site.
| Method | Start position | Nature of the speed | What -to refers to |
|---|---|---|---|
-ss before + -c copy | May slip back to a nearby earlier keyframe | Jumps straight there with no re-encoding, fast | Output time (elapsed since the start). Prefer -t |
-ss before + re-encode | Frame-accurate (default behavior) | Jumps straight to the start point, fairly fast | Output time (elapsed since the start). Prefer -t |
-ss after + re-encode | Frame-accurate | Reads and discards the beginning, so slower the later the position | A time in the original video |
-ss after + -c copy | The state of the start differs by file, so not recommended | Reads from the beginning | A time in the original video |
In short: if you don't need exactness, use “before + copy”. If you do, re-encode, put -ss before -i, and give the end with -t; that way nothing gets confusing.
subtitles) may be missing; if you get an error, check with ffmpeg -encoders and ffmpeg -filters.-fps_mode replaced -vsync). With an old FFmpeg, check the documentation for that version.Put -ss before -i, give the length with -t, and use -c copy (for example: ffmpeg -ss 00:01:00 -i in.mp4 -t 30 -c copy out.mp4). There is no quality loss and it is very fast, but -c copy can only cut at keyframes, so the start may slip back to a nearby earlier keyframe.
-ss before -i jumps straight to near that time in the input file, and -to is then read as output time (elapsed since the start), so prefer -t. -ss after -i reads and discards the beginning, so it is slower the later the position, and the time refers to the original video. For an exact cut, re-encode, put -ss before -i, and give the end with -t; that way nothing gets confusing.
No. Remuxing moves the data as it is, so the size stays almost the same. Also, MP4 can't hold subtitle tracks such as ASS or PGS as they are, which can cause an error, so map only video and audio, or convert text subtitles separately.
-fps_mode is the name used from FFmpeg 5.1 onward; older versions use -vsync cfr. Because it changes frames, re-encoding is required. Some option names have changed between versions, so with an older FFmpeg, check the manual for that version.
Depending on the build, an encoder (libsvtav1, libx265) or a filter (subtitles) may be missing. Run ffmpeg -encoders and ffmpeg -filters to see what your build has.