Override SRT Styles Using FFmpeg force_style

This guide explains how to use the force_style option within FFmpeg's subtitles filter to override the default appearance of SubRip (.srt) subtitle files. By leveraging Advanced SubStation Alpha (ASS) style attributes inside the filter, you can easily customize fonts, sizes, colors, outlines, and positioning when hardcoding subtitles into video files.


Basic Command Syntax

The subtitles filter burns subtitles directly into the video stream. To alter the rendering style of an SRT file, append the force_style option to the filter argument:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='Fontname=Arial,Fontsize=24'" -c:a copy output.mp4

Multiple style properties are separated by commas inside the force_style string.


Common force_style Properties

The force_style option accepts standard ASS style definitions:

  • Fontname: Sets the font family (e.g., Fontname=Roboto, Fontname=Arial).
  • Fontsize: Sets the font height in points (e.g., Fontsize=20).
  • PrimaryColour: Sets the main text fill color.
  • OutlineColour: Sets the color of the border around text.
  • BackColour: Sets the shadow or bounding box color.
  • Bold: Enables bold text (Bold=1 for on, Bold=0 for off).
  • Italic: Enables italic text (Italic=1 for on, Italic=0 for off).
  • Outline: Thickness of the text outline in pixels (e.g., Outline=2).
  • Shadow: Depth of the drop shadow in pixels (e.g., Shadow=1).
  • Alignment: Determines screen placement using the numeric keypad layout (e.g., Alignment=2 is bottom-center; Alignment=6 is middle-right).
  • MarginV: Vertical distance from the screen edge in pixels (e.g., MarginV=30).
  • BorderStyle: Determines border type (1 for standard outline, 3 for an opaque bounding box).

Color Format Specification

Colors in ASS styles are formatted in hexadecimal as &HAABBGGRR& (or &HBBGGRR&), where:

  • AA: Alpha/transparency channel (00 is fully opaque, FF is fully transparent).
  • BB: Blue component (00 to FF).
  • GG: Green component (00 to FF).
  • RR: Red component (00 to FF).

Note: The order is BGR, not standard RGB.

  • White (Opaque): &H00FFFFFF&
  • Yellow (Opaque): &H0000FFFF&
  • Black (Opaque): &H00000000&
  • Semi-transparent Black: &H80000000&

Practical Examples

1. Yellow Text with a Black Outline

A common broadcast-style look that enhances readability across varied backgrounds:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='Fontname=Helvetica,Fontsize=18,PrimaryColour=&H0000FFFF&,OutlineColour=&H00000000&,Outline=1.5,Shadow=0'" -c:a copy output.mp4

2. Subtitles on an Opaque Box

To place subtitles inside a solid background banner instead of an outline, set BorderStyle=3:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='Fontname=Arial,Fontsize=16,PrimaryColour=&H00FFFFFF&,BackColour=&H80000000&,BorderStyle=3,Outline=2'" -c:a copy output.mp4

3. Top-Centered Positioning

To move subtitles to the top of the video with adjusted vertical spacing:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='Fontsize=22,Alignment=8,MarginV=40'" -c:a copy output.mp4

Escaping Special Characters

When using paths containing colons (such as Windows drive letters like C:\path\to\subs.srt) or commas, you must escape them with backslashes so FFmpeg does not misinterpret them as filter separators:

ffmpeg -i input.mp4 -vf "subtitles='C\:/subtitles/subs.srt':force_style='Fontsize=20'" -c:a copy output.mp4