Syntax: -vf crop=width:height:x:y

  • width = pixels wide for output video
  • height = pixels high for output video
  • x = horizontal location in input video to start crop (left upper corner)
  • y = vertical location in input video to start crop (left upper corner)
  • in_h = variable that can be used on command line, corresponds to the input video height value
  • in_w = variable that can be used on command line, corresponds to the input video width value

crop_diagram2.jpg

Other cropping examples

  • To crop 50 pixels off the top
-vf crop=in_w:in_h-50:0:50
  • Crop same 50 top pixels, without using the in_h and in_w variables (this example assumes input video size of 640x480)
-vf crop=640:430:0:50
  • Crop 20 pixels off left
-vf crop=in_w-20:in_h:20:0
  • Crop 10 top, 15 bottom, 30 left, 40 right
-vf crop=in_w-70:in_h-25:30:10
  • Make a 400x500 sized video with the upper left hand corner starting at pixel(40,80)
-vf crop=400:500:40:80

To explain another way

Assume T=crop top, B=crop bottom, L=crop left, R=crop right
Your formula would be:
-vf crop=in_w-(L+R):in_h-(T+B):L:T
  • More detailed explanation of ffmpeg cropping can be found here.