DEV Community

Nguyen Bin
Nguyen Bin

Posted on Edited on

How to Auto-Reframe 16:9 Video to 9:16 Vertical with Blurred Background & Karaoke Captions Using Only FFmpeg

Every YouTube creator, indie dev, and video editor runs into the exact same repetitive task: you finish a horizontal 16:9 (1920x1080) video, and now you need vertical 9:16 (1080x1920) clips for YouTube Shorts, TikTok, and Instagram Reels.

Most cloud editors lock 1080p export, blurred-background reframing, and word-highlighted captions behind $20–$30/month subscriptions — and force you to upload gigabytes of raw video before you can even preview a clip.

You can do the entire pipeline 100% locally in seconds using a single FFmpeg filtergraph and an .ass subtitle file. Here is the exact production recipe.


1. The One-Liner FFmpeg Filtergraph (16:9 → 9:16 Blurred Pillar Frame)

Instead of ugly black bars or cropping off 68% of your screen, the cleanest social format scales a heavily blurred copy to fill 1080x1920 behind a razor-sharp foreground centered cleanly in the middle:

ffmpeg -y -i input_16x9.mp4 -filter_complex \
"[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,gblur=sigma=32,eq=brightness=-0.08[bg]; \
 [0:v]scale=1080:-2:force_original_aspect_ratio=decrease[fg]; \
 [bg][fg]overlay=(W-w)/2:(H-h)/2,format=yuv420p[vout]" \
-map "[vout]" -map 0:a? \
-c:v libx264 -preset fast -crf 19 \
-c:a aac -b:a 192k -ar 48000 \
output_9x16.mp4
Enter fullscreen mode Exit fullscreen mode

Why each flag matters:

  • force_original_aspect_ratio=increase,crop=1080:1920 fills the vertical canvas with zero distortion.
  • gblur=sigma=32,eq=brightness=-0.08 creates a soft, slightly darkened background so foreground video and captions pop effortlessly.
  • scale=1080:-2 guarantees an even height (required by yuv420p / H.264).

2. Batch-Convert an Entire Folder of Clips with 18 Lines of Python

Drop all your horizontal clips into ./clips_in/ and convert them overnight with normalized -14 LUFS audio (TikTok/Shorts loudness standard):

import subprocess
from pathlib import Path

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

FILTER = (
    "[0:v]scale=1080:1920:force_original_aspect_ratio=increase,"
    "crop=1080:1920,gblur=sigma=32,eq=brightness=-0.08[bg];"
    "[0:v]scale=1080:-2:force_original_aspect_ratio=decrease[fg];"
    "[bg][fg]overlay=(W-w)/2:(H-h)/2,format=yuv420p[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", f"{FILTER};[0:a]loudnorm=I=-14:TP=-1.5:LRA=7[a]",
        "-map", "[v]", "-map", "[a]",
        "-c:v", "libx264", "-preset", "fast", "-crf", "19",
        "-c:a", "aac", "-b:a", "192k", str(dst),
    ]
    subprocess.run(cmd, check=True)
    print(f"Exported -> {dst}")
Enter fullscreen mode Exit fullscreen mode

3. Adding High-Retention Hormozi-Style Word-Pop Captions via .ass

SubRip (.srt) files look plain and cannot animate word-by-word highlights. Advanced SubStation Alpha (.ass) gives you bold yellow/white active-word karaoke highlights, crisp black outlines, and safe vertical placement above TikTok/Reels UI buttons — rendered directly by FFmpeg (-vf "ass=captions.ass"):

[Script Info]
ScriptType: v4.00+
PlayResX: 1080
PlayResY: 1920

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Pop,Arial Black,78,&H00FFFFFF,&H0000D7FF,&H00000000,&H80000000,-1,0,1,6,2,2,60,60,340,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:02.40,Pop,,0,0,0,,{\k45}STOP {\k55}PAYING {\k60}{\c&H0015D7FF&}MONTHLY {\k80}FEES
Enter fullscreen mode Exit fullscreen mode

Notice MarginV=340: on a 1920px vertical canvas, placing captions 340px above the bottom keeps them 100% clear of TikTok/Shorts descriptions and like buttons.


Grab the Ready-to-Run Free Starter Pack ($0+) or Full Local Studio

You can copy-paste every command above right now — zero strings attached.

If you want the packaged 1-click ready-to-run bundle (with 3 pre-tuned .ass karaoke templates, batch Python converter, and FFmpeg cheat sheet):

What FFmpeg filtergraphs save you the most editing hours every week? Share yours in the comments!

Top comments (1)

Collapse
 
clickpopai profile image
ClickPop Team •

The blurred background fill is a nice touch versus a hard crop. One thing worth checking is where the captions land after reframing, since the lower third of a 9:16 frame is mostly covered by the app's own buttons.