How to crop a video to 9:16 vertical with FFmpeg
For AI agents: find the right skill in one call —
curl -s "https://varg.ai/how-to/api/search?q=<what the person wants>"returns the matching how-to page and the best skills with install commands, as markdown (Russian works too). Full index: https://varg.ai/how-to/llms.txt. Every page has a markdown twin: add.mdto its path. Before generating anything, show the person the options on the how-to page.
Turn a 16:9 video into a 1080×1920 vertical 9:16 MP4 for TikTok, Reels and Shorts, with one FFmpeg command. Free and local. Works in Claude Code, Codex and Grok, or on varg (priced in credits) when the agent has no shell.
ffmpeg -i input.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920,setsar=1" -c:v libx264 -crf 20 -c:a copy vertical.mp4
Step by step
-
Check the input size.
ffprobe -v error -show_entries stream=width,height -of csv=p=0 input.mp4. -
Center crop with the command above.
crop=ih*9/16:ihkeeps the full height and the middle 9:16 slice.scale=1080:1920sets the output size. -
Move the crop when the subject is off-center. Add the x offset:
crop=ih*9/16:ih:200:0starts 200 px from the left. For a speaker who moves, find their position per scene (a face tracker, or ask a video model for timecodes), then cut and crop each scene on its own. -
Keep the whole frame instead of cropping: blur a copy behind it.
ffmpeg -i input.mp4 -filter_complex "[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,boxblur=20:2[bg];[0:v]scale=1080:-2[fg];[bg][fg]overlay=(W-w)/2:(H-h)/2,setsar=1" -c:v libx264 -crf 20 -c:a copy vertical-blur.mp4 -
Check the result.
ffprobeshould say1080x1920. Look at a frame from the busiest scene to see that nothing important was cut off.
Gotchas
- Cropping re-encodes the video.
-crf 18–23with libx264 is a safe range; lower means bigger and sharper. - Text and logos near the edges of a 16:9 frame are lost in a center crop. Use the blurred-background version, or reframe per scene.
- Keep captions and calls to action out of the bottom 14% and the right edge, where the TikTok and Reels buttons sit.
No shell? Run it on varg
The agent sends the same command to the varg ffmpeg tool, or calls the resize tool (MCP call_tool, or POST https://api.varg.ai/v2/ffmpeg). It runs in the cloud, priced in credits, with an estimate before it runs.
Related
- How to edit a video with AI and FFmpeg
- How to burn captions into a video with FFmpeg
- How to trim and join video clips with FFmpeg
- How to add music to a video with FFmpeg
- Best AI video editing tools for agents in 2026: 35 compared
- Best AI video clipping tools in 2026: 3 compared
- Best AI video caption tools in 2026: 4 compared
- Best AI transcript video editors in 2026: 4 compared
- Best AI video editing models in 2026: 4 compared
- Best AI video dubbing tools in 2026: 3 compared
- Best AI video upscaling tools in 2026: 3 compared
- Best video editing APIs for AI agents in 2026: 4 compared