DEV Community

Nguyen Bin
Nguyen Bin

Posted on

Stop Opening Premiere for Vertical Clips: A 1-Command FFmpeg Filter Complex for 9:16 Blurred Shorts

If you convert 16:9 YouTube tutorials, screen recordings, or podcasts into 9:16 vertical Shorts/Reels/TikToks, opening a heavy NLE just to stack a blurred background behind a centered clip is massive overkill.

You can automate the entire pipeline — blurred 9:16 backdrop, sharp centered 16:9 foreground, broadcast -14 LUFS loudness normalization, and iOS/TikTok-safe yuv420p H.264 encoding — with a single FFmpeg filter_complex and a tiny Python batch wrapper.


1. The One-Line FFmpeg Filter Complex

Here is the production command that converts any 16:9 MP4 into a crisp 1080x1920 vertical clip with zero stretching and zero black bars:

ffmpeg -y -i input.mp4 \
  -filter_complex "\
    [0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,boxblur=24:4,eq=brightness=-0.08:saturation=1.15[bg]; \
    [0:v]scale=1080:-2:force_original_aspect_ratio=decrease[fg]; \
    [bg][fg]overlay=(W-w)/2:(H-h)/2,setsar=1[v]" \
  -map "[v]" -map 0:a? \
  -af "loudnorm=I=-14:TP=-1.5:LRA=11" \
  -c:v libx264 -preset medium -crf 18 -pix_fmt yuv420p \
  -c:a aac -b:a 192k -movflags +faststart \
  output_9x16.mp4
Enter fullscreen mode Exit fullscreen mode

Why Every Single Flag Matters (Bugs This Avoids)

  1. scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920 Scales the background proportionally until it fills the entire 1080x1920 vertical canvas, then center-crops cleanly so there is zero aspect-ratio distortion.
  2. boxblur=24:4,eq=brightness=-0.08:saturation=1.15 Heavy blur (luma_radius=24, 4 passes) plus a subtle -0.08 darkening makes the sharp foreground video pop immediately without competing visually.
  3. scale=1080:-2 The -2 (instead of -1) guarantees the computed height is divisible by 2 — preventing the classic libx264: height not divisible by 2 crash on odd-resolution screen captures.
  4. -pix_fmt yuv420p + -movflags +faststart Without yuv420p, QuickTime and mobile social apps often render a black video track (especially when the source is 10-bit or 4:4:4 OBS output). +faststart moves the moov atom to the front for instant mobile playback.
  5. -af "loudnorm=I=-14:TP=-1.5:LRA=11" Matches YouTube Shorts / Reels / TikTok loudness normalization (-14 LUFS, -1.5 dBTP true peak ceiling) so your clip doesn't get crushed or sound whisper-quiet next to other videos.

2. Batch-Convert an Entire Folder in 25 Lines of Python

Drop this script next to a folder of clips (clips_in/) and run python batch_reframe.py:

import subprocess
from pathlib import Path

IN_DIR = Path("clips_in")
OUT_DIR = Path("clips_9x16")
OUT_DIR.mkdir(exist_ok=True)

FILTER = (
    "[0:v]scale=1080:1920:force_original_aspect_ratio=increase,"
    "crop=1080:1920,boxblur=24:4,eq=brightness=-0.08:saturation=1.15[bg];"
    "[0:v]scale=1080:-2:force_original_aspect_ratio=decrease[fg];"
    "[bg][fg]overlay=(W-w)/2:(H-h)/2,setsar=1[v]"
)

for src in sorted(IN_DIR.glob("*.mp4")):
    dst = OUT_DIR / f"{src.stem}_9x16.mp4"
    cmd = [
        "ffmpeg", "-y", "-i", str(src),
        "-filter_complex", FILTER,
        "-map", "[v]", "-map", "0:a?",
        "-af", "loudnorm=I=-14:TP=-1.5:LRA=11",
        "-c:v", "libx264", "-preset", "medium", "-crf", "18",
        "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "192k",
        "-movflags", "+faststart", str(dst),
    ]
    print(f"Reframing {src.name} -> {dst.name}")
    subprocess.run(cmd, check=True)
Enter fullscreen mode Exit fullscreen mode

3. Bonus: Hardware Acceleration on NVIDIA GPUs

If you batch-process dozens of 4K clips on an NVIDIA card, swap -c:v libx264 -preset medium -crf 18 for NVENC:

-c:v h264_nvenc -preset p6 -rc vbr -cq 19 -pix_fmt yuv420p
Enter fullscreen mode Exit fullscreen mode

On a mid-range RTX card, a 60-second 1080p clip renders in ~2.5 seconds instead of ~18 seconds on CPU.


Want the Turnkey Offline Starter Bundle?

Everything above is free to copy and tweak! If you want a ready-to-run ZIP containing the complete batch reframer script (with auto aspect-ratio detection & split-screen mode), 12 copy-paste FFmpeg creator recipes, plus our 20KB zero-dependency Offline HTML PDF Invoice Generator, you can grab the Offline Dev & Creator Starter Code Kit ($2.99 one-time, zero subscriptions) here:

👉 Offline Dev & Creator Starter Code Kit ($2.99 on Payhip)

What FFmpeg filter chains do you keep in your personal cheat sheet? Drop your favorite one-liner below!

Top comments (5)

Collapse
 
ahmetozel profile image
Ahmet Özel •

Explaining why each flag is there—especially scale=1080:-2 to prevent libx264 failures on odd-height screen captures, yuv420p for QuickTime and mobile compatibility on 10-bit OBS sources, and +faststart for immediate streaming playback—turns a one-liner into a genuinely reusable production recipe.

One small optimization when batching dozens of clips with loudnorm: single-pass dynamic normalization works well for quick turnarounds, while a two-pass loudnorm measurement avoids pumping artifacts on quiet talking-head segments. Adding setsar=1 right after the overlay also eliminates subtle aspect-ratio quirks on social upload pipelines.

Collapse
 
apexaistudio profile image
Nguyen Bin •

Spot-on catch on single-pass vs. two-pass loudnorm! On talking-head clips with long silent breaths or dramatic pauses, single-pass dynamic mode definitely pumps the room tone right back up between sentences.

For production batch runs, doing a quick measurement pass with print_format=json and feeding measured_I / measured_LRA / measured_TP / measured_thresh into linear=true completely eliminates that pumping:

# Pass 1: measure true loudness stats
ffmpeg -i input.mp4 -af "loudnorm=I=-14:TP=-1.5:LRA=11:print_format=json" -f null -

# Pass 2: apply linear gain (zero pumping)
ffmpeg -y -i input.mp4 -af "loudnorm=I=-14:TP=-1.5:LRA=11:measured_I=-22.4:measured_LRA=6.8:measured_TP=-3.1:measured_thresh=-33.0:linear=true" ...
Enter fullscreen mode Exit fullscreen mode

And huge +1 on setsar=1 right after overlay — non-square SAR from screen capture tools or older cameras has bitten me on Shorts uploads before too. Appreciate you adding that for anyone copying the batch pipeline!

Collapse
 
ahmetozel profile image
Ahmet Özel •

Sharing that exact two-pass loudnorm snippet with print_format=json and linear=true is super helpful—seeing measured_I, measured_LRA, measured_TP, and measured_thresh wired directly into pass two saves anyone automating talking-head batches from guessing the parameter names. Glad setsar=1 resonated too; non-square SAR from mixed capture tools is one of those bugs you only catch after an upload looks subtly squished.

Thread Thread
 
apexaistudio profile image
Nguyen Bin •

Your point about talking-head pumping actually inspired me to write up the full zero-dependency Python wrapper (two_pass_loudnorm.py) that parses FFmpeg's Pass-1 JSON output automatically and locks Pass 2 into linear=true (including the offset and -ar 48000 sample-rate gotcha): dev.to/apexaistudio/two-pass-loudn...

Thanks again for kicking off such a solid thread!

Thread Thread
 
ahmetozel profile image
Ahmet Özel •

Nice—turning that into a zero-dependency two-pass Python wrapper that auto-parses Pass-1 JSON and includes the -ar 48000 fix saves a lot of silent headaches. That 192 kHz internal upsampling quirk in FFmpeg's loudnorm filter catches almost everyone until file sizes spike or mobile players reject the audio stream.