C.W.K.
Stream
Lesson 04 of 10 · published

Resolution Scaling

~10 min · scale, resolution, aspect-ratio

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

The scale filter

Resolution changes go through -vf scale=W:H. Width and height accept literal pixels (1280:720), the special value -1 (preserve aspect ratio, must be divisible by 2), or expressions (iw/2:ih/2).

Aspect-ratio safe scaling

Hard-coding both dimensions can squish video. Two patterns to remember:

  • scale=1280:-2 — width is 1280, height auto-computed and rounded to even (H.264/H.265 require even dimensions).
  • scale=-2:720 — height is 720, width auto.
  • scale=iw/2:ih/2 — half size, exact ratio preserved.

Upscaling vs downscaling

Downscaling is lossless in perceptual terms — you're throwing pixels away. Upscaling is lossy in perceptual terms — you're inventing pixels. scale uses bicubic by default, which is fine for downscaling and acceptable for moderate upscaling. For aggressive upscaling (480p → 4K) consider AI-based tools (Topaz, esrgan) or the realesrgan_ncnn filter on Linux.

Code

Common scale recipes·bash
# To 720p, preserve aspect
ffmpeg -i in.mp4 -vf scale=1280:-2 -c:v libx264 -crf 22 -c:a copy out_720.mp4

# To 1080p
ffmpeg -i in.mp4 -vf scale=1920:-2 -c:v libx264 -crf 20 -c:a copy out_1080.mp4

# Half size
ffmpeg -i in.mp4 -vf scale=iw/2:ih/2 -c:v libx264 -crf 23 -c:a copy out_half.mp4

# Force exact dimensions (will distort if aspect ratio differs)
ffmpeg -i in.mp4 -vf scale=1024:768 -c:v libx264 -crf 23 -c:a copy out_squish.mp4
Better scaling algorithm — Lanczos·bash
# For downscale work where every pixel matters
ffmpeg -i in.mp4 \
  -vf scale=1280:-2:flags=lanczos \
  -c:v libx264 -crf 20 -c:a copy out_lanczos.mp4

# Lanczos is a sharper sinc-based filter than bicubic. Sharper = good
# for content with text/lines, slightly more aliasing for soft footage.

External links

Exercise

Take a 4K source. Downscale to 1080p two ways: default bicubic (scale=1920:-2) and Lanczos (scale=1920:-2:flags=lanczos). Look at high-frequency areas (text, foliage). Can you see the sharpness difference at 100% pixel-zoom? Save your two outputs and the source for the rest of the track.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.