Home > Common Problem > What is the file format of ass?

What is the file format of ass?

青灯夜游
Release: 2023-02-22 18:05:54
Original
19421 people have browsed it

ass is the format of the subtitle file. The full name of ASS is "Advanced SubStation Alpha". It is an advanced subtitle format based on SSA 4.00 encoding. It adds more special effects and instructions based on the SSA writing style; the plug-in file for subtitles in this format starts with "*.ass" as a suffix. ASS subtitles are plain text files, which means they can be edited manually with any text editor.

What is the file format of ass?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

ASS is a subtitle format recognized and frequently used by most subtitlers.

SubStation Alpha (Sub Station Alpha), referred to as SSA, is a subtitle file format created by CS Low (also known as Kotus) and has more advanced functions than traditional subtitle formats (such as SRT). Plug-in files for subtitles in this format have the suffix *.ssa.

Advanced SubStation Alpha (ASS) is a subtitle format more advanced than SSA, and its actual version is SSA v4.00. It is built on SSA 4.00 encoding. The main change of ASS is to add more special effects and instructions based on the SSA writing style. Plug-in files for subtitles in this format have the suffix *.ass.

Currently, many players support rendering SSA and ASS subtitles.

ASS is compatible with SSA format.

What is the file format of ass?

1. SSA/ASS basic structure

SSA/ASS subtitles are plain text files, which means they can be used in any Edit manually with a text editor, but be careful: the parser assumes that this script follows the rules defined in the SSA standard, and any errors during parsing may lead to unpredictable results.

The SSA/ASS script is divided into multiple sections in an ini file style. But it is not a standard ini file.
The script contains up to five sections: [Script Info], [v4 Styles], [Events], [Fonts], [Graphics].

  • [Script Info] must be the first line of the entire file.
  • Nowadays SSA files rarely contain the two parts [Fonts] and [Graphics].
    Because these functions are only supported by Sub Station Alpha, and other filters (Vobsub/Vsfilter/Avery Lee Subtitler filter) are not supported.
  • Most lines in each section begin with some descriptive text, called a "line descriptor (line descriptor)", and end with a colon.
  • Line type mainly includes:
    • Comment line starting with semicolon;
    • Format: format line;
    • [Script 15 line types in the Info] section; style lines in the
    • [v4 Styles] section;
    • [Events] section of 6 row types. (Row types are covered separately in each subsequent section).
  • The information fields in each row are separated by commas, so the character name ([Events] part) and style name ([v4 Styles] part) cannot contain commas.
  • Rows are indivisible.
    Each entry in the script contains all the information in one line and cannot be divided into multiple lines.
  • Incorrectly formatted lines will be ignored. The order of events in the
  • [Events] section can be scrambled and still be played correctly. We cannot assume that each line of dialogue is arranged in chronological order in the script file.
  • If an unknown style is used in the script, the *Default style will be used.
  • If the style specifies a font that is not installed, then Arial/宋体 will be used.

The following is a brief summary of the five main sections in the SSA/ASS file:

[Script Info]

This section contains the header and overall body of the script information. [Script Info] must be the first line of a v4 script.

[v4 Styles]

This section contains the definitions of all styles. Every style used by the script should be defined here. ASS uses [v4 Styles].

[Events]

This part contains all script events, including subtitles, comments, pictures, sounds, images and commands. Basically, everything you see on the screen is in this section.

[Fonts]

This section contains information about fonts embedded in the script.

[Graphics]

This part contains information about the images embedded in the script.

2. [Script Info] section

A typical [Script Info] section is like this:

[Script Info]
; This is a Sub Station Alpha v4 script.
; For Sub Station Alpha info and downloads,
; go to http://www.eswat.demon.co.uk/
Title: Neon Genesis Evangelion - Episode 26 (neutral Spanish)
Original Script: RoRo
Script Updated By: version 2.8.01
ScriptType: v4.00
Collisions: Normal
PlayResY: 600
PlayDepth: 0
Timer: 100,0000
Copy after login

This section defines multiple Row type, its corresponding meaning is as follows:

##;semicolon, after Can be followed by any content. Only used as comments in scripts. Not visible when loading script. The semicolon must be the first character on the line. In older versions, Titletitle is a description of the script. If not specified, automatically set to Original ScriptThe author who originally created the script. If not specified, automatically set to Original Translation (Optional) The person who originally translated the conversation. If not specified, this field does not show Original Editing (optional) The editor of the original script, usually the person who polished and proofread the translation. If not specified, this item does not display Original Timing (optional) The original timeline person. If not specified, this item is not displayed Synch Point (optional) Indicates when the script should start playing. If not specified, this item does not show Script Updated By (optional) People from other subtitle groups who updated the original script. If not specified, this item does not display Update Details (Optional) Details of updates to the original script by other subtitle groups. If not specified, this entry does not display the ScriptType version of the SSA script format. For example V4.00. If the version of the SSA program currently in use is older than the version of the script, a warning will be givenCollisionsThis determines how the subtitles are moved in order to prevent them from overlapping. PlayResYThe height of the rendering range when rendering subtitles. If playing with Directdraw, SSA v4 will automatically choose the closest enabled setting to the width of the rendering range when rendering subtitles PlayResX. If playing with Directdraw, SSA v4 will automatically choose the closest enabled setting PlayDepth to the color depth when rendering subtitles. If playing with Directdraw, SSA v4 will automatically choose the closest enabled setting to the Timer script's timer speed, using floating point percentages. For example, WrapStyle defines the default line wrapping method. ScaledBorderAndShadowSpecifies whether the border width and shadow depth scale proportionally with the video resolution. The default is No. When the value is No, the border width and shadow depth are displayed exactly according to the specified number of pixels; when the value is Yes, the border width and shadow depth are the same as the actual video resolution. Proportional scaling.

在实际应用中可能用到的是Title、PlayResX、PlayResY、WrapStyle等。

3、[v4 Styles]部分

这一部分包含了所有样式的定义。每一个被脚本使用的样式都应该在这里定义。区别于SSA,ASS 使用[v4+ Styles]关键字。
典型的字段如下:

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: DefaultVCD, Arial,28,11861244,11861244,11861244,-2147483640,-1,0,1,1,2,2,30,30,30,0,0
Copy after login

这一部分用来定义字幕的外观和位置,以便[Events]部分直接引用。此部分由格式行(Format:)和样式行(Style:)组成。除边框样式外,所有样式都可以在[Events]部分使用代码重设。

格式行和样式行的内容一一对应。格式行定义了如何解释样式中的每个字段,因此格式行必须出现在所有的样式之前,且格式行中列出的字段名必须拼写正确!格式行允许在未来将新字段添加到脚本格式中,并且允许旧版本的软件读取它所识别的字段——即使字段顺序已经更改。包括如下23个字段:

Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding

各字段含义如下:

Script line Remarks
!: comments
untitled
unknown
If set to
Normal, SSA will attempt to position the subtitles using the positions specified by "Margins". At the same time, subtitles are moved vertically to prevent overlapping. In Normal's anti-overlap mode, new subtitles will appear on top of existing subtitles, but it will look for the lowest non-overlapping position to fill the "gaps" created by other subtitles. If set to
Reverse, existing subtitles will be moved to make room for new subtitles. This means that subtitles can always be read from top to bottom, but it also means that existing subtitles may appear in the middle of the screen before new subtitles appear. It takes up a lot of screen area.
100.0000 represents 100% to four decimal places. Timer speed is a time multiplier applied to the SSA clock to provide ramp times to expand or compress the total time of the script. A speed greater than
100% will reduce the total script time, meaning that subtitles will gradually appear earlier and earlier; a speed less than 100% will increase the total script time, meaning that subtitles will gradually appear earlier and earlier. Land appears later and later (like a positive ramp time). Expansion and compression only occur when the script is played, this value does not change the actual time of the script event part.
0: Intelligent line wrapping, the division is relatively even, and the upper line is longer.
1: Wrap from the word at the end of the line. Only \N can force a line break.
2: No line breaks, \n and \N force line breaks.
3: Smart line wrapping like 0, the following line is longer.

格式名 备注
Name 样式名称(用于[Events]部分引用,区分大小写,不能包含逗号)
Fontname 字体名称( Windows所使用的字体名称,区分大小写)
Fontsize 字体大小(字号)
PrimaryColour 主体颜色(一般情况下文字的颜色)
SecondaryColour 次要颜色(在卡拉OK效果中字幕由次要颜色变为主体颜色)
OutlineColor 边框颜色
BackColour 阴影颜色
Bold 粗体(-1=开启,0=关闭)
Italic 斜体(-1=开启,0=关闭)
Underline 下划线( -1=开启,0=关闭)
Strikeout 删除线( -1=开启,0=关闭)
ScaleX 横向缩放(单位%,100即正常宽度)
ScaleY 纵向缩放(单位%,100即正常高度)
Spacing 字间距(单位像素,支持小数)
Angle 旋转角度(绕z轴逆时针旋转\frz,负数=顺时针旋转。单位,支持小数)
BorderStyle 边框样式(1=边框+阴影,3=不透明底框)
Outline 边框宽度(单位像素,可用小数)
Shadow 阴影深度(单位像素,可用小数,右下偏移)
Alignment 对齐方式(同小键盘布局,决定了旋转/定位/缩放的参考点)
MarginL 左边距(字幕距左边缘的距离,单位像素,右对齐和中对齐时无效)
MarginR 右边距(字幕距右边缘的距离,单位像素,左对齐和中对齐时无效)
MarginV 垂直边距(字幕距垂直边缘的距离,单位像素,下对齐时表示到底部的距离;上对齐时表示到顶部的距离;中对齐时无效,文本位于垂直中心)
Encoding 编码( 0=ANSI,1=默认,128=日文,134=简中,136=繁中,一般用默认1即可 )

其中脚本支持的颜色格式是:&Haabbggrr,均为十六进制,取值0-9,A-F。
前2位(alpha)为透明度,00=不透明,FF=DEC255=全透明;
后6是BGR蓝绿红颜色。 排在最前的00可以忽略不写, 如:{\c&HFF&}={\c&H0000FF&}为纯红色、&HFFFFFF=纯白色、&HC8000000=透明度为200的黑色。

4、[Events]部分

该部分的一个典型示例是:

[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: Marked=0,0:00:01.18,0:00:06.85,DefaultVCD, NTP,0000,0000,0000,,{\pos(400,570)}Like an angel with pity on nobody
Copy after login

[Event]部分由格式行(Format:)和多个事件行组成。格式航定义了事件行中各种字段的具体含义,因此格式行必须出现在所有事件前。事件行包括:

  • Dialogue: 这是一个“对话”事件,用于显示一些文本。
  • Comment: 这是一个“评论”事件,它包含与对话、图片、声音、电影或命令事件相同的信息,但在脚本回放期间会被忽略。
  • Picture: 这是一个“图片”事件 ,意味着SSA将显示指定的.bmp、.jpg、.gif、.ico或.wmf图形(不支持.png, 且filter不支持加载图片)。
  • Sound: 这是一个“声音”事件,意味着SSA将播放指定的.wav文件。 (filter不支持)
  • Movie: 这是一个“影片”事件,意味着SSA将播放指定的.avi文件。 (filter不支持)
  • Command: 这是一个“命令”事件,意味着SSA将执行指定的程序作为后台任务。 (filter不支持)

注意后面三个使用频率及兼容性过低,这里不作深入分析。

4.1 格式行Format:

Format 行必须出现在所有事件行之前,因为它决定了SSA如何来解析下面的事件行。其所列出的字段必须正确拼写。字段名如下:
Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text

最后的字段总是 Text,以便其可以包含逗号。
格式行支持在未来的脚本格式中添加新的字段,也支持旧版本的软件读出它所能识别的字段,即便字段的顺序发生了变化。其中各字段含义如下:

Number Field name Remark
1 Marked Marked=0 means that the row is not displayed as marked in SSA.
Marked=1, indicating that the row is displayed as marked in SSA.
Usually set Marked to 0
2 Layer Any integer.
Subtitles with different layer values ​​will be ignored in overlap detection.
Large value layers will be overlaid on small value layers.
3 Start The start time of the event, the format is 0:00:00:00 (hour:minute :second:millisecond), the minimum unit is 0.01s. It is the amount of time that elapses in script playback while the subtitles are displayed on the screen. Note that there is only one hour.
4 End The end time of the event, the format is 0:00:00:00 (hour:minute :seconds:milliseconds). It is the amount of time that elapses in script playback before the subtitles disappear from the screen. Note that there is only one hour.
5 Style Style name. If Default, your own *Default style will replace it.
However, if the Default style that the script author wants to use is already stored in the script but is ignored by SSA, if you want to use it, you can modify the name in the style definition line so that it appears in the script's style list.
In actual applications, if the Default style is defined in [v4 Styles], and if an undefined style name is used later, the Default style will be used. If the Default style is not defined, then the renderer's own style will be used.
6 Name Character name. Say the character's name for this line of dialogue. Just for easy identification when editing and setting up the timeline.
7 MarginL 4-digit left margin override value (in pixels). 0000 means using the value defined in the Style line.
8 MarginR 4-bit right margin override value (in pixels). 0000 means using the value defined in the Style line.
9 MarginV 4-bit vertical margin override value (in pixels). 0000 means using the value defined in the Style line.
10 Effect Transition effect. Can be a null value, or one of the three transition effects implemented in SSA v4.x.
Effect names are case-sensitive and must be spelled correctly without quotation marks.
Karaoke, indicates the karaoke effect, highlighting each word in turn. Deprecated as an effect type.

Scroll up;y1;y2;delay[;fadeawayheight], means that the text or image will scroll up on the screen.
The parameter fields after Scroll up are separated by semicolons.
The y1 and y2 values ​​(in pixels) define the vertical area on the screen where the text will scroll. The two value positions are interchangeable. If both values ​​are 0, the text will scroll up the full height of the screen.
The delay value can range from 1 to 100 to reduce the scrolling speed. 0 means scrolling at the original speed without delay. When the delay value is greater than 1, it takes (1000/delay) seconds to move 1 pixel.
The fadeawayheigh value is optional and can cause the text to fade out when it scrolls to the edge of its range.

Scroll down;y1;y2;delay[;fadeawayheight], same as above, for scrolling down.

Banner;delay[;lefttoright;fadeawaywidth], indicating that all text is ignored and lengthened to one line, and scrolls across the screen from right to left.
The delay value is the same as above.
The lefttoright value is optional and takes the value 0 or 1. The default is 0, which means scrolling from right to left.
fadeawaywidth value is the same as above.
11 Text Subtitle text. It is the text that actually appears on the screen as subtitles. Any text after the 9th comma is considered subtitle text, so it can contain commas. The text can contain the \n code that represents a line break, or it can contain the style override control code that appears between curly braces {}.

4.2 Event line

The Dialog event gives the corresponding number according to the field sequence given in the above format line.

Comment, Picture, Sound, Movie, and Command event lines only replace the Text field with the corresponding parameter information. For example, the comment information of Comment, the full command path of Command, the picture path of Picture, etc.

5. Style control override code and special effects examples

The above four parts are the basic SSA/ASS format. In order to achieve various special effects, it is actually necessary to embed various style control override codes in the Text of the Dialog. The following is a brief summary:

  • Except \h, \n and \N, all override codes are written in capital letters within brackets {}.
  • All override codes begin with a backslash \.
  • Multiple override codes can be placed within one curly bracket {}.
  • All override codes apply to all text after them. If you want an override code to only apply to selected text, you need to add a "cancel" override code after the selected text to cancel the previous override code.
  • Some override codes will automatically apply to the entire line of text. Currently there are only Alignment codes, and more may be added later (for example, overrides for shadow and border depth).
  • \pos and \move will also act on the entire line of text, as will be mentioned in the specific instructions below.

In the following writing, means parameters, [] means optional, <..></..>Select one. There is no similar symbol in the actual code.

##\u\s\bordBorder width, unit is pixel, OK It's a decimal. When there is x or y, the border width along the X-axis or Y-axis can be set independently. \shadShadow depth, unit is pixel, can It's a decimal. When there is x or y, the shadow depth along the X or Y axis can be set independently. \fnSpecify a font that is installed in the system. case sensitive. If the specified font is not installed, \fs is a number that specifies the font point size. \fs Multiply the font size of the current text by a certain multiple. For example, \fscxScale text size. \fspIt changes the distance between characters, default is 0. Writing example: \fr represents a certain degree of rotation along the X/Y/Z axis. \faxIncline the text lines along the X-axis and Y-axis respectively. For example, \feSpecifies the character set (font encoding) of the text. Usually 0 is English, 1 is system default, 134 is Simplified Chinese, and 136 is Traditional Chinese. \[]c[&][H]## ##\a is a number that determines where on the screen the subtitles are displayed. \an Same as the keypad layout. If multiple \a or \an appear, the first one that appears takes precedence. \q is a number, the same as \r[
Overwrite code Explanation and remarks
\n Line break. If smart line wrapping is enabled, \n will be ignored.
Writing example: This is the first line\nThis is the second line.
\n will only wrap when WrapStyle:2 or \q2. In other modes, it is equivalent to a space.
\N Force newline. When smart line wrapping is enabled, it is used instead of \n to implement line wrapping.
Line breaks will be forced in any mode. In xy-VSFilter, \N will also wrap in the transition effect Banner; in libass, \N will be in the Banner No line breaks, equivalent to spaces.
\h Hard spaces. Without line breaks, this ensures that the subtitles will not break on this space when displaying them (to ensure that the left and right words are on the same line).
\b \b1Make text bold, \b0Cancel bold.
When this parameter is greater than 1, it will be used as the weight value of the font (400 = normal, 700 = bold, note: the thickness of most fonts can be quantized into 2-3 levels).
\i \i1Italicize the text, \i0Cancel italics.
\u1Underline the text, \u0Cancel the underlining of the text.
\s1Add strikethrough to text, \s0Cancel text deletion Wire.
\xbord
\ybord
Writing examples:
\bord1, \xbord2, \ybord3.
\xshad
\yshad
Writing examples: \shad1, \xshad2, \yshad3.
Arial font will be used. Writing example:
\fnMicrosoft Yahei.
Note that the font size here is not the font size.
\fs20 It does not mean that the font size (font-size) is 20px, but that the line-height (line-height) is 20px. Mainly It's because VSFilter uses the Windows GDI font interface.
\fs-
\fs 2 means multiplying the font size of the current text by 1.2, and \fs-3 means multiplying the font size of the current text by 0.7. The calculation method is (10 ± <value>) * current font size. When the calculated result is less than or equal to 0, the result will not take effect, that is, it will still be the original font size. </value>
\fscy
\fscx is horizontal scaling, \fscy is vertical scaling. Writing examples:
\fscx233.33, \fscy50. Can be used for vector graphics.
\fsp3.
\frx
\fry
\frz
\fr means rotation along the Z axis. Writing examples:
\fr30, \frx-30, \fry-233.33, \frz480. The origin of its rotation is determined by
\org. If \org is not specified, then the rotation will be based on the "default anchor point".
\fay
\fax-0.5 is equivalent to italics. In general, the absolute value of the factor should not exceed 2.
When general subtitle files are saved in Unicode encoding such as UTF-8, this setting can be ignored.
[&] is a hexadecimal RGB value, but the color order is reversed, and the leading 0 can be omitted. <color serial number> The optional values ​​are 1, 2, 3 and 4, which correspond to setting PrimaryColour, SecondaryColour, OutlineColor and BackColour separately. When <color serial number> is not written, it is equivalent to setting it to PrimaryColour. <br> Writing examples: <code>\c&HFF0000&, \1c&HFF&, \2c&HFF00&, \3c&HFFFFFF, \4cFFFFFF . The & and H should be present according to the specification, but if not, it can be parsed normally.
\[]c When c is not followed by other characters, it will be set to the corresponding value defined in the currently used Style .
a[&][H][&] is a hexadecimal Transparency value, 00 is opaque, FF is fully transparent.
The meaning is the same as above, but it cannot be omitted here.
Writing examples: \1a&H80&, \2a&H80, \3a80, \4a&H80&.
The & and H should be present according to the specification, but if not, it can be parsed normally.
\alpha[&][H][&] is a hexadecimal transparency value , 00 is opaque, FF is fully transparent. It defaults to \1a&H<aa>&</aa>.
Writing example: \alpha80.
1, 2, and 3 are left, center, and right at the bottom respectively;
5, 6, and 7 are left, center, and right at the top respectively;
9, 10, and 11 are in the middle respectively Left, center, right.
If it is 0 or none, set it to the default location. If multiple \a or \an appear, the first one that appears takes precedence.
WrapStyle. 0: Intelligent line wrapping, the division is relatively even, and the upper line is longer.
1: Wrap from the word at the end of the line. Only \N can force a line break.
2: No line breaks, \n and \N force line breaks.
3: Same as 0, smart line wrapping, the following line is longer.