Burn Subtitles into Video with FFmpeg and Change Font Size

This article provides a straightforward guide on how to permanently burn subtitles into a video file using FFmpeg’s subtitles filter. You will learn the exact commands needed to hardcode subtitles from an external file (such as an SRT or ASS file) and how to use the force_style option to customize the font size, font family, and other visual properties.

Burning Subtitles with Default Styles

To burn subtitles into a video stream, you must use the video filter (-vf) flag with the subtitles filter. The basic command takes your input video and subtitle file, overlays the text onto the video frames, and re-encodes the video.

Run the following command in your terminal:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt" output.mp4

In this command: * -i input.mp4 specifies the input video. * -vf "subtitles=subs.srt" applies the subtitles filter using the file subs.srt. * output.mp4 is the resulting video with hardcoded subtitles.

Adjusting the Subtitle Font Size

By default, FFmpeg uses the system’s default font and size configuration. To customize the font size, you need to pass the force_style parameter to the subtitles filter. This parameter accepts Advanced SubStation Alpha (ASS) style overrides.

To increase or decrease the font size, use the FontSize property:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='FontSize=24'" output.mp4

Change 24 to your desired size (defined in points).

Adjusting Font Name and Size Together

You can customize multiple properties at once, such as the font family (FontName) and the font size, by separating the style parameters with commas inside the force_style string:

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

Adding Advanced Styling (Colors and Outlines)

To make your subtitles more readable, you can also modify the text color, outline color, and outline thickness using force_style:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='FontName=Helvetica,FontSize=22,PrimaryColour=&H00FFFF&,OutlineColour=&H000000&,Outline=2'" output.mp4

Requirements for Styling to Work

  1. Font Availability: The font specified in FontName must be installed on your operating system.
  2. Fontconfig: FFmpeg must be compiled with --enable-libass and --enable-fontconfig to find and render system fonts properly. If a specified font is not found, FFmpeg will fall back to a default system font.