Burn Subtitles with Custom Outline in FFmpeg
Burning subtitles directly into a video stream—known as
hardcoding—ensures that captions are permanently visible on any player
without requiring external files. In FFmpeg, this is achieved using the
subtitles video filter combined with the
force_style parameter to override default styling rules.
This guide provides the complete command syntax, explains how FFmpeg
handles outline colors and widths, and details the specific color
formatting required to style your subtitles effectively.
The Basic Command
To burn subtitles from an .srt file into a video and
define a custom outline color, use the following FFmpeg command:
ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='OutlineColour=&H0000FF&,BorderStyle=1,Outline=2'" -c:a copy output.mp4Understanding the Color Format
FFmpeg subtitle styling uses the Advanced SubStation Alpha (ASS)
format. In this format, colors are defined in hexadecimal using the
&HAABBGGRR& (Alpha, Blue, Green,
Red) or &HBBGGRR& (Blue, Green,
Red) format, rather than standard HTML/web RRGGBB
format.
- Red Outline:
&H0000FF& - Green Outline:
&H00FF00& - Blue Outline:
&HFF0000& - Yellow Outline:
&H00FFFF& - Black Outline:
&H000000& - White Outline:
&HFFFFFF&
If an alpha channel is included, 00 denotes completely
opaque and FF denotes fully transparent (e.g.,
&H000000FF& is fully opaque red).
Key Style Parameters
When using force_style, you can separate multiple style
options with commas inside the quotation marks:
OutlineColour: Sets the color of the border surrounding the text in&HAABBGGRR&format.Outline: Controls the thickness of the border in pixels (e.g.,Outline=2orOutline=3).BorderStyle: Set this to1to enable a standard outline with drop shadow. Setting it to3produces an opaque background bounding box instead of a text outline.PrimaryColour: Sets the main font fill color.FontSize: Adjusts the subtitle font size.FontName: Specifies the typeface (e.g.,FontName=Arial).
Complete Example: White Text with a Blue Outline
The following command burns captions.srt into
input.mp4, rendering the text in 24pt Arial, filled with
white, and outlined with a 3-pixel-wide pure blue border:
ffmpeg -i input.mp4 -vf "subtitles=captions.srt:force_style='FontName=Arial,FontSize=24,PrimaryColour=&H00FFFFFF&,OutlineColour=&HFF0000&,BorderStyle=1,Outline=3'" -c:v libx264 -crf 20 -c:a copy output.mp4Windows Path Formatting Note
If you are using Windows and providing an absolute path to the subtitle file, backslashes must be escaped or converted to forward slashes, and the drive colon must be escaped:
-vf "subtitles='C\\:/path/to/subs.srt':force_style='OutlineColour=&H0000FF&,Outline=2'"