How to Crop Video using FFmpeg

  • Post category:FFmpeg

Welcome to our guide on how to crop video using FFmpeg. Whether you’re a pro or a beginner, we’ll show you how to resize and trim with precision for outstanding content. Let’s get started!

Step 1: Install FFmpeg (if not already installed)

Before we begin, make sure you have FFmpeg installed on your system. You can download it from the official website or follow our step by step instruction to install FFmpeg on your system.


How to Install FFmpeg in Windows

Step 2: Open Your Command Prompt or Terminal

Now, open the command prompt (if you’re on Windows) or the terminal (if you’re on Mac or Linux).

Step 3: Crop Video using FFmpeg

Here is a command to crop a video using ffmpeg:

ffmpeg -i input.mp4 -filter:v "crop=w:h:x:y" -c:a copy output.mp4
    

Let’s break down the command:

  • Take input.mp4 as input
  • Apply the crop filter on the video stream
  • Keep the audio stream unchanged with -c:a copy
  • Save cropped video to output.mp4

The crop filter takes w, h, x, and y as parameters:

  • w – Width of cropped region
  • h – Height of cropped region
  • x – Horizontal position of top-left corner
  • y – Vertical position of top-left corner

For example, to crop a 1920×1080 video to 1440×810 starting at x=200, y=150:

ffmpeg -i input.mp4 -filter:v "crop=440:810:200:150" -c:a copy output.mp4
    
crop=1440:810:200:150

Some tips:

  • Use -filters:v to only crop video and not affect audio
  • Keep resolution divisible by 2 for optimal encoding
  • Use -c:a copy to stream copy audio and avoid re-encoding

You can also chain multiple crops. For example:

crop=1440:810:200:150,crop=720:400:250:200

This would crop the original, then crop the result again.

So in summary, the crop filter with w, h, x, and y positions can cleanly crop video using ffmpeg.