Take the 2-minute tour ×
Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It's 100% free, no registration required.

I have an MP4 file of a screen recording that I need to crop down. How can I accomplish this without using expensive tools like Adobe Premier or Final Cut? I prefer ffmpeg because I have used it before.

share|improve this question

1 Answer 1

up vote 25 down vote accepted

In recent versions of FFmpeg, use the crop filter:

ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4

Where the options are as follows:

  • out_w is the width of the output rectangle
  • out_h is the height of the output rectangle
  • x and y specify the top left corner of the output rectangle

So, for example, to crop a 640×480 window, starting from position (100, 100), you'd do:

ffmpeg -i in.mp4 -filter:v "crop=640:480:100:100" out.mp4

Be aware that FFmpeg will re-encode the video using x264. With no additional options, this defaults to a constant quality factor (CRF) set to 23. To increase the quality, use a lower value, maybe go down to 18:

ffmpeg -i in.mp4 -filter:v "crop=640:480:100:100" -crf 18 out.mp4

For older versions of FFmpeg, information is provided on this site:

Let's take our original kitty.flv movie and turn it into a widescreen MPEG movie that can be used on a DVD-Video. The trouble is, its aspect ratio is 4:3, which is narrower than the 16:9 of widescreen format. Its current size is 320x240. If we want to give it a widescreen aspect ratio, its height should be 320/(16/9)=180 pixels instead of 240. If we simply resize the image in order to squash it vertically, the picture will be deformed. The only thing we can do in order to stop the picture from going anamorphic is to trim off parts of it, or to "crop" it. The picture is 60 pixels too "tall" so let's shave 30 pixels off the top and off the bottom, then convert the result to a 16:9 NTSC DVD:

$ ffmpeg -i kitty.flv -croptop 30 -cropbottom 30 -target ntsc-dvd -aspect 16:9 kitty.169.mpg


The "-croptop" and "-cropbottom" options slice the given number of pixels off the top and the bottom of the image respectively. There are also "-cropleft" and "-cropright" options for narrowing an image with an aspect ratio that's too high. The number of pixels to slice off must be an even number. The various "-crop" options act BEFORE any resizing takes place. They crop the specified number of pixels off the ORIGINAL image. Now let's turn this 16:9 NTSC video into a 480x360 letterboxed AVI at 15 frames per second. "Letterboxed" means that we keep the whole widescreen image and put bars on the top and bottom so that the resulting bar-image-bar sandwich has the required aspect ratio:

$ fmpeg -i kitty.169.mpg -acodec mp3 -ar 44100 -ab 128k -vcodec msmpeg4v2 -b 500k \ -s 480x270 -r 15 -padtop 44 -padbottom 46 -padcolor 000000 -f avi kitty.letterbox.avi


If we want to maintain the same aspect ratio for the image itself and if we want to make it 480 pixels wide, then the height will have to be 480/(16/9)=270 pixels, hence the "-s 480x270".

Our image being 270 pixels high while we need it to be 360 pixels high in order to obtain the standard 4:3 aspect ratio, we need to slap an extra 90 pixels on it. However, the number of pixels specified in the "-padtop" and "-padbottom" options has to be an even number, hence 44 for one and 46 for the other rather than 45 each.

The color of the padding is specified using the "-padcolor" option. The argument given is a color expressed as three hex bytes just like in HTML (but without the leading "#" sign). See here for a conversion tool that can convert a color into hex notation. There are also "-padleft" and "-padright" options for widening an image with an aspect ratio that's too low for the target.

The various "-pad" options are applied AFTER resizing has taken place. They add the specified number of pixels to the RESIZED image.

Additional information can be found on the ffmpeg-wiki pages, of which I suggest you to start with the "FilteringGuide" section, in which you will find a really comprehensive list of ffmpeg filters.

share|improve this answer
Thanks so much! I'm actually on Mac OS X, but I use ffmpeg compiled through MacPorts. This does exactly what I need. –  stephenwade Aug 15 '12 at 14:00
Note that the -crop* and -pad* options have been depreciated in favor of the crop and pad filters in non-ancient ffmpeg releases. –  LordNeckbeard Aug 28 '12 at 18:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.