Burning Subtitles into Video via FFmpeg on Linux

Burning subtitles directly into a video stream—often called creating “hardsubs”—is a reliable way to ensure captions display correctly across all media players and devices without needing separate subtitle files. This guide provides a straightforward walkthrough on how to use FFmpeg on Linux to permanently embed both SRT and ASS subtitle formats into your video files. You will learn the exact command-line syntax required, how to handle common encoding challenges, and how to customize the appearance of your text.


Understanding Hardsubs vs. Softsubs

Before running the commands, it helps to understand what FFmpeg is doing behind the scenes. Unlike “softsubs,” which exist as a separate track that viewers can toggle on and off, “hardsubs” are permanently drawn onto the video frames.

Because FFmpeg must re-render every single frame to merge the text with the imagery, this process requires re-encoding the video track. The audio track, however, can usually be copied directly without alteration to save time and processing power.


Prerequisites: Installing FFmpeg with Libass

To burn subtitles, your FFmpeg installation must be compiled with the --enable-libass configuration flag. Most modern Linux distributions (like Ubuntu, Debian, Fedora, and Arch Linux) include this by default in their package managers.

You can verify your installation by running:

ffmpeg -version | grep enable-libass

If you see --enable-libass in the output configuration, you are ready to proceed.


Scenario 1: Burning External SRT Subtitles

The SubRip (SRT) format is the most common subtitle format. To burn an external .srt file into a video, you will use the subtitles video filter.

ffmpeg -i input.mp4 -vf "subtitles=subs.srt" -c:a copy output.mp4

Breaking down the command:


Scenario 2: Burning External ASS/SSA Subtitles

Advanced SubStation Alpha (ASS) subtitles allow for complex styling, positioning, and animations. If you want to retain these custom styles, use the ass video filter instead of the standard subtitles filter.

ffmpeg -i input.mp4 -vf "ass=subs.ass" -c:a copy output.mp4

The syntax functions identically to the SRT command, but FFmpeg will leverage the Libass library to render the exact fonts, colors, and positions defined within the .ass file.


Scenario 3: Burning Embedded Subtitles

Sometimes, your video file already contains a subtitle track (like an MKV file with softsubs), and you simply want to convert those softsubs into hardsubs.

To pull a subtitle track from within the same file and burn it into the video stream, use this syntax:

ffmpeg -i input.mkv -vf "subtitles=input.mkv" -c:a copy output.mp4

If the input file contains multiple subtitle tracks, FFmpeg will default to the first one. You can specify a specific track index by adding the si parameter:

ffmpeg -i input.mkv -vf "subtitles=input.mkv:si=1" -c:a copy output.mp4

Note: Track indexing starts at 0, so si=1 targets the second subtitle stream.


Customizing SRT Subtitle Appearance

Because standard SRT files do not contain font or styling information, FFmpeg renders them using basic white text. You can customize the look of SRT subtitles on the fly by passing styling parameters directly to the underlying Libass renderer using the force_style option.

ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='FontSize=24,PrimaryColour=&H00FFFF,BackColour=&H80000000,BorderStyle=4'" -c:a copy output.mp4

Common Styling Parameters:


Troubleshooting Path and Escaping Issues

On Linux, if your file paths contain spaces, special characters, or backslashes, FFmpeg’s filter graph can misinterpret them. When dealing with complex paths or file names, you must escape the paths properly.

If your subtitle file is named my subtitles.srt, format the filter argument like this:

ffmpeg -i input.mp4 -vf "subtitles='my subtitles.srt'" -c:a copy output.mp4

For absolute system paths, ensure every colon after the drive or root is escaped if necessary, though wrapping the path in single quotes inside the double-quoted filter string generally resolves most Linux file path conflicts.