In this tutorial, we learn how to crop a video using FFmpeg‘s crop
filter. We will also learn how to use variables for cropping the video.
How to Crop a Video using Pixel Coordinates
If you know the size and the coordinates of the section of the video that you want to crop, then it’s very simple to crop a video using FFmpeg.
The syntax for cropping a video is crop=width:height:x:y
. With this, here is a command line that crops a 200×200 portion of a video.
ffmpeg -i input.mp4 -filter_complex "[0:v]crop=200:200:300:100[cropped]" -map "[cropped]" output.mp4
This command results in a 200x200
cropped portion of the video situated 300
pixels from the left edge and 100
pixels from the top edge.
If the parameters 300:100
is not provided, the resulting portion will be taken from the center of the video. It’s that easy!

Crop a Video in FFmpeg with Variables
We can implement the video cropping command using variables to denote the video parameters. The input video’s width
and height
can be denoted by in_w
/ iw
and in_h
/ ih
respectively.
Here is an example of cropping a video in FFmpeg using variables instead of specifying the literal pixel coordinates.
ffmpeg -i input.mp4 -filter_complex "[0:v]crop=in_w/2:in_h/2[cropped]" -map "[cropped]" output.mp4
Some useful variable templates
- Bottom right corner:
crop=in_w/2:in_h/2:in_w/2:in_h/2
- Remove
$x
pixels from the top and bottom:crop=in_w:in_h-2*$x
- Remove
$x
pixels from either side of the video:crop=in_w-2*$x:in_h
Crop A Video using FFmpeg from the Bottom Only
A quick example to drive home the point about cropping. Let’s say your video has some ticker text at the bottom and you want to crop it out.
The way to do it using FFmpeg’s crop command is as follows:
ffmpeg -i input.mp4 -filter_complex "[0:v]crop=in_w:in_h-10:0:0[cropped]" -map "[cropped]" output.mp4
This command line tells FFmpeg to crop a region
- whose width is equal to the source video’s width,
- whose height is equal to the source video’s height minus 10 pixels,
- and the origin is at
[0,0]
All you have to do is adjust this command to the height of the region you want to remove, and you’ll have successfully cropped a video using FFmpeg.
If you enjoyed this post, do check out the rest of OTTVerse’s FFmpeg tutorials to learn more about how to use FFmpeg to improve your video editing, compression, and processing skills!

Akshay Rajeev
Akshay is a student at the NYU Tandon School of Engineering, completing his M.S. in Computer Engineering. His area of interest includes software system design, machine learning, and cybersecurity.
Akshay also serves as a Contributing Author on OTTVerse.com
” Remove $x pixels from the top and bottom: crop=in_w:in_h-2*$x ”
That seems incorrect. Shouldn’t this be the following ?
” Remove $x pixels from the top and bottom: crop=in_w:in_h-2*$x:0:$x ”
Similar mistake in
” Remove $x pixels from either side of the video: crop=in_w-2*$x:in_h “.
It should be
” Remove $x pixels from either side of the video: crop=in_w-2*$x:in_h:$x:0″.