How to Add Subtitles to a Video with FFmpeg

83% of people watch videos with the sound off.
by Bannerbear Youtube ·

83% of people watch videos with the sound off. No subtitles = lost viewers. In this tutorial, I'll show you exactly how to add subtitles to any video file using FFmpeg — completely free, no GUI needed.

You'll learn how to burn in permanent hard subtitles, embed toggleable soft subtitle streams, style them with custom fonts and colors, and even pack multiple languages into a single file.

What you'll learn:

• Hard vs. soft subtitles — and when to use each

• How to burn hard subtitles into your video using an SRT file

• How to style subtitles with the ASS format (font, size, color, alignment & more)

• How to embed soft subtitles as a toggleable stream viewers can switch on/off

• How to add multiple language tracks (English + Chinese) in a single pass

Tools used:

• FFmpeg (free & open-source) → https://ffmpeg.org/

If you have questions or a tutorial you'd like to see next, drop it in the comments. See you in the next one!

Video Transcription

[00:00:00] Hey, welcome back. Here's a stat that should make every video creator stop and think: 83% of people watch videos with sound off. They could be commuting, sitting in a quiet office, multitasking, or simply don't have their headphones with them when they're outside. If there are no subtitles to follow along with, they're likely to scroll past it.

If you're a developer building a video editing tool or anything that handles video, this is your sign to add subtitle support. In this video, I'm going to show you how to add subtitles to any video file using FFmpeg, a free, powerful command-line tool. By the end of the video, you'll know how to add both hard and soft subtitles to videos.

Let's start with hard subtitles. These subtitles are permanently backed into the video frames.

[00:01:00] Once they're added, they can't be removed. An SRT file has four parts per subtitle entry: an index number, a start and end timestamp, the subtitle text, and a blank line to indicate the end of the subtitle. Make sure the SRT file is in the same folder as your video and run this FFmpeg command.

Here's what the command means. -i input.mp4 specifies the source video. -vf subtitles=subtitle.srt applies the subtitles filter,

and specify the name of the SRT subtitle file. And finally, output_srt.mp4 specifies the name of the output file. This

[00:02:00] adds the hard-coded subtitle to the video using the default font style. If you want more styling control, convert your SRT file to an ASS file first using the command. The ASS format gives you control over font name, size, color, bold, italic, alignment, margins, and more.

Once you've configured the styles in the file, apply it to your video with an ASS filter. The styling will be applied to the subtitles, like how it's defined in the ASS file. Now, let's add soft subtitles. Unlike hard subtitles, these are not burned into the video. They're embedded as a separate stream, so viewers can turn them on or off using their media player.

This is great for accessibility

[00:03:00] and also for supporting multiple languages. Before we start, rename your subtitle file to subtitle.en.srt. Then run this command. Here's the result. You can see the subtitle stream is there in the player, and you can switch it on or off. Let's break down the command that we just ran.

Two files following -i are the video and subtitle files. -c copy tells FFmpeg not to re-encode the video. -cs mov_text converts the SRT stream to MOV_text format, which is what MP4 containers use. And -metadata ss0 language argument tags the subtitle stream

[00:04:00] as English using the ISO 639 language code.

Basically, the command takes the video and embeds the subtitle file as a toggleable English subtitle stream without re-encoding the video, outputting it as output_english.mp4. Now let's add a

Chinese subtitle to the video we just created. Create another file name, subtitle.chi.srt, with Chinese subtitles inside. We'll use -map flag to tell FFmpeg which streams to include. -map 0 includes everything from the previous output video, including the English subtitle stream, and -map 1 adds the Chinese SRT as an additional stream.

[00:05:00]

Metadata SS one language tag marks the second subtitle stream as Chinese. Let's run the command. Now, you can choose which subtitle to show. If you want to go from scratch and add both language subtitle streams in a single pass, here's the one-liner Before we end this video, let's quickly compare the two methods.

Hard subtitles burn the text permanently into the video frames. You can't remove them, and viewers can't toggle them off, but they'll show up on any media player without any compatibility concerns. Use these when you need the subtitles to always be there. On the other hand, soft subtitles are embedded as a separate stream.

Viewers can turn them on or off, and you can pack multiple

[00:06:00] languages into a single file. They're also faster to process since FFmpeg skips re-encoding entirely. Use these when you're producing content for platforms that support subtitle tracks, like a video app, a streaming platform, or a downloadable file where your audience speaks different languages.

And that's a wrap. If you have any questions or any tutorials that you want to see, drop them in the comments below. I'll see you for the next one.

https://youtu.be/a3BfFk2vXBg?si=SImJV5tVdS1GQh_1

About the authorBannerbear Youtube@bannerbear
Quick Youtube video tutorials from the Bannerbear team on automating image and video generation.
Video

Style Your Subtitles Like YouTube, Netflix & Crunchyroll Using FFmpeg

Learn how to recreate the iconic subtitle styles from your favorite streaming platforms — all using FFmpeg.

How to Add AI-Generated Backgrounds to Your Bannerbear v5 Templates (Node.js Tutorial)

Learn how to add AI-generated backgrounds to your Bannerbear v5 templates. This step-by-step tutorial shows you how to enable AI Background Generation in the template editor and generate on-brand product images automatically using the Bannerbear API.

Video

How to Auto-Generate Custom Pinterest Images for Your Website Using Bannerbear

Already generating Open Graph images automatically?

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
How to Add Subtitles to a Video with FFmpeg