Skip to content

Burn Subtitles Into a Video With FFmpeg: SRT, Fonts and Styling

FFmpeg commands to hardcode an SRT into an MP4 with the subtitles filter, style it, choose a font, and keep a soft track instead. With Windows path pitfalls.

Try it now: AI Subtitle Generator — timed subtitles from speech in 20 languages, processed in your browser.

If you are comfortable in a terminal, FFmpeg can draw an SRT onto a video with no editor and no watermark. This guide covers the two jobs people usually mean: burning subtitles in, and attaching them as a switchable track.

Before you rely on these commands: run them on a 10-second test clip first. Options and builds differ, and the subtitles filter needs an FFmpeg build with libass.

1. Burn an SRT into the picture

bash
ffmpeg -i input.mp4 -vf "subtitles=subs.srt" -c:a copy output.mp4
  • -vf "subtitles=subs.srt" renders the text onto each frame, so the video must be re-encoded.
  • -c:a copy leaves the audio untouched.

The SRT must be UTF-8. If you made it from speech, see generating the SRT; if you must fix text first, see editing an SRT file.

2. Style the text

You can override the look with force_style, which takes ASS-style fields:

bash
ffmpeg -i input.mp4 \
  -vf "subtitles=subs.srt:force_style='FontName=Noto Sans,FontSize=22,PrimaryColour=&H00FFFFFF,OutlineColour=&H00000000,BorderStyle=1,Outline=2,Alignment=2,MarginV=40'" \
  -c:a copy output.mp4
FieldMeaning
FontName, FontSizeFont and size (size is relative to the video's script resolution)
PrimaryColour, OutlineColourColours in &HAABBGGRR (note the blue-green-red order)
BorderStyle=1 + OutlineOutline width around the text
Alignment=2Bottom centre (numpad layout)
MarginVDistance from the bottom edge

3. Fonts for non-Latin scripts

FFmpeg draws text with the fonts available on your system. If your script shows empty boxes, choose a font that contains it and name it in FontName, or point FFmpeg at a folder of fonts with fontsdir:

bash
-vf "subtitles=subs.srt:fontsdir=./fonts:force_style='FontName=Noto Sans Sinhala'"

See fonts for non-Latin subtitles for why boxes appear.

4. Windows paths and escaping

Filter arguments use : and , as separators, so a path like C:\videos\subs.srt breaks. FFmpeg's documentation describes a second level of escaping for the whole filter description, where characters like [ ] , ; are special. The easiest ways around it:

  • Run the command from the folder that contains the SRT and use a plain file name (subs.srt).
  • Or escape the drive colon and use forward slashes: subtitles='C\:/videos/subs.srt'.

5. Soft subtitles (a switchable track)

To keep the subtitles as a separate track instead of burning them in:

bash
# MP4: the text codec is mov_text
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text output.mp4

# MKV: SRT can be stored as it is
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s srt output.mkv

No re-encoding of the video happens, so it is quick. The viewer's player decides whether to show the track; see soft vs burned-in captions.

6. Common problems

ProblemLikely cause
"No such filter: subtitles"FFmpeg built without libass
Boxes instead of lettersThe font lacks the script; set FontName or fontsdir
Subtitles tiny or hugeFontSize is relative to script resolution; adjust
Command fails on WindowsPath escaping; use a plain file name
Output is much largerRe-encoding; set quality with -crf and keep the source bitrate in mind

When a GUI is better

For styled, animated captions or non-technical teammates, a visual tool is faster. The subtitle generator can export an MP4 with captions burned in, after a free Google sign-in; FFmpeg is the better fit for scripted batches.

Sources

Last updated