C.W.K.
Stream
Lesson 03 of 10 · published

Crop

~8 min · crop, aspect, framing

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

Crop syntax

crop=W:H:X:Y. W and H are the output dimensions; X and Y are the top-left corner relative to the input. Defaults are (in_w-out_w)/2 and (in_h-out_h)/2 — centered.

Common patterns

  • crop=in_w:in_h*0.9 — 10% off the bottom (de-letterbox).
  • crop=in_w/2:in_h:0:0 — left half of the frame.
  • crop=1080:1920 — vertical 9:16 from a 16:9 (TikTok format), centered.
  • crop=in_h*9/16:in_h — vertical crop from any horizontal source.

Code

Crop recipes·bash
# Trim 100px off the top and bottom (assume 1920×1080 input)
ffmpeg -i in.mp4 -vf "crop=1920:880:0:100" -c:v libx264 -crf 20 out.mp4

# 16:9 → 9:16 vertical (centered)
ffmpeg -i landscape.mp4 \
  -vf "crop=in_h*9/16:in_h" \
  -c:v libx264 -crf 20 -preset slow vertical.mp4

# Auto-detect black bars and crop them
ffmpeg -i in.mp4 -vf cropdetect -f null - 2>&1 | grep -o 'crop=[^ ]*' | tail -1
# Outputs e.g. crop=1920:800:0:140
# Then run that crop:
ffmpeg -i in.mp4 -vf "crop=1920:800:0:140" -c:v libx264 -crf 20 cropped.mp4

External links

Exercise

Find a video with letterboxing (movie trailer, anything 2.35:1). Run cropdetect, take the suggested crop, and apply it. Verify the output has no black bars. Then take any 16:9 clip and convert to vertical 9:16 — does the centered crop look right, or do you need to re-frame?

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.