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

```bash
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:

   ```bash
   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:

```bash
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

- `subtitles` and `ass` need FFmpeg built with libass. Run `ffmpeg -filters | grep subtitles`. If it prints nothing, install a full build (`brew install ffmpeg-full` on macOS, a static build, or `npx 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=./fonts` to 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](https://varg.ai/how-to/edit-a-video.md)
- [How to crop a video to 9:16 vertical with FFmpeg](https://varg.ai/how-to/crop-a-video-to-vertical-with-ffmpeg.md)
- [How to trim and join video clips with FFmpeg](https://varg.ai/how-to/trim-and-join-video-clips-with-ffmpeg.md)
- [How to add music to a video with FFmpeg](https://varg.ai/how-to/add-music-to-a-video-with-ffmpeg.md)
- [Best AI video editing tools for agents in 2026: 35 compared](https://varg.ai/how-to/best-ai-video-editing-tools.md)
- [Best AI video clipping tools in 2026: 3 compared](https://varg.ai/how-to/best-ai-video-clipping-tools.md)
- [Best AI video caption tools in 2026: 4 compared](https://varg.ai/how-to/best-ai-video-caption-tools.md)
- [Best AI transcript video editors in 2026: 4 compared](https://varg.ai/how-to/best-ai-transcript-video-editors.md)
- [Best AI video editing models in 2026: 4 compared](https://varg.ai/how-to/best-ai-video-editing-models.md)
- [Best AI video dubbing tools in 2026: 3 compared](https://varg.ai/how-to/best-ai-video-dubbing-tools.md)
- [Best AI video upscaling tools in 2026: 3 compared](https://varg.ai/how-to/best-ai-video-upscaling-tools.md)
- [Best video editing APIs for AI agents in 2026: 4 compared](https://varg.ai/how-to/best-video-editing-apis-for-ai-agents.md)
