All posts
Scale video via CLI
ffmpeg pad letterboxes to a target size; a split + gblur fills the bars with a blurred frame.
Open online converterPackages to install
Only ffmpeg is required. Use libx264 for MP4 and libvpx-vp9 for WebM.
ffmpeg
sudo apt-get update
sudo apt-get install -y ffmpegHow to run the command
Fit with scale=W:H:force_original_aspect_ratio=decrease, then pad=W:H:(ow-iw)/2:(oh-ih)/2:color=0xRRGGBB. For a blurred backdrop, split the stream, cover-scale and gblur the background, then overlay the fitted video.
ffmpeg -y -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=0x000000,setsar=1" -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart output.mp4Dockerfile example
Build a minimal Ubuntu image with the required packages and run the conversion inside the container.
FROM ubuntu:24.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg && \
rm -rf /var/lib/apt/lists/*
WORKDIR /work
docker build -t scale-video .
docker run --rm -v "$PWD:/work" -w /work scale-video \
ffmpeg -y -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=0x000000,setsar=1" -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart output.mp4Example commands
Run these locally after installing the packages, or inside the container from the Dockerfile.
ffmpeg -y -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=0x000000,setsar=1" -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart output.mp4ffmpeg -y -i input.mp4 -filter_complex "[0:v]split=2[fg][bg];[bg]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,gblur=sigma=20[bg2];[fg]scale=1080:1920:force_original_aspect_ratio=decrease[fg2];[bg2][fg2]overlay=(W-w)/2:(H-h)/2,setsar=1[vout]" -map "[vout]" -map 0:a:0? -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart output.mp4