There are several recommendations for burning subtitles into video files on different operating systems such as Handbrake and VLC. Unfortunately, these programs fall short when offering customizability such as positioning and size, transformations and edits.

Aegisub and FFMPEG combined together can help achieve this with ease in less than 5 minutes. This article will walk through how to set that up and get started burning subtitles into your video files.

Installation & Setup

FFMPEG Installation

The first thing you’ll need to do is install FFMPEG. In order to do this, you can either visit their documentation on installation https://ffmpeg.org/download.html or you can install via Homebrew like so:

brew install ffmpeg

Aegisub Installation

Aegisub is a free, open-source solution for SRT edits. When editing and saving modified SRT files, we will output what is known as a .ass file, standing for Advanced Subtation Alpha. These files are similar to a standard subtitle file like SRT, but they don’t require libavcodec and livavformat installations to be present.

You get additional benefits with .ass files like

  • Custom shaping engine
    • auto libass shaping engine
    • simple font-agnostic shaper
    • complex shaper utilizing OpenType for substitutions and positioning
  • Orientation modification
  • Encoding modifications
  • Stylistic modifications

Cross platforms installers are available here: http://www.aegisub.org/downloads/

Sample .ass Snippet

[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: None

[Aegisub Project Garbage]
Scroll Position: 9
Active Line: 45
Video Position: 14275

[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,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:19.98,0:00:24.96,Default,,0,0,0,,{\fscx73\fscy65\pos(191.289,282.693)

You’ll notice the metadata embedded in the file encodes some of the stylistic information we want to bind into the .mp4 file.

Adjusting The Video & Subtitles Together

  1. The first step is to modify the subtitles to look and feel great within your video. In order to do this, open Aegisub and load the .srt file by going to File → Open Subtitles.
  2. The next step is to load the video. This can be done by going Video → Open Video

Now, you have the flexibility of modifiying the look and feel of the text/subtitles loaded onto the video file.

Below shows some of the side-bar utilities we can use to modify the orientation, scale and x-y positioning of the loaded subtitles. ctrl/cmd + a will allow you to modify all the subtitle lines in one go.

/assets/img/posts/sub.png

Exporting Subtitle From Aegisub

When you’re satisfied with the modifications, export the SRT modifications as an ass file.

File → Save Subtitles As …

Burning Subtitles Into Video File Via FFMPEG

After FFMPEG is installed, we can simply burn the ASS file into the video.

ffmpeg -i input_video.mp4 -vf "ass=YOUR_SUBTITLE.ass" output_video.mp4