🎯 Try StreamTranslate free for your next stream — 60-second setup, no card requiredStart Free Plan →
Blurred Background

Blurred background
vertical video in ffmpeg.

The full filter graph, what every single part of it does, how to batch it across a folder, and the three mistakes that produce broken output.

The command

Complete filter graph

ffmpeg -y -i input.mp4 -filter_complex "\
  [0:v]scale=1080:1920:force_original_aspect_ratio=increase,\
       crop=1080:1920,boxblur=40:4,setsar=1[bg];\
  [0:v]scale=1080:-2[fg];\
  [bg][fg]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[v]" \
  -map "[v]" -map 0:a? -c:v libx264 -preset veryfast -crf 20 \
  -c:a copy -movflags +faststart output.mp4
Breakdown

Every part, explained

FragmentWhat it does
[0:v]The video stream of input 0. Used twice — once for background, once for foreground.
force_original_aspect_ratio=increaseScales up until the frame covers the canvas, overflowing on one axis rather than fitting inside it.
crop=1080:1920Trims that overflow to exact canvas size, producing a full-bleed background.
boxblur=40:4Radius 40, 4 passes. Repeated box blur approximates gaussian at a fraction of the cost.
setsar=1Forces square pixels. Without it, mismatched sample aspect ratios between layers break the overlay.
scale=1080:-2Foreground at full width; height computed automatically and rounded even for H.264.
overlay=(W-w)/2:(H-h)/2Centres foreground over background on both axes using canvas and layer dimensions.
format=yuv420pMandatory for social platforms. Without it ffmpeg may emit yuv444p, which most uploaders reject.
-map 0:a?Includes audio only if present. The ? prevents a silent source from failing the job.
-movflags +faststartMoves the MP4 index to the front so the file streams before it finishes downloading.
Batch

Processing a whole folder

macOS / Linux

mkdir -p out
for f in *.mp4; do
  ffmpeg -y -i "$f" -filter_complex "\
    [0:v]scale=1080:1920:force_original_aspect_ratio=increase,\
         crop=1080:1920,boxblur=40:4,setsar=1[bg];\
    [0:v]scale=1080:-2[fg];\
    [bg][fg]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[v]" \
    -map "[v]" -map 0:a? -c:v libx264 -preset veryfast -crf 20 \
    -c:a copy -movflags +faststart "out/${f%.mp4}-vertical.mp4"
done

Windows (PowerShell)

mkdir out -Force
Get-ChildItem *.mp4 | ForEach-Object {
  ffmpeg -y -i $_.Name -filter_complex "[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,boxblur=40:4,setsar=1[bg];[0:v]scale=1080:-2[fg];[bg][fg]overlay=(W-w)/2:(H-h)/2:format=auto,format=yuv420p[v]" -map "[v]" -map 0:a? -c:v libx264 -preset veryfast -crf 20 -c:a copy -movflags +faststart "out/$($_.BaseName)-vertical.mp4"
}
Failure modes

Three mistakes that break output

01

Missing yuv420p

The file encodes fine and plays locally, then fails to upload with an unhelpful error. Always end the chain with format=yuv420p.

02

Hardcoded height

Works for exactly-16:9 sources, silently stretches everything else. Use -2 and let ffmpeg compute it.

03

Missing setsar=1

Sources with non-square pixels produce a distorted or failed overlay. Cheap to add, annoying to debug.

Performance

Speeding it up

The blur is the expensive filter. If you're processing at volume:

  • Blur a smaller layer. Scale down, blur, then scale back up — visually near-identical, meaningfully cheaper, since the result is heavily blurred anyway.
  • Keep -preset veryfast. The blurred region conceals most encoding artefacts, so slower presets buy very little here.
  • Don't touch the audio. -c:a copy skips audio re-encoding entirely.
# cheaper background: downscale → blur → upscale
[0:v]scale=270:480,boxblur=10:4,scale=1080:1920,setsar=1[bg];
FAQ

Common questions

What does boxblur=40:4 mean?

Radius 40 pixels, applied over 4 passes. Multiple passes of box blur approximate a gaussian blur at much lower computational cost.

Why use -2 instead of a fixed height?

It tells ffmpeg to compute the height from the width while preserving aspect ratio and rounding to an even number, which H.264 requires. A fixed height distorts any source that isn't exactly 16:9.

Can I use GPU acceleration?

Yes — h264_nvenc, h264_qsv, or h264_videotoolbox can replace libx264 for encoding. The blur filter itself still runs on CPU unless you use the CUDA filter chain.

How do I make the blur stronger?

Increase the boxblur radius. Values between 30 and 50 work well; beyond that the background loses all structure and stops reading as related to the foreground.

Related