How to burn subtitles into videos using FFmpeg?

Hey John!

You can subtitle a file with .srt format from where FFmpeg can pick up subtitles. In addition, FFmpeg provides a subtitles filter that takes the following video stream as input and gives a video stream with subtitles burned in as output.

The Subtitles filter takes the following:

Filename: The filename of the subtitle file is used to read it. It needs to be stated.
You can also pass styling options like font type, size, and colors with the force_style parameter as key-value pairs like this:

force_style='Fontname=DejaVu Serif,PrimaryColour=&HCCFF0000'

If you want to use custom fonts with your subtitle, you can provide a font dir parameter with value as a directory path containing fonts that the filter can use.

Following is the example FFmpeg command for subtitle burn-in:

ffmpeg -i video.mp4 -vf subtitles=filename=/path/to/sub.srt:force_style='Fontname=DejaVu Serif,PrimaryColour=&HCCFF0000' -c copy -f mp4 output.mp4

Do not forget to check out this:

Hope this may help you :grin: