Burn ASS/SSA Subtitles into Video with FFmpeg
This article provides a straightforward guide on how to permanently
burn styled ASS (Advanced SubStation Alpha) and SSA subtitles into a
video stream using the FFmpeg command-line tool. You will learn the
exact syntax required for the subtitles video filter, how
to handle complex file paths, and how to preserve styling and fonts
during the encoding process.
The Basic Command
To burn subtitles into a video, you must use FFmpeg’s video filter
graph (-vf) with the subtitles filter. Because
burning subtitles modifies the actual pixels of the video, the video
stream must be re-encoded.
The basic syntax is as follows:
ffmpeg -i input.mp4 -vf "subtitles=subtitle_file.ass" output.mp4In this command: * -i input.mp4 specifies your source
video. * -vf "subtitles=subtitle_file.ass" applies the
subtitle filter using your ASS/SSA file. * output.mp4 is
the resulting video file with the subtitles permanently burned in.
Optimizing Quality and Performance
Since re-encoding is mandatory, you should specify video quality settings to prevent quality loss. You can copy the audio stream without re-encoding it to save time and preserve audio quality.
Here is an optimized command using the H.264 video encoder:
ffmpeg -i input.mp4 -vf "subtitles=subtitle_file.ass" -c:v libx264 -crf 23 -preset medium -c:a copy output.mp4-c:v libx264uses the H.264 video codec.-crf 23sets the Constant Rate Factor (lower values mean higher quality; 18–28 is the sane range).-preset mediumbalances compression efficiency and encoding speed.-c:a copycopies the audio stream directly without re-encoding it.
Handling File Paths and Escaping
The subtitles filter in FFmpeg can be sensitive to file
paths, especially if they contain spaces, backslashes, or colons.
Relative Paths
The easiest way to avoid path issues is to place your video and subtitle file in the same directory and use relative paths:
ffmpeg -i input.mp4 -vf "subtitles=subs.ass" output.mp4Absolute Paths (Windows)
On Windows, absolute paths contain colons (e.g., C:\)
which conflict with FFmpeg’s filter argument separator. You must escape
the drive colon and use forward slashes or escaped backslashes:
ffmpeg -i input.mp4 -vf "subtitles='C\\:/path/to/subs.ass'" output.mp4Absolute Paths (macOS/Linux)
For Unix-based systems, wrap the path in single quotes inside the double-quoted filter string if the path contains spaces:
ffmpeg -i input.mp4 -vf "subtitles='/path/to/my subtitles.ass'" output.mp4Managing Fonts for ASS/SSA Styles
ASS and SSA subtitles rely heavily on specific fonts for their unique
styles, positioning, and effects. FFmpeg uses the
fontconfig library to locate and render these fonts.
- System Fonts: If the ASS file references a font installed on your system (e.g., Arial, Calibri, or custom fonts installed in Windows Fonts or macOS Book Font), FFmpeg will automatically detect and render it.
- Missing Fonts: If FFmpeg cannot find the font specified in the ASS file, it will fall back to a default system font, which may break the subtitle positioning and design.
- Custom Fonts Directory: If you want to use fonts
that are not installed on the system, you can point FFmpeg to a specific
fonts folder by setting the
FONTCONFIG_FILEenvironment variable or placing the fonts in a directory namedfontsin your working directory.