====== 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 text-based subtitle format. * Any text editor can open .ass files. 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. * SRT is more popular than ASS. ASS files have INI-style sections. * Each section is preceded by a line containing the sections name, in square brackets. * Aside from this, each line is generally composed of: a line descriptor, which tells about what the line is about; a colon; and the line data itself. * Any whitespace between these parts are allowed. * Blank lines are also allowed. * Hard comment lines are preceded by either a semicolon or !: (with "!" as the line descriptor). * Unrecognized and incorrect line formats are ignored. ---- ===== 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 [[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes|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