diff --git a/index.bs b/index.bs index 6491e90..fe9dfaa 100644 --- a/index.bs +++ b/index.bs @@ -362,6 +362,68 @@ CSS comment (e.g. /**/).

+

Attributes Block

+ +

This section is non-normative.

+ +

WebVTT supports an Attributes block to provide additional information about the rendered text track, and to allow disambiguation of metadata tracks.

+ + + +
+ +

In this example, an optional WebVTT attributes object is used to differentiate captions from standard subtitles.

+
+WEBVTT
+
+ATTRIBUTES
+kind: captions
+lang: es-mx
+label: Español (SDH)
+
+NOTE
+Captions (SDH aka Subtitles for the Deaf and Hard-of-Hearing) 
+typically include spoken dialog as well as important audible 
+sounds such as "floor boards creak", "dogs barking", or in 
+this case, "music".
+
+1
+00:00:10.123 --> 00:00:15.432
+¡Hola! ¿Qué tál?
+
+2
+00:00:47.462 --> 00:01:04.028
+[♫ música ♫]
+ 
+ +
+ + +
+ +

In this example, a WebVTT attributes object is used to indicate the text track cues represent audible or braille descriptions for the blind. Unlike subtitles or captions, these are not intended to be rendered visually.

+
+WEBVTT
+
+ATTRIBUTES
+kind: descriptions
+lang: en-us
+label: English (AD)
+
+NOTE
+VTT-based descriptions are meant to render as text-to-speech audio or braille,
+for blind or deafblind audiences, not usually as visual captions on screen. 
+As such, the option/label might be displayed in an audio menu or elsewhere. 
+
+1
+00:00:10.123 --> 00:00:15.432
+A young girl tiptoes down a dark hallway.
+ 
+ +
+ + +

Other caption and subtitling features

This section is non-normative.

@@ -671,11 +733,14 @@ signifies the end of the WebVTT cue.

-

In this example, a talk is split into each slide being a chapter.

+

In this example, topics mentioned in a talk are provided as URLs for reference.

  WEBVTT
 
+ ATTRIBUTES
+ kind: metadata
+ 
  NOTE
  Thanks to http://output.jsbin.com/mugibo
 
@@ -704,6 +769,30 @@ signifies the end of the WebVTT cue.

+
+ +

In this example, a sequence of video thumbnails and their text alternative are made available for the playback UI.

+
+WEBVTT
+
+ATTRIBUTES
+kind: metadata
+
+00:00:01.959 --> 00:00:02.938
+{
+ "src": "https://cdn.example.com/thumbnails.jpg#xywh=0,0,284,160",
+ "alt": {
+  "en-us": "Miguel crosses the marigold bridge to the land of the dead.",
+  "es-mx": "Miguel cruza el puente marigold hacia la tierra de los muertos."
+ }
+}
+ 
+
+ +

The Timed Text Working Group is discussing a registry for metadata type +values, such as type: video-thumbnails or type: video-flash-avoidance. +See WebVTT issues #511 and #512 for more info.

+

Conformance

@@ -1436,6 +1525,70 @@ together, which is particularly important when scrolling up.

+

WebVTT attributes object

+ +

A WebVTT attributes object represents the optional file-level metadata declared in a +WebVTT attributes block. It consists of:

+ +
+ +
A kind
+
+

A string giving the text track kind. If present, must be one of "subtitles", + "captions", "descriptions", "chapters", or + "metadata". Defaults to the empty string.

+

The kind key is the only required key. Consumers that do not + recognise the kind value should treat the entire WebVTT attributes object + as opaque.

+
+ +
A type
+
+

A string further differentiating the subtype within a kind (for example, + distinguishing varieties of metadata tracks). If present, must be either + "custom" or a string beginning with "custom-". All other values + are reserved for future standardization. Defaults to the empty string.

+

The type key disambiguates the track kind subtype to resolve + naming conflicts for the other common key names often used by different types of metadata.

+

Authors including + custom pairs should provide a non-empty + type value to identify the application or schema those pairs belong to. + A WebVTT attributes block with non-empty + custom pairs and an empty + type is valid but parsers may generate a warning.

+
+ +
A language
+
+

A string giving the BCP 47 language tag of the track content. Defaults to the empty + string.

+
+ +
A label
+
+

A human-readable string intended for use in a track selection menu. Defaults to the empty + string.

+
+ +
Custom pairs
+
+

An ordered list of key/value string pairs for any unrecognized attribute keys. Defaults to + the empty list.

+

Custom pairs should be accompanied by a non-empty + type value so that consumers can identify the + schema to which the pairs belong. If custom pairs are present and type is the + empty string, parsing continues normally, but parsers may generate a warning.

+
+ +
+ +

The WebVTT attributes object's properties are intended to be used by +the embedding context (e.g. HTML) to populate the corresponding internal text track concepts. +How format-provided values interact with values specified in the embedding context (e.g. +<track> element attributes) is defined by the embedding specification. See +whatwg/html issue #11665 for the +ongoing HTML integration work.

+

WebVTT chapter cues

A WebVTT chapter cue is a WebVTT cue whose cue text is interpreted as a @@ -1474,6 +1627,9 @@ with the MIME type text/vtt. [[!RFC3629]]

  • Two or more WebVTT line terminators to terminate the line with the file magic and separate it from the rest of the body.
  • +
  • Zero or one WebVTT attributes block followed by one or + more WebVTT line terminators.
  • +
  • Zero or more WebVTT region definition blocks, WebVTT style blocks and WebVTT comment blocks separated from each other by one or more WebVTT line @@ -1650,6 +1806,65 @@ SIGN).

    When interpreted as a number, a WebVTT percentage must be in the range 0..100.

    +

    A WebVTT attributes block consists of the following components, in the given order:

    +
      +
    1. The string "ATTRIBUTES" (U+0041, U+0054, U+0054, U+0052, U+0049, U+0042, U+0055, + U+0054, U+0045, U+0053).
    2. +
    3. Zero or more U+0020 SPACE or U+0009 CHARACTER TABULATION (tab) characters.
    4. +
    5. A WebVTT line terminator.
    6. +
    7. Zero or more WebVTT attribute key/value pairs, + each followed by a WebVTT line terminator.
    8. +
    + +

    The WebVTT attributes block is terminated by a blank line (two consecutive +WebVTT line terminators), exactly as for +WebVTT region definition blocks.

    + +

    The kind key is the only required key in a +WebVTT attributes block. It must appear in the block to disambiguate the track kind. +Without it, consumers cannot determine whether other common key names such as +language and label apply to a recognized track kind, and may treat +them as opaque. See WebVTT rules for parsing +attribute key/value pairs.

    + +

    A WebVTT attribute key/value pair consists of the following components, +in the given order:

    +
      +
    1. A WebVTT attribute key consisting of one or more + ASCII alphanumeric characters or + U+005F LOW LINE (_) characters, where the first character is either an + ASCII alpha character or U+005F LOW + LINE (_). In other words, matching the production + [A-Za-z_][0-9A-Za-z_]*.
    2. +
    3. A single U+003A COLON character (":").
    4. +
    5. Zero or one U+0020 SPACE or U+0009 CHARACTER TABULATION (tab) characters.
    6. +
    7. A WebVTT attribute value, which is any sequence of zero or more Unicode + characters, subject to the following constraints: +
        +
      • The characters U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) must not appear + literally; they may be represented using the + numeric + character references &#x000A; and &#x000D; + respectively.
      • +
      • The bidirectional formatting characters U+202B, U+202C, U+202D, U+202E, U+2066, + U+2067, U+2068, U+2069, U+200E, U+200F, and U+061C must not appear literally; they may + be represented using + numeric + character references (e.g. &#x200E;).
      • +
      • The resulting string, after escape processing, must not contain the substring + "-->" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).
      • +
      +
    8. +
    + +

    Keys are restricted to ASCII to ensure consistent case-folding and to avoid +ambiguity in key matching. Values may contain any Unicode characters (subject to the constraints +above) to support multilingual labels, language tags, and other internationalized content.

    + +

    The numeric character reference escape convention above is the same as that used +in WebVTT for bidi mark characters in cue payloads (e.g."&#x2068;").

    + +

    A WebVTT comment block consists of the following components, in the given order:

      @@ -1687,7 +1902,7 @@ separated from the next by a WebVTT line terminator. (In other words, any have two consecutive WebVTT line terminators and does not start or end with a WebVTT line terminator.)

      -

      WebVTT metadata text cues are only useful for scripted applications (e.g. using the +

      WebVTT metadata text cues were originally intended for scripted applications (e.g. using the metadata text track kind in a HTML text track).

      @@ -2450,11 +2665,13 @@ chapters, or metadata. Most of the steps will be skipped for chapters or metadat

      WebVTT file parsing

      A WebVTT parser, given an input byte stream, a text track list of cues -|output|, and a collection of CSS style sheets |stylesheets|, must decode the byte -stream using the UTF-8 decode algorithm, and then must parse the resulting -string according to the WebVTT parser algorithm below. This results in WebVTT cues -being added to |output|, and CSS style sheets being added to |stylesheets|. -[[!RFC3629]]

      +|output|, a collection of CSS style sheets |stylesheets|, and optionally a +slot |attributes| for a WebVTT attributes object, must decode the byte stream using the +UTF-8 decode algorithm, and then must parse the resulting string +according to the WebVTT parser algorithm below. This results in WebVTT cues +being added to |output|, CSS style sheets being added to |stylesheets|, and +if a WebVTT attributes block is present, a WebVTT attributes object being set in +|attributes|. [[!RFC3629]]

      A WebVTT parser, specifically its conversion and parsing steps, is typically run asynchronously, with the input byte stream being updated incrementally as the resource is @@ -2549,6 +2766,9 @@ stream lacks this WebVTT file signature, then the parser aborts.

    1. Otherwise, if |block| is a WebVTT region object, add |block| to |regions|.

    2. +
    3. Otherwise, if |block| is a WebVTT attributes object, and |attributes| has been + provided to this invocation of the WebVTT parser, let |attributes| be |block|.

    4. +
    5. collect a sequence of code points that are U+000A LINE FEED (LF) @@ -2589,6 +2809,8 @@ header set, the user agent must run the following steps:

    6. Let |region| be null.

    7. +
    8. Let |attributes| be null.

    9. +
    10. Loop: Run these substeps in a loop:

      @@ -2770,7 +2992,40 @@ header set, the user agent must run the following steps:

    11. - +
    12. + +

      Otherwise, if |seen cue| is false and |buffer| starts with the substring + "ATTRIBUTES" (U+0041, U+0054, U+0054, U+0052, U+0049, U+0042, U+0055, U+0054, + U+0045, U+0053), and the remaining characters in |buffer| (if any) are all ASCII + whitespace, then run these substeps:

      + +
        + +
      1. Attributes creation: Let |attributes| be a new WebVTT attributes + object.

      2. + +
      3. Let |attributes|'s kind be the empty + string.

      4. + +
      5. Let |attributes|'s type be the empty + string.

      6. + +
      7. Let |attributes|'s language be the + empty string.

      8. + +
      9. Let |attributes|'s label be the empty + string.

      10. + +
      11. Let |attributes|'s custom pairs + be an empty list.

      12. + +
      13. Let |buffer| be the empty string.

      14. + +
      + +
    13. + +
    @@ -2805,6 +3060,9 @@ header set, the user agent must run the following steps:

    using |region| for the results. Construct a WebVTT Region Object from |region|, and return it.

  • +
  • Otherwise, if |attributes| is not null, then collect WebVTT attributes from + |buffer| using |attributes| for the results, and return |attributes|.

  • +
  • Otherwise, return null.

  • @@ -2942,6 +3200,56 @@ means that it is aborted at that point and returns nothing.

    + +

    WebVTT attributes settings parsing

    + +

    When the WebVTT parser algorithm says to collect WebVTT attributes +from a string |input| for a WebVTT attributes object |attributes|, the user agent must +run the following steps:

    + +
      + +
    1. Let |lines| be the result of splitting |input| on U+000A LINE FEED (LF) characters.

    2. + +
    3. +

      For each string |line| in |lines|, run the following substeps:

      +
        + +
      1. If |line| does not contain a U+003A COLON character (:), then jump to + the step labeled next line.

      2. + +
      3. Let |name| be the leading substring of |line| up to and excluding the first U+003A + COLON character.

      4. + +
      5. If |name| is not a valid WebVTT attribute key, then jump to the step labeled + next line.

      6. + +
      7. Let |value| be the trailing substring of |line| starting from the character + immediately after the first U+003A COLON character.

      8. + +
      9. If |value| is not empty and its first character is a U+0020 SPACE or U+0009 + CHARACTER TABULATION (tab) character, remove that first character from |value|.

      10. + +
      11. Let |value| be the result of + parsing + character references in |value|, with no additional allowed character.

      12. + +
      13. Run the WebVTT rules for parsing attribute key/value pairs for |name| and + |value| against |attributes|.

      14. + +
      15. Next line: Continue.

      16. + +
      +
    4. + +
    5. +

      If |attributes|'s custom pairs is not + empty and |attributes|'s type is the empty string, + then, parsers may generate a warning.

      +
    6. + +
    +

    WebVTT cue timings and settings parsing

    When the algorithm above says to collect WebVTT cue timings and settings from a string @@ -4130,6 +4438,83 @@ follows:

    +

    WebVTT rules for parsing attribute key/value pairs

    + +

    The WebVTT rules for parsing attribute key/value pairs for a |name|/|value| pair +against a WebVTT attributes object |attributes| are as follows:

    + +
      +
    1. + How the pair is processed depends on |name|, as follows: +
      + +
      If |name| is an ASCII + case-insensitive match for "kind"
      +
      +

      Let |normalized| be the result of + converting |value| to ASCII + lowercase.

      +

      If |normalized| is one of "subtitles", "captions", + "descriptions", "chapters", or "metadata", set + |attributes|'s kind to |normalized|.

      +

      Otherwise, ignore the pair.

      +
      + +
      If |name| is an ASCII + case-insensitive match for "type"
      +
      +

      Let |normalized| be the result of + converting |value| to ASCII + lowercase.

      +

      If |normalized| is "custom" or starts with the prefix + "custom-" (U+0063, U+0075, U+0073, U+0074, U+006F, U+006D, U+002D), set + |attributes|'s type to |normalized|.

      +

      Otherwise, if |normalized| is not the empty string, ignore the pair. All non-custom + type values are reserved for future standardization.

      +
      + +
      If |name| is an ASCII + case-insensitive match for "language"
      +
      Set |attributes|'s language to + |value|.
      + +
      If |name| is an ASCII + case-insensitive match for "label"
      +
      Set |attributes|'s label to |value|.
      + +
      Otherwise
      +
      Append the pair (|name|, |value|) to |attributes|'s + custom pairs.
      + +
      +
    2. +
    + +

    The kind key is the only required key in a +WebVTT attributes block. It disambiguates the track kind and guards against naming +conflicts: consumers that do not recognise a given kind value should treat the +entire WebVTT attributes object as opaque. The type key further +differentiates subtypes within a kind (for example, distinguishing varieties of +metadata tracks). All non-custom type values are reserved for future +standardization; authors needing custom subtypes must use "custom" or a value +beginning with "custom-".

    + +

    The kind, type, language, and +label keys are matched +ASCII case-insensitively +to allow compatibility with implementations already using this pattern in production. +Unrecognized keys are preserved in the +custom pairs list for use by consuming +applications.

    + +

    The WebVTT attributes object's properties are consumed by the embedding +context. How kind, +language, and +label relate to the corresponding attributes of an +HTML <track> element is defined by the HTML specification. See +whatwg/html issue #11665.

    + +

    Rendering

    This section describes in some detail how to visually render WebVTT caption or