Embed ASS Subtitles in MP4 with FFmpeg
This article provides a quick and practical guide on how to embed Advanced SubStation Alpha (ASS) subtitles into an MP4 video container using FFmpeg. You will learn how to either “hardburn” the subtitles directly into the video track to preserve their unique styling and fonts, or “soft-mux” them as a toggleable subtitle track.
Method 1: Hardburning ASS Subtitles (Recommended for MP4)
Because the MP4 container has limited native support for the advanced styling, fonts, and animations of the ASS format, “hardburning” (or hardsubbing) is the most reliable method. This process draws the subtitles directly onto the video frames. It requires re-encoding the video, meaning the subtitles cannot be turned off, but they will display perfectly on any media player.
To hardburn ASS subtitles, use the following FFmpeg command:
ffmpeg -i input.mp4 -vf "ass=subtitles.ass" -c:a copy output.mp4Command Breakdown:
-i input.mp4: Specifies the input video file.-vf "ass=subtitles.ass": Applies the video filter (-vf) calledassto overlay the specified subtitle file onto the video.-c:a copy: Copies the audio stream without re-encoding it, which saves time and preserves audio quality.output.mp4: The path and name of the newly created video file.
Note: If your subtitle file name contains spaces or special
characters, wrap the path in escaped quotes, like so:
-vf "ass='my subtitles.ass'".
Method 2: Soft-Muxing Subtitles (Lossy Format Conversion)
If you do not want to re-encode your video and prefer “soft”
subtitles that can be turned on and off, you must convert the ASS
subtitles to mov_text (the standard subtitle format for
MP4).
Because mov_text does not support complex ASS styles,
positioning, or effects, the subtitles will revert to a basic text
style.
To soft-mux the subtitles with format conversion, run:
ffmpeg -i input.mp4 -i subtitles.ass -c:v copy -c:a copy -c:s mov_text output.mp4Command Breakdown:
-i subtitles.ass: Adds the subtitle file as a second input stream.-c:v copy: Copies the video stream without re-encoding.-c:a copy: Copies the audio stream without re-encoding.-c:s mov_text: Converts and encodes the ASS subtitle stream into the MP4-compatiblemov_textformat.
Alternative: Keep Soft ASS Styles Using MKV
If you want to keep the subtitles soft (toggleable) and preserve the complex ASS formatting, you should use the Matroska (MKV) container instead of MP4. The MKV container fully supports native ASS subtitle streams.
To merge ASS subtitles into an MKV container without re-encoding the video or audio:
ffmpeg -i input.mp4 -i subtitles.ass -c copy output.mkvUsing -c copy copies all video, audio, and subtitle
streams directly into the new container in seconds without losing any
quality.