FFmpeg Burn Subtitles with Custom Outline Color

This guide explains how to permanently burn subtitles into a video using FFmpeg while customizing their visual style. You will learn how to use the FFmpeg subtitle filter, apply the force_style parameter to modify the subtitle outline color, and understand the specific hexadecimal color format required for successful styling.

The FFmpeg Command

To burn subtitles into a video and style the outline, you use the -vf (video filter) flag with the subtitles filter. The force_style option allows you to override the default subtitle styles.

Here is the template command:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='OutlineColour=&H0000FF&,BorderStyle=1,Outline=2'" output.mp4

Command Breakdown and Styling Options

  • -i input.mp4: Specifies the input video file.
  • subtitles=subs.srt: Specifies the subtitle file to burn into the video.
  • force_style='...': Overrides the default subtitle formatting using ASS (Advanced SubStation Alpha) style properties:
    • OutlineColour: Sets the color of the outline (see color formatting below).
    • BorderStyle: Set to 1 for a standard outline + shadow, or 3 for an opaque box background.
    • Outline: Sets the thickness of the outline in pixels (e.g., 2 or 3).
    • PrimaryColour: Sets the main text fill color.

Understanding the FFmpeg Color Format

FFmpeg subtitle styling uses the ASS color format, which is written in hexadecimal but structured differently than standard HTML hex codes.

The format is &H[Alpha][Blue][Green][Red]& (ABGR):

  • &H starts the color code, and & ends it.
  • The values are in hexadecimal (00 to FF).
  • Alpha: 00 is fully opaque, FF is fully transparent. If omitted, it defaults to opaque.
  • Blue, Green, Red (BGR): The reverse order of standard RGB.

Color Examples:

  • Red Outline: &H0000FF& (Blue: 00, Green: 00, Red: FF)
  • Green Outline: &H00FF00& (Blue: 00, Green: FF, Red: 00)
  • Blue Outline: &HFF0000& (Blue: FF, Green: 00, Red: 00)
  • Yellow Outline: &H00FFFF& (Blue: 00, Green: FF, Red: FF)
  • Black Outline: &H000000& (Blue: 00, Green: 00, Red: 00)

Complete Customization Example

To burn yellow text with a thick red outline and a custom font size, use the following command:

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='Fontname=Arial,Fontsize=20,PrimaryColour=&H00FFFF&,OutlineColour=&H0000FF&,BorderStyle=1,Outline=3'" output.mp4