Table of Contents

ffmpeg - Subtitles - Add subtitles from an ASS file

An ASS (Advanced SubStation Alpha) file is a subtitle format that supports text styling, animation, and karaoke-like graphics.

ASS is a more advanced subtitle format than SRT since ASS allows for more advanced display features such as text positioning, fonts, animation, and graphics besides the plain text styling.

ASS files have INI-style sections.


Adding Soft Subtitles

ffmpeg -i input.mp4 -i subtitle.ass -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4
 
ffmpeg -i input.mp4 -i subtitle.ass -c copy -c:s srt -metadata:s:s:0 language=eng output.mkv

NOTE: Different syntax is used for MP4 and MKV.

  • -c copy specifies that the video is not to be re-encoded.
  • -c:s mov_text sets the ASS file to MOV_TEXT format for MP4.
  • -c:s srt sets the ASS file to SRT format for MKV.
  • -metadata:s:s:0 means to set the metadata for Stream:Subtitle:Number of stream, starting with 0.
  • language=eng sets the subtitle language to English.
    • The value for this option uses the ISO 639 language code which consists of 3 letters for every language.


Adding Hard Subtitles

ffmpeg -i input.mp4 -vf ass=subtitle.ass output.mp4

NOTE: The subtitles will be added to the video using the default font styles.

  • -vf is an alias for -filter:v.
  • ass=subtitle.ass is the name of the filter followed by the name of the ASS subtitle file.

References

https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes