Cropping Videos With ffmpeg

Cropping in ffmpeg is down with the `-vf`` `crop`` filter. For example:

Code

ffmpeg input.mp4 -vf "crop=OUTWIDTH:OUTHEIGHT:STARTX:STARTY" output.mp4

Where:

  • *OUTWIDTH** is the output width

  • *OUTHEIGHT** is the output height

  • *STARTX** is the horizontal position to start cropping from the top left corner

  • *STARTY** is the vertical position to start cropping from the top left corner

Code

ffmpeg -i input.mp4 -vf "crop=3840:2160:0:0" output.mp4

Code

ffmpeg -i input.mp4 -vf "crop=2840:2160:0:0" output.mp4

Code

ffmpeg -i input.mp4 -vf "crop=2840:2160:1000:0" output.mp4

Code

ffmpeg -i input.mp4 -vf "crop=1840:2160:1000:0" output.mp4

Code

-vf "crop=4840:2160:0:0"

with an error message like:

[Parsed_crop_0 @ 0x135828c60] 
Invalid too big or non positive size for width '4840' 
or height '2160'

[Parsed_crop_0 @ 0x135828c60] Failed to configure 
input pad on Parsed_crop_0

Error reinitializing filters!

Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0

Conversion failed!
  • write up ffmpeg resizing and cropping together