====== ffmpeg - Video - Crop ======
===== Crop a video =====
ffmpeg -i input.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4
ffmpeg -i input.mp4 -filter:v "crop=850:540:0:50" out.mp4
**NOTE:** The options are:
* **out_w** - the width of the output rectangle.
* **out_h** - the height of the output rectangle
* **x and y** - specify the top left corner of the output rectangle (coordinates start at (0,0) in the top left corner of the input).
**WARNING:** The top & bottom, left & right margin values should not conflict.
* For example, for a video of 300px height, when crop top margin = 200px, bottom margin cannot be more than 300-200 = 100px.
* Otherwise, the output will be an empty video file.
----
====== Crop video using cuda acceleration (-hwaccel cuvid) ======
Pass the **-crop** flag with margins: top x bottom x left x right.
ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -crop 50x50x0x430 -i input.mp4 -c:v h264_nvenc output.mp4
**NOTE:** This crops the input video to the rectangle bounded by lines 50px from top and bottom side, 430px from right side, and left side of original video.
----