/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
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"
doneOutput
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
| Task | Command |
|---|---|
| Streams and codecs | ffprobe -hide_banner input.mp4 |
| Duration only | ffprobe -v error -show_entries format=duration -of csv=p=0 input.mp4 |
| JSON for scripts | ffprobe -v error -show_format -show_streams -of json input.mp4 |
Convert and encode
| Task | Command |
|---|---|
| Change container only | ffmpeg -i in.mkv -c copy out.mp4 |
| H.264 + AAC for the web | ffmpeg -i in.mov -c:v libx264 -crf 23 -preset medium -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart out.mp4 |
| VP9 WebM | ffmpeg -i in.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -c:a libopus out.webm |
| Change frame rate | ffmpeg -i in.mp4 -r 30 out.mp4 |
Cut, scale, crop
| Task | Command |
|---|---|
| Cut without re-encoding (keyframe-aligned) | ffmpeg -ss 00:01:00 -i in.mp4 -t 30 -c copy clip.mp4 |
| Cut frame-accurately | ffmpeg -ss 00:01:00 -i in.mp4 -t 30 -c:v libx264 -c:a aac clip.mp4 |
| Scale to 720p height, keep ratio | ffmpeg -i in.mp4 -vf scale=-2:720 out.mp4 |
| Crop to a centred square | ffmpeg -i in.mp4 -vf "crop=min(iw\,ih):min(iw\,ih)" out.mp4 |
Audio, images, GIF
| Task | Command |
|---|---|
| Extract audio, no re-encode | ffmpeg -i in.mp4 -vn -c:a copy audio.m4a |
| Remove audio | ffmpeg -i in.mp4 -an -c:v copy silent.mp4 |
| Thumbnail at 10 s | ffmpeg -ss 10 -i in.mp4 -frames:v 1 thumb.jpg |
| GIF with a good palette | ffmpeg -i in.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" out.gif |
| Images to video | ffmpeg -framerate 25 -i img%03d.png -c:v libx264 -pix_fmt yuv420p out.mp4 |
Sources
Related pages
commands · ffmpegffmpeg: extract audio from a video (with and without re-encoding)Extract audio with ffmpeg -i input.mp4 -vn -c:a copy audio.m4a without re-encoding, or make an MP3 with -c:a libmp3lame -q:a 2. Check codecs with ffprobe.flags · ffmpegffmpeg -crf: constant rate factor for x264, x265 and AV1-crf sets constant quality: lower means better and bigger. libx264 defaults to 23 on a 0 to 51 scale, libx265 to 28. Use it with -preset; sizes measured.compare · ffmpegffmpeg -c copy vs re-encoding: speed, quality and limits-c copy remuxes streams without decoding: fast and lossless, but cuts snap to keyframes and filters are impossible. Re-encoding is slower, lossy, flexible.