Back to roadmaps ffmpeg Course

Resizing and Cropping Video with Video Filters

FFmpeg video filters (-vf) allow you to transform video frames before encoding. Scaling and cropping are the most common operations.


1. Scaling Video Resolution

To scale a video to a specific width while maintaining the aspect ratio (set height to -1 to auto-calculate):

# Resize to 1280px width, auto-calculate height
ffmpeg -i input.mp4 -vf "scale=1280:-1" output_1280.mp4

To scale to a fixed resolution:

# Scale to exactly 1920x1080
ffmpeg -i input.mp4 -vf "scale=1920:1080" output_fhd.mp4

2. Cropping Video Regions

The crop filter extracts a rectangular region from the video frame. The syntax is crop=width:height:x:y where x and y define the top-left corner position:

# Crop a 640x480 region starting from position x=100, y=50
ffmpeg -i input.mp4 -vf "crop=640:480:100:50" output_cropped.mp4

3. Chaining Filters Together

You can chain multiple filters in a single command using commas:

# Scale to 1280px width, then crop to 1280x720
ffmpeg -i input.mp4 -vf "scale=1280:-1,crop=1280:720:0:0" output_hd.mp4
Published on Last updated: