Skip to main content
Scale a video to a target resolution (e.g., 1280×720 or 1920×1080) and letterbox where needed to preserve the source aspect ratio.

Code

How the FFmpeg command works

  • scale=1280:720:force_original_aspect_ratio=decrease — fit inside 1280×720, keep aspect ratio
  • pad=1280:720:(ow-iw)/2:(oh-ih)/2 — letterbox with black bars centered
  • -c:v libx264 — re-encode video with H.264 (required after scaling)
  • -c:a copy — pass audio through unchanged (faster than re-encoding)
  • {{out_1}} — output file
For stretch-to-fit without letterbox, drop the pad filter. For crop-to-fit, change decrease to increase and add crop=1280:720.

Response