Crop video w/ audio
Crop video using cuda acceleration (-hwaccel cuvid)
Pass the -crop flag with margins: top x bottom x left x right. For example, given input video width 1280px and height 640px, to crop the rectangle bounded by lines 50px from top and bottom side, 430px from right side, and left side of original video, use the command below:
ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -crop 50x50x0x430 -i input.mp4 -c:v h264_nvenc output.mp4Crop video without cuda acceleration
Crop the video with input https://video.stackexchange.com/a/4571
ffmpeg -i input.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4Where the options are as follows:
out_wis the width of the output rectangleout_his the height of the output rectanglexandyspecify the top left corner of the output rectangle (coordinates start at (0,0) in the top left corner of the input)
For example, to crop the rectangle bounded by lines 50px from top and bottom side, 430px from right side, and left side of original video, use the command below:
ffmpeg -i input.mp4 -filter:v "crop=850:540:0:50" out.mp4NOTE: 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.