Resize a video in one command
ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4
That's the simplest way to resize video with FFmpeg, taking input.mp4 and outputting it at 1280x720 pixels. If your source is 1920x1080, the aspect ratio matches and everything looks fine. If your source is 4:3 or vertical, the output gets stretched. Usually not what you want.
This guide covers how to resize without distortion, how to crop and pad for different platforms, which scaling algorithm to pick, and how to batch-process hundreds of files. There's also an API approach at the end for when you don't want FFmpeg on your server at all.
New to FFmpeg? The has 50 commands organized by task, including several resize recipes. For a focused reference on the scale filter itself, algorithm selection, and common errors, see the explains CRF tuning in more detail.
TikTok / Instagram Reels (9:16, 1080x1920):
ffmpeg -i input.mp4 -vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2" \
-c:v libx264 -crf 20 -c:a aac -b:a 128k output_tiktok.mp4
If your source is landscape, this letterboxes it vertically. For a better result with landscape source footage, crop to the center first:
ffmpeg -i landscape.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" \
-c:v libx264 -crf 20 -c:a aac output_tiktok.mp4
TikTok's upload limit is 10 minutes and 4GB as of early 2026. They re-encode aggressively on their end, so there's no benefit in going below CRF 18 or uploading at 4K. 1080x1920 at CRF 20 gives a good size-to-quality tradeoff for TikTok's re-encoding pipeline.
Instagram Square (1:1, 1080x1080):
ffmpeg -i input.mp4 -vf "crop=min(iw\,ih):min(iw\,ih),scale=1080:1080" \
-c:v libx264 -crf 20 -c:a aac output_ig.mp4
Crops to a square from the center, then scales to 1080x1080.
Twitter/X (16:9, 1280x720):
ffmpeg -i input.mp4 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" \
-c:v libx264 -crf 23 -c:a aac -b:a 128k output_twitter.mp4
Twitter compresses aggressively on their end. No point going above 720p.
LinkedIn (16:9, 1920x1080, max 10 min):
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" \
-c:v libx264 -crf 22 -preset medium -c:a aac -b:a 128k -t 600 -movflags +faststart output_linkedin.mp4
LinkedIn caps video at 10 minutes, so -t 600 trims to that limit. If you need more precise will make a bigger difference than any filter flag.
Rotate and flip: fix orientation problems
Phone videos sometimes have wrong rotation metadata. Or you need to flip footage for a mirror effect.
# Rotate 90 degrees clockwise
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
# Rotate 90 degrees counter-clockwise
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4
# Rotate 180 degrees
ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" output.mp4
# Flip horizontally (mirror)
ffmpeg -i input.mp4 -vf "hflip" output.mp4
# Flip vertically
ffmpeg -i input.mp4 -vf "vflip" output.mp4
The transpose values: 0 = 90° counter-clockwise + vertical flip, 1 = 90° clockwise, 2 = 90° counter-clockwise, 3 = 90° clockwise + vertical flip. I never remember these either, which is why I keep the , put the overlay filter last: transpose=1,scale=1920:1080,overlay=....
Batch resize: process an entire folder
Single file commands are fine until you have 200 files to resize. Here's a shell script that handles an entire directory:
#!/bin/bash
INPUT_DIR="./raw"
OUTPUT_DIR="./resized"
mkdir -p "$OUTPUT_DIR"
for f in "$INPUT_DIR"/*.mp4; do
filename=$(basename "$f")
ffmpeg -i "$f" -vf "scale=1280:-2:flags=lanczos" \
-c:v libx264 -crf 23 -c:a aac -b:a 128k \
"$OUTPUT_DIR/$filename" -y
done
echo "Done. Processed $(ls "$OUTPUT_DIR" | wc -l) files."
Multi-resolution batch (generate multiple sizes at once):
#!/bin/bash
for f in ./input/*.mp4; do
name=$(basename "$f" .mp4)
ffmpeg -i "$f" \
-vf "scale=1920:-2:flags=lanczos" -c:v libx264 -crf 22 "./output/${name}_1080p.mp4" \
-vf "scale=1280:-2:flags=lanczos" -c:v libx264 -crf 23 "./output/${name}_720p.mp4" \
-vf "scale=854:-2:flags=lanczos" -c:v libx264 -crf 25 "./output/${name}_480p.mp4"
done
This generates 1080p, 720p, and 480p versions in one pass per file. Useful for creating multiple quality tiers for an adaptive video player.
Parallel processing with xargs:
find ./raw -name "*.mp4" | xargs -P 4 -I {} bash -c \
'ffmpeg -i "{}" -vf "scale=1280:-2:flags=lanczos" -c:v libx264 -crf 23 "./resized/$(basename {})" -y'
The -P 4 flag runs 4 FFmpeg processes simultaneously. Adjust based on your CPU cores. On an 8-core machine, -P 4 is a safe bet that leaves headroom for the OS. Going higher risks thrashing.
For heavier workloads, the break down the cost math at different volumes.
With and try it with one of the commands above. For language-specific examples, see the API guides.
If you're building automation workflows, the walk through connecting RenderIO to those platforms step by step.
Common pitfalls (and how to avoid them)
Odd dimensions crash the encoder. H.264 and H.265 require width and height divisible by 2. Some codecs need divisibility by 4 or even 16. Always use -2 instead of -1 in scale expressions, or add a safety-net filter:
-vf "scale=1280:-2,pad=ceil(iw/2)*2:ceil(ih/2)*2"
Upscaling doesn't add detail. Scaling a 480p video to 1080p doesn't improve quality. You're just interpolating between existing pixels. FFmpeg won't warn you about this. If you must upscale, use flags=spline and accept that the output will look softer than native 1080p. Check the source resolution first with or goes deeper on tuning CRF per resolution.
Container format compatibility. After resizing, make sure your output container supports the codec you're using. MP4 with H.264 works everywhere. MKV is more flexible but won't play natively in browsers. The or offloading to an handles concurrency and storage so you don't have to manage worker processes.
What resolution should I use for TikTok, Instagram, or YouTube?
TikTok and Instagram Reels: 1080x1920 (9:16 vertical). Instagram feed square: 1080x1080. YouTube: 1920x1080 (16:9). Twitter/X: 1280x720. The platform presets section above has ready-to-copy commands for each one, including proper aspect ratio handling and codec settings.
Quick reference
Here's everything from this guide condensed:
# Resize to exact dimensions
ffmpeg -i in.mp4 -vf "scale=1280:720" out.mp4
# Resize with auto-height (keep aspect ratio)
ffmpeg -i in.mp4 -vf "scale=1280:-2" out.mp4
# Downscale only (no upscaling)
ffmpeg -i in.mp4 -vf "scale='min(1920,iw)':'min(1080,ih)':force_original_aspect_ratio=decrease" out.mp4
# Center crop to square
ffmpeg -i in.mp4 -vf "crop=ih:ih" out.mp4
# Letterbox into 16:9
ffmpeg -i in.mp4 -vf "scale=-2:1080,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" out.mp4
# TikTok vertical from landscape
ffmpeg -i in.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" out.mp4
# Rotate 90° clockwise
ffmpeg -i in.mp4 -vf "transpose=1" out.mp4
# Batch resize folder
for f in *.mp4; do ffmpeg -i "$f" -vf "scale=1280:-2:flags=lanczos" -c:v libx264 -crf 23 "resized_$f"; done
Want the full list of common FFmpeg operations? The covers H.264, H.265, AV1, and VP9 conversions. Working with container formats? The formats reference explains which codecs fit inside which containers.
SOCIAL SHARE CARD GENERATOR