FFmpeg Crop Video to Bottom Right Corner

This article provides a straightforward guide on how to crop a video to its bottom-right corner using FFmpeg’s built-in crop filter and variable names. You will learn the exact command syntax, how the coordinate variables work, and how to apply this to any video resolution.

To crop a video in FFmpeg, you use the crop filter, which follows this basic syntax:

crop=out_w:out_h:x:y

Using Variables for the Bottom-Right Corner

FFmpeg provides shorthand variable names that allow you to calculate the bottom-right position dynamically, without needing to know the input video’s exact dimensions beforehand:

To target the bottom-right corner, your starting coordinates (x and y) must shift all the way to the right and bottom edges. You calculate this by subtracting the output dimensions from the input dimensions:

The FFmpeg Command

To crop a video to a specific size (for example, a width of 640 pixels and a height of 480 pixels) at the bottom-right corner, run the following command:

ffmpeg -i input.mp4 -vf "crop=640:480:iw-ow:ih-oh" output.mp4

How It Works

  1. 640:480: Defines the size of your cropped output window. This sets ow to 640 and oh to 480.
  2. iw-ow: Calculates the starting horizontal coordinate. By subtracting 640 from the total input width, the crop box is pushed to the far right edge.
  3. ih-oh: Calculates the starting vertical coordinate. By subtracting 480 from the total input height, the crop box is pushed to the very bottom edge.

This formula dynamically scales to any input video resolution, ensuring the cropped area always aligns perfectly with the bottom-right corner of your source file.