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 .md to 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

  1. 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.

  2. Check the input. ffprobe -v error -show_entries stream=codec_type,width,height -of compact=p=0 input.mp4 shows the size, so you can set the font size and margin for it.

  3. Burn them in with the command above. force_style takes ASS style fields. Alignment=2 is bottom centre and MarginV lifts the text off the edge. On 9:16 video, keep it out of the bottom 14% where TikTok and Reels put their buttons.

  4. 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 .ass file, then burn it in:

    ffmpeg -i input.mp4 -vf "ass=subs.ass" -c:v libx264 -crf 20 -c:a copy captioned.mp4
    
  5. 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

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