Skip to content

/cheatsheets/ffmpeg/ffmpeg-cheat-sheet

FFmpeg cheat sheet: convert, cut, scale, extract and inspect

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · ffmpeg version 9.0.2-full_build-www.gyan.devupdated 2026-10-20
tool
FFmpeg
versions
FFmpeg 6 – 9
os
linux, macos, windows

The FFmpeg commands you reach for most often. Option order matters: options before -i apply to that input, options after it apply to the next output.

Try it on a generated clip

bash
ffmpeg -hide_banner -loglevel error -f lavfi -i testsrc=size=640x360:rate=25:duration=6 -f lavfi -i sine=duration=6 \
  -c:v libx264 -pix_fmt yuv420p -c:a aac -shortest -y in.mp4
ffmpeg -hide_banner -loglevel error -ss 2 -i in.mp4 -t 2 -c copy -y cut.mp4
ffmpeg -hide_banner -loglevel error -i in.mp4 -vf scale=320:-2 -c:a copy -y small.mp4
ffmpeg -hide_banner -loglevel error -ss 1 -i in.mp4 -frames:v 1 -y thumb.png
for f in in.mp4 cut.mp4 small.mp4 thumb.png; do
  size=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0:s=x "$f")
  dur=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$f")
  printf '%-9s %-8s duration %s\n' "$f" "$size" "$dur"
done

Output

in.mp4    640x360  duration 6.000000
cut.mp4   640x360  duration 2.200000
small.mp4 320x180  duration 6.000000
thumb.png 640x360  duration N/A

Inspect

TaskCommand
Streams and codecsffprobe -hide_banner input.mp4
Duration onlyffprobe -v error -show_entries format=duration -of csv=p=0 input.mp4
JSON for scriptsffprobe -v error -show_format -show_streams -of json input.mp4

Convert and encode

TaskCommand
Change container onlyffmpeg -i in.mkv -c copy out.mp4
H.264 + AAC for the webffmpeg -i in.mov -c:v libx264 -crf 23 -preset medium -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart out.mp4
VP9 WebMffmpeg -i in.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -c:a libopus out.webm
Change frame rateffmpeg -i in.mp4 -r 30 out.mp4

Cut, scale, crop

TaskCommand
Cut without re-encoding (keyframe-aligned)ffmpeg -ss 00:01:00 -i in.mp4 -t 30 -c copy clip.mp4
Cut frame-accuratelyffmpeg -ss 00:01:00 -i in.mp4 -t 30 -c:v libx264 -c:a aac clip.mp4
Scale to 720p height, keep ratioffmpeg -i in.mp4 -vf scale=-2:720 out.mp4
Crop to a centred squareffmpeg -i in.mp4 -vf "crop=min(iw\,ih):min(iw\,ih)" out.mp4

Audio, images, GIF

TaskCommand
Extract audio, no re-encodeffmpeg -i in.mp4 -vn -c:a copy audio.m4a
Remove audioffmpeg -i in.mp4 -an -c:v copy silent.mp4
Thumbnail at 10 sffmpeg -ss 10 -i in.mp4 -frames:v 1 thumb.jpg
GIF with a good paletteffmpeg -i in.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" out.gif
Images to videoffmpeg -framerate 25 -i img%03d.png -c:v libx264 -pix_fmt yuv420p out.mp4

Sources