Custom Font Family for FFmpeg Subtitles Filter

This article explains how to specify a custom font family when rendering subtitles onto a video using the FFmpeg subtitles filter. You will learn the exact syntax to override default fonts for SRT files using the force_style parameter and how to point FFmpeg to custom font files stored in specific directories.

Using the force_style Parameter

To change the font family for SubRip (.srt) subtitles, you must use the force_style option within the subtitles filter. This option allows you to pass Advanced SubStation Alpha (ASS) style properties to override the default text rendering settings.

To specify a custom font family, use the FontName property inside the force_style parameter:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='FontName=Arial,FontSize=20'" output.mp4

In this command: * FontName defines the family name of the font (e.g., Arial, Helvetica, Times New Roman). * FontSize sets the size of the rendered text.

Using Custom Fonts from a Specific Directory

If the font you want to use is not installed on your system, FFmpeg will not be able to find it by name alone. You can tell FFmpeg where to look for your custom .ttf or .otf font files by using the fontsdir parameter.

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:fontsdir=/path/to/fonts/dir/:force_style='FontName=MyCustomFont'" output.mp4

Handling ASS Subtitles

If you are using Advanced SubStation Alpha (.ass) subtitles, the font styles are already embedded within the subtitle file itself under the [V4+ Styles] section.

If you want to override the font family defined in an .ass file without editing the file itself, you can still apply the force_style parameter:

ffmpeg -i input.mp4 -vf "subtitles=subs.ass:force_style='FontName=Impact'" output.mp4