Cropping Videos on Linux
I recently had a need to crop a video that I’d shot landscape, but wanted to upload to Instagram as a reel. My original clip was 1280x720, but Instagram reels are 1080x1920, i.e. portrait.
There are plenty of video editing suites that can do this, but I didn’t have any installed, and I knew exactly how I wanted to crop (so I didn’t need a preview). All I wanted to do was crop out the excess width (equally on the left and right), and maintain the original height.
So, how?
As is so often the answer to these sorts of questions: ffmpeg
is all you need.
Given Instagram’s 9:16 aspect ratio, I needed to crop my original 1280x720 clip down to 405x720, thus removing 875 pixels of width. And since I wanted to keep the middle section, that meant removing about 437 pixels from both the left and the right.
And this is how do it:
ffmpeg -i original.mp4 -filter:v "crop=405:720:437:0" cropped.mp4
You can see here that 405:720
is the dimensions of the cropped video, and 437:0
is the top left of the rectangle overlayed on the original.
Simple, once you know how!