Table of Contents

ffmpeg - Subtitles - Styling the Subtitles

Set the Style in the Subtitle File Itself.

SRT Files

For SRT files, the options for the subtitle styles are limited.

subtitle.srt
1
00:00:0,000 --> 00:00:2,000
This is the <b><i>first</i></b> sentence
 
2
00:00:2,000 --> 00:00:4,000 
This is the second sentence
 
3
00:00:4,000 --> 00:00:7,000
This is the third sentence
 
4
00:00:7,000 --> 00:00:10,000
This is the forth sentence

ASS Files

For ASS files, there are many more options for the subtitle styles.

These are the styles options that can be set in an ASS file:

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0

Example

To change the font style to Futura and font color to “&HFF00” (green):

subtitle.ass
[Script Info]
; Script generated by FFmpeg/Lavc60.31.102
ScriptType: v4.00+
PlayResX: 384
PlayResY: 288
ScaledBorderAndShadow: yes
YCbCr Matrix: None
 
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Futura,16,&Hff00,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,1
 
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:02.00,Default,,0,0,0,,This is the first sentence
Dialogue: 0,0:00:02.00,0:00:04.00,Default,,0,0,0,,This is the second sentence
Dialogue: 0,0:00:04.00,0:00:07.00,Default,,0,0,0,,This is the third sentence
Dialogue: 0,0:00:07.00,0:00:10.00,Default,,0,0,0,,This is the forth sentence

NOTE: See the Style line.

  • Futura is the Fontname.
  • &Hff00 is the PrimaryColour.

PrimaryColour is in hexadecimal in Blue Green Red (BGR) order.

  • This is the opposite order of HTML color codes.
  • They must always start with &H.