How to burn captions into a video 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 video and an SRT file into an MP4 with the captions burned into the picture, in 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 "subtitles=subs.srt:force_style='FontName=Arial,FontSize=14,Bold=1,Outline=2,Alignment=2,MarginV=60'" -c:v libx264 -crf 20 -c:a copy captioned.mp4
Step by step
-
Get the captions as SRT. Transcribe with word timestamps: Whisper, Groq Whisper or ElevenLabs Scribe. Keep lines short (2–5 words for Shorts) and check names and numbers by hand.
-
Check the input.
ffprobe -v error -show_entries stream=codec_type,width,height -of compact=p=0 input.mp4shows the size, so you can set the font size and margin for it. -
Burn them in with the command above.
force_styletakes ASS style fields.Alignment=2is bottom centre andMarginVlifts the text off the edge. On 9:16 video, keep it out of the bottom 14% where TikTok and Reels put their buttons. -
For styled or word-by-word captions, use ASS. Convert with
ffmpeg -i subs.srt subs.ass, edit the styles or add karaoke tags in the.assfile, then burn it in:ffmpeg -i input.mp4 -vf "ass=subs.ass" -c:v libx264 -crf 20 -c:a copy captioned.mp4 -
Check the result. Grab a frame where a caption shows (
ffmpeg -ss 2 -i captioned.mp4 -frames:v 1 frame.png) and look at it before you deliver.
Soft subtitles instead
To give viewers captions they can switch on and off, mux the SRT as a track. Nothing is re-encoded:
ffmpeg -i input.mp4 -i subs.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4
Gotchas
subtitlesandassneed FFmpeg built with libass. Runffmpeg -filters | grep subtitles. If it prints nothing, install a full build (brew install ffmpeg-fullon macOS, a static build, ornpx ffmpeg-static).- Burning in re-encodes the video, so set the quality (
-crf 18–23). The audio can stay-c:a copy. - A font must be installed on the machine. Add
:fontsdir=./fontsto point at your own. - Animated captions (bounce, highlight the spoken word, emoji) are easier in Remotion or HyperFrames than in ASS. See the caption skills below.
No shell? Run it on varg
The agent sends the same command to the varg ffmpeg 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. Inputs and outputs are URLs.
Related
- How to edit a video with AI and FFmpeg
- How to crop a video to 9:16 vertical 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