AnythingOnline
📐
Aspect Ratio Padding & Matte Calculator Audio, Video & Photography
100% Free • No Sign-Up

Aspect Ratio Padding & Matte Calculator

Calculate exact pixel padding (letterbox or pillarbox), scaled video dimensions, and FFmpeg pad filter parameters when fitting footage into any canvas.

Source & Destination Canvas Dimensions

Padding Type
--
Format transformation mode
Vertical Padding (Letterbox)
-- px
Horizontal Padding (Pillarbox)
-- px
Scaled Content Dimensions
-- × -- px
Matte Bar Area %
--%
FFmpeg Scale & Pad Filter
--

How Letterboxing and Pillarboxing Work

When placing video footage into a canvas with a different aspect ratio without cropping or anamorphic stretching, black bars (mattes) are added to preserve the original geometry:

  • Letterboxing: Added above and below the video when the source is wider than the target frame (e.g. 16:9 video placed into a 9:16 vertical TikTok canvas or 2.39:1 scope into 16:9).
  • Pillarboxing: Added to the left and right sides when the source is narrower than the target frame (e.g. classic 4:3 video placed into a 16:9 widescreen canvas).

Mathematical Derivation

Given source dimensions W_s, H_s and target canvas W_c, H_c:

  • Source Aspect Ratio: R_s = W_s / H_s; Canvas Aspect Ratio: R_c = W_c / H_c.
  • If R_s > R_c: Fit to width. Scaled width is W' = W_c; Scaled height is H' = round(W_c / R_s). Total vertical padding is P_v = H_c - H'. Top pad is floor(P_v / 2); bottom pad is P_v - Top pad.
  • If R_s < R_c: Fit to height. Scaled height is H' = H_c; Scaled width is W' = round(H_c × R_s). Total horizontal padding is P_h = W_c - W'. Left pad is floor(P_h / 2); right pad is P_h - Left pad.

Frequently Asked Questions

Why should scaled dimensions always be even numbers?

Most video codecs (H.264, HEVC, VP9, AV1) use 4:2:0 chroma subsampling, which stores color data across 2x2 pixel blocks. Odd pixel dimensions will cause encoding failures or color distortion in video pipelines.

How do I use this in FFmpeg?

The generated filter string can be passed directly to the -vf parameter, for example: ffmpeg -i input.mp4 -vf "scale=1080:608,pad=1080:1920:0:656:black" output.mp4.

What is windowboxing?

Windowboxing occurs when a video simultaneously has letterbox bars on top/bottom and pillarbox bars on the sides, typically caused by re-encoding a previously letterboxed video into a pillarboxed canvas.