Resize and Crop
Scale videos to any resolution, crop specific regions, maintain aspect ratios, and prepare content for different social media platforms.
Why Resize and Crop?
Videos rarely arrive in the exact dimensions you need. A 4K camera recording needs to become a 1080p web upload. A landscape video needs to become a portrait reel. A wide-angle shot has dead space on the edges that should be cropped out.
FFmpeg handles all of this through its filter system. The two filters you will use most are scale (for resizing) and crop (for trimming edges).
The Video Filter Flag: -vf
All video filters in FFmpeg are applied using the -vf flag (short for -filter:v). You pass a filter name and its parameters:
You can chain multiple filters together with commas:
Filters are applied left to right, so this crops first, then scales the cropped result.
Scaling (Resizing) Videos
Basic scale: set exact dimensions
This forces the output to exactly 1280x720 pixels, regardless of the input size. If the aspect ratio does not match, the video will be distorted (stretched or squished).
Scale by width, preserve aspect ratio
Setting one dimension to -1 tells FFmpeg to calculate it automatically from the other dimension while preserving the aspect ratio. A 1920x1080 input becomes 1280x720. A 1920x800 input becomes 1280x533.
Gotcha: Some codecs require even dimensions. If -1 produces an odd height, encoding will fail. Use -2 instead to round to the nearest even number:
Scale by height, preserve aspect ratio
Same idea, but anchoring on height. Useful when you need a specific vertical resolution (e.g. 720p) regardless of the aspect ratio.
Scale down only (never upscale)
Upscaling a 720p video to 1080p adds pixels but no detail — the result looks blurry. You can prevent upscaling with a conditional expression:
iw and ih are built-in variables for the input width and height. This caps the output at 1280x720 but leaves smaller videos untouched.
Cropping Videos
The crop filter cuts a rectangular region from the frame. Its syntax is:
Where x and y are the top-left corner of the crop region. If omitted, the crop is centered.
Center crop to 1:1 (square)
This takes the input height as both the width and height, creating a centered square crop. For a 1920x1080 video, this produces a 1080x1080 square from the center.
Crop to 9:16 (vertical / portrait)
This calculates the 9:16 width from the input height, producing a centered vertical crop. Perfect for converting landscape footage into portrait format for Instagram Reels or TikTok.
Crop from a specific position
Extracts a 640x480 rectangle starting at pixel position (100, 50) from the top-left corner. Useful when you need to isolate a specific region of the frame.
Remove black bars (letterbox / pillarbox)
FFmpeg can automatically detect and remove black bars using the cropdetect filter. First, detect the crop values:
Look at the output for lines like crop=1920:800:0:140, then use those values:
Social Media Presets
Different platforms have different size requirements. Here are ready-to-use commands for the most common targets:
YouTube (1080p landscape)
Scales to fit within 1920x1080 and adds letterbox padding if needed.
Instagram Reels / TikTok (1080x1920 portrait)
Center-crops to 9:16, then scales to 1080x1920.
Twitter / X (1280x720 landscape)
Instagram Feed (1080x1080 square)
Combining Scale and Crop with Padding
Sometimes you want to fit a video into a specific frame size without cropping any content. The pad filter adds colored bars (default black) to fill the space:
This is a three-step chain: first it scales the video to fit within 1920x1080 while preserving aspect ratio, then it pads the result to exactly 1920x1080 by centering it on a black background. The expression (ow-iw)/2 calculates the offset needed to center horizontally.
You can change the padding color to white, a brand color, or any hex value:
Performance Tips
- Scale before crop when downscaling and cropping — the crop operates on fewer pixels.
- Crop before scale when upscaling — scale only the region you need.
- Use
-c:a copyto pass through audio untouched when you are only modifying the video. - Always use
-2instead of-1for automatic dimensions to avoid odd-number errors.
Key Takeaways
- Use
-vf "scale=W:H"to resize — set one dimension to-2to auto-calculate the other - Use
-vf "crop=W:H:X:Y"to extract a region — omit X and Y for center crop - Chain filters with commas:
"crop=...,scale=..." - Use
padto add bars instead of cropping content - Always test with a short clip before processing an entire library
Try This With FFmpeg Micro
Instead of running FFmpeg locally, you can use FFmpeg Micro's API to process videos in the cloud. No installation required.