How to crop videos using ffmpeg

Sometime you might want a specific resolution for a video(ofcourse, smaller than the original). You can either resize the video and degrade the quality or you can just crop the video to achieve that resolution. This might affect the content of the video but if the content is mostly centric then it is probably a good option.

Suppose, we have a video of resolution 1920x1200 and we want to convert into a video of resolution 1200x1024. This is how you will do it using ffmpeg.

[shredder12]$ ffmpeg -i inputfile.avi -croptop 88 -cropbottom 88 -cropleft 360 -cropright 360 outputfile.avi

Just take a look at the original resolution the width of the video was 1920 pixels and we want it to be 1200, the difference is 720 so we removed 360 pixels each from right and left. Similarly, we did the same for the height.

3 Comments

ffmpeg-windows-user (not verified)
September 18th, 2010 10:20 am
the new ffmpeg versions, don't use pad or crop anymore, they use -vf filters
Anon Linuxer (not verified)
January 25th, 2011 09:12 pm
error cropping picture
Big Hammy Toast (not verified)
March 13th, 2011 06:54 pm
Here's the script I use to process my digital camera clippings. It removes some of the beginning frames and the annoying popping noise when the camera starts up, changes the audio from unrecognizable format to s16le. You might want to change my default sample rate of 8000. I am very stupid. I named it vidconv. Use like this: vidconv FILE_NAME [width] [height] Crop to 640x360: vidconv GEDC3866.MOV Crop to 720x405: vidconv GEDC3866.MOV 720 405 #!/bin/bash set -x ffmpeg -threads 8 -ss 0.5 -itsoffset 0.1 -i "$1" -acodec pcm_s16le -ar 8000 -ac 1 -vf crop=${2-640}:${3-360} -b 2000k "${1%%.MOV}.1.MOV"

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Use syntax $$latex$$ to insert LaTeX formulas.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.