How to Add Subtitles to a Video with FFmpeg (5 Different Styles)

Embed hard subtitles with styles like Youtube, Netflix, and Crunchyroll in your videos using FFmpeg.
by Josephine Loo · · Updated

Contents

    To catch the eye of the audience with an ever-shrinking attention span, adding subtitles to videos has become a norm. Popular video streaming platforms like Youtube, Netflix, and Crunchyroll add subtitles to their videos and you should do the same.

    It doesn't only retain the audience's attention but also breaks the language barrier. International fans can enjoy watching phenomenal TV shows like Money Heist, Squid Game, and other Japanese anime shows with the help of translated subtitles.

    These video streaming platforms use different styles for their subtitles and they are pretty distinctive. Although most of them use soft subtitles, you can use FFmpeg to embed hard subtitles with styles like theirs in your videos.

    In this article, I will show you how to create different styles, like anime/Crunchyroll, Netflix, Youtube, yellow font, and more for your subtitles.

    The Default Subtitle Style

    A default subtitle style is applied to every subtitle added using FFmpeg. If the subtitle is in the SRT format, you can convert it into an ASS subtitle file using the command below:

    ffmpeg -i subtitle.srt subtitle.ass
    

    In the subtitle.ass file, you will be able to read the font name, font size, colour, and other properties of the default style from the list of style definitions.

    a screenshot of the default subtitle style

    The default subtitle style uses Arial as its font and white colour with a black border for its text.

    screenshot of the default subtitle style on a video

    How to Change the Subtitle Style

    You can set the style in the subtitle file itself or use the force_style option of the “subtitles” filter from the command line. The detail is written in the “ Styling the Subtitles” section of How to Add Subtitles to a Video File Using FFmpeg.

    In the next section of this article, I will show you some subtitle styles that you can use. For each of the subtitle styles, there will be:

    • A list of style definitions that you can change in an ASS subtitle file (Option 1)
    • An FFmpeg command which defines the subtitle style while adding a subtitle to a video file (Option 2)

    Examples

    For Option 1, you will see some key-value pairs like these below:

    Format: Fontname, OutlineColour, BorderStyle
    Style: Roboto, &H40000000, 3
    

    These are some of the properties that you can define for a subtitle style. In your ASS subtitle file, change the values on the second line of the key-value pairs and add the subtitle to your video.

    For Option 2, you will see an FFmpeg command with the subtitle styles specified in the force_style option:

    ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='Fontname=Roboto,OutlineColour=&H40000000,BorderStyle=3'" output.mp4
    

    You can run the command in your command line/terminal directly after changing the names of the input file and output file.

    Either of these options mentioned above can be used to change the subtitle style. Next, let’s see how to define the styles.

    Custom Subtitle Styles

    Style 1 - Youtube

    Youtube’s closed caption uses a subtitle style which is very easy to read in any video regardless of its colour. It is similar to the default style of a soft subtitle added using FFmpeg, which uses white colour for its text, surrounded by a semi-opaque black box.

    an example of subtitle in Youtube style

    Font name : Roboto
    Font colour : White
    Background colou r: Black
    Background opacity : 75% (25% transparency)

    Style definition (ASS file):

    Format: Fontname, OutlineColour, BorderStyle
    Style: Roboto, &H40000000, 3
    

    Command:

    ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='Fontname=Roboto,OutlineColour=&H40000000,BorderStyle=3'" output.mp4
    

    The default value for BorderStyle is 1, which adds an outline and a drop shadow to the text. It only accepts two possible values, 1 or 3. When BorderStyle is set to 3, an opaque box that becomes the background of the subtitle text will be added.

    OutlineColour sets the colour of the box using hexadecimal code but in the format of ‘&HBBGGRR’. It is in the reverse order of a usual HTML hex code which follows the ‘RRGGBB’ sequence.

    The hex code used in an ASS file also doesn’t start with ‘#’ but uses the prefix ‘&H’. If you use #2596be in HTML, you need to change it to &Hbe9625.

    You can also add transparency to the colour by adding the corresponding hex value before ‘BBGGRR’.

    For this subtitle style, the background colour is black (&H000000) while its transparency is 25% (40). Hence, the complete hex code is &H40000000.

    an example of subtitle in Youtube style on a video

    Style 2 - Netflix

    Netflix uses a Block font and white colour for its default subtitle text. A black drop shadow is added to the subtitle to separate the text from the background. It isn’t as clear as Youtube’s closed caption that has a black background behind the text but it looks cleaner and less distractive.

    an example of subtitle in Netflix style

    Font name : Consolas
    Font colour : White
    Shadow colour : Black
    Shadow opacity : 75%

    Style definitions (ASS file):

    Format: Fontname, BackColour, Spacing, Outline, Shadow
    Style: Consolas, &H80000000, 0.2, 0, 0.75
    

    Command:

    ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='Fontname=Consolas,BackColour=&H80000000,Spacing=0.2,Outline=0,Shadow=0.75'" output.mp4
    

    BackColour sets the colour of the outline or shadow of the text depending on which one is used while Outline sets the width of them in pixels. When Outline is set to 0, a drop shadow is added to the text and &H80000000 becomes the colour of the shadow.

    The depth of the shadow can also be adjusted and the value ranges from 0 to 4. For this subtitle style, we will use a shadow depth of 0.75 which looks soft but still makes the text pops.

    an example of subtitle in Netflix style on a video

    Style 3 - Aesthetic (Vintage Yellow Subtitle)

    Besides white colour, yellow is also often used for subtitles. Compared to white, a yellow subtitle is more eye-catching and easier to read in various backgrounds.

    A yellow subtitle isn’t for everyone as some people think that it looks distractive compared to a white subtitle which is more neutral. In spite of this, some people prefer the yellow subtitle as it makes them feel nostalgic.

    It also gives an aesthetic and vintage vibe when the font style is set to Italic.

    an example of subtitle in aesthetic (vintage yellow subtitle) style

    Font name : Arial
    Font colour : Yellow
    Style : Italic
    Border colour : Black

    Style definitions (ASS file):

    Format: PrimaryColour, Italic, Spacing
    Style: &H03fcff, 1, 0.8
    

    Command:

    ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='PrimaryColour=&H03fcff,Italic=1,Spacing=0.8'" output_aesthetic.mp4
    

    The colour of the font can be set from the PrimaryColour property and setting Italic to 1 applies the Italic style to the text.

    The default style with no spacing makes the bright yellow text look very packed on a video. Increasing the spacing to 0.8 can make the subtitle look more pleasing to the eye.

    an example of subtitle in aesthetic (vintage yellow subtitle) style on a video

    Style 4 - Anime/Crunchyroll

    This is one of the most common subtitle fonts that is used in many anime shows. It is also the font used by Crunchyroll, a video streaming platform that offers over 1,000 anime shows to more than 5 million paid subscribers worldwide.

    As this font is often used in anime shows' subtitles, an anime lover can easily recognize the font and associate it with anime.

    an example of subtitle in anime/Crunchyroll style

    Font name : Trebuchet MS
    Font colour : White
    Border colour : Black

    Style definitions (ASS file):

    Format: Fontname
    Style: Trebuchet MS
    

    Command:

    ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='Fontname=Trebuchet MS'" output.mp4
    

    The only property that needs to be changed is the font name while other properties can use the default value. Set Fontname to Trebuchet MS and you’re ready to add the subtitle to your video.

    an example of subtitle in anime/Crunchyroll style on a video

    Note : You can use any font which is installed in your operating system in an ASS file. If the font is not applied in the output video, you can download the TTF font file and place it in your current directory.

    Style 5 - Your Own Style

    Other than popular subtitle styles which are familiar to most people like those mentioned above, you can create your own subtitle style which is designed specifically for your audience!

    If you are adding subtitles to movies or videos that are longer than 30 minutes, black and white might still be the best colours to use. For other videos, you can try different colours especially if you are creating a short video for a brand.

    If you have a brand kit, using the brand’s colours in the video subtitle can help you to maintain branding consistency.

    You can use the style definitions below as a guide to change the colours of the font, border, background, and shadow of your subtitle. Other properties like Fontname, Fontsize, Bold, etc. are self-explanatory, you can change them too.

    Default Style with Border

    an example of custom subtitle style 1

    Style definitions (ASS file):

    Format: PrimaryColour, OutlineColour, BorderStyle, Outline
    Style: "font colour", "border colour", 1, "border width 0-4"
    

    Solid Background

    an example of custom subtitle style 2

    Style definitions (ASS file):

    Format: PrimaryColour, OutlineColour, BorderStyle
    Style: "font colour", "background colour", 3
    

    Drop Shadow

    an example of custom subtitle style 3

    Style definitions (ASS file):

    Format: PrimaryColour, OutlineColour, BackColour, BorderStyle, Outline, Shadow
    Style: "font colour", "border colour", "shadow colour", 1, "border width 0-4", "shadow depth 0-4"
    

    Auto-generate Subtitles

    Other than FFmpeg, there are other tools that can help you to add subtitles to video files. Some of them like Bannerbear can even auto-generate subtitles for your videos and add them to the videos with custom styles and other elements.

    If you are interested to try it out, this article can help you get started: How to Create Videos with Auto Subtitles in One API Request.

    Regardless of what type of video you are producing, adding subtitles to your videos definitely has more advantages and you should utilise it to give you an edge over others.

    About the authorJosephine Loo
    Josephine is an automation enthusiast. She loves automating stuff and helping people to increase productivity with automation.

    Bannerbear Beginner Guide: How to Start Generating Images Dynamically in JavaScript with Bannerbear

    If you want to integrate dynamic image generation into your JavaScript project, this article is for you! Learn how to do it effortlessly with Bannerbear—we’ll walk you through the entire process, from setup and implementation to achieving the final result.

    How to Automatically Create Eye-Catching Images for Your App's Link Sharing Using Bannerbear (Node.js)

    Want to make your app’s link sharing stand out? Learn how to use Bannerbear to automatically create eye-catching images that boost click-through rates! This tutorial walks you through building a backend service with Node.js to automatically generate custom images based on dynamic data.

    How to Auto-Generate Social Media Posts For a Business Conference Using Bannerbear (Node.js): Part 2

    In Part 2 of our series on auto-generating social media posts for a business conference using Bannerbear, we'll be creating posts for panel sessions. The image for each post will feature key details like the session topic, moderator, and panelists.

    Automate & Scale
    Your Marketing

    Bannerbear helps you auto-generate social media visuals, banners and more with our API and nocode integrations

    How to Add Subtitles to a Video with FFmpeg (5 Different Styles)
    How to Add Subtitles to a Video with FFmpeg (5 Different Styles)