Skip to content

Commit f76d1ac

Browse files
committed
turn WebVTT muxing examples into XML/EBML
It's easier to comprehend what is going on.
1 parent b2bea54 commit f76d1ac

File tree

1 file changed

+78
-45
lines changed

1 file changed

+78
-45
lines changed

subtitles.md

+78-45
Original file line numberDiff line numberDiff line change
@@ -449,21 +449,22 @@ Example entry 2: Another entry.
449449
This one has multiple lines.
450450
451451
00:01:03.000 --> 00:01:06.500 position:90% align:right size:35%
452-
Example entry 3: That stuff to the right of the timestamps are cue \
453-
settings.
452+
Entry 3: That stuff to the right of the \
453+
timestamps are cue settings.
454454
455455
00:03:10.000 --> 00:03:20.000
456-
Example entry 4: Entries can even include timestamps.
456+
Entry 4: Entries can even include timestamps.
457457
For example:<00:03:15.000>This becomes visible five seconds
458458
after the first part.
459459
```
460460

461461
#### CodecPrivate
462462

463-
The resulting `CodecPrivate` element will look like this:
463+
The following XML depicts the `CodecPrivate` element contains the UTF-8 text of all global WebVTT blocks before the first subtitle entry:
464464

465-
```webvtt
466-
WEBVTT with text after the signature
465+
```xml
466+
<TrackEntry>
467+
<CodecPrivate>WEBVTT with text after the signature
467468

468469
STYLE
469470
::cue {
@@ -491,65 +492,97 @@ scroll:up
491492
NOTE
492493
Notes always span a whole block and can cover multiple
493494
lines. Like this one.
494-
An empty line ends the block.
495+
An empty line ends the block.</CodecPrivate>
496+
</TrackEntry>
495497
```
496498

497499
#### Cue Block 1
498500

499-
Example Cue 1: timestamp 00:00:00.000, duration 00:00:10.000, Block's content:
500-
501-
```webvtt
502-
Example entry 1: Hello <b>world</b>.
503-
```
504-
505-
BlockAddition's content starts with one empty line as there's no Cue Settings List:
506-
507-
```webvtt
508-
509-
hello
501+
The following XML depicts the nested elements of a `BlockGroup` element with of the first WebVTT cue block.
502+
The cue block timings are turned into Matroska timestamps.
503+
The last line feed character (U+0x000a) is stripped.
504+
505+
The `BlockAddition` content starts with one empty line as there's no WebVTT cue settings list:
506+
507+
```xml
508+
<BlockGroup>
509+
<Block timestamp="0">Example entry 1: Hello <b>world</b>.</Block>
510+
<BlockDuration>10000</BlockDuration> <!-- 10000 Ticks of 1 ms -->
511+
<BlockAdditions>
512+
<BlockMore>
513+
<BlockAddID>1</BlockAddID>
514+
<BlockAdditional>
515+
516+
hello</BlockAdditional>
517+
</BlockMore>
518+
</BlockAdditions>
519+
</BlockGroup>
510520
```
511521

512522
#### Cue Block 2
513523

514-
Example Cue 2: timestamp 00:00:25.000, duration 00:00:10.000, Block's content:
515-
516-
```webvtt
517-
Example entry 2: Another entry.
518-
This one has multiple lines.
519-
```
520-
521-
BlockAddition's content starts with two empty lines as there's neither a Cue Settings List nor a Cue Identifier:
522-
523-
```webvtt
524-
525-
NOTE style blocks cannot appear after the first cue.
524+
The following XML depicts the nested elements of a `BlockGroup` element with of the second WebVTT cue block.
525+
The last line feed character (U+0x000a) is stripped.
526+
527+
The `BlockAddition` content starts with two empty lines as there's neither a WebVTT cue settings list nor a WebVTT cue identifier,
528+
Then follows the content of the WebVTT comment block(s). The last line feed character (U+0x000a) is stripped.
529+
530+
```xml
531+
<BlockGroup>
532+
<Block timestamp="25000">Example entry 2: Another entry.
533+
This one has multiple lines.</Block>
534+
<BlockDuration>10000</BlockDuration>
535+
<BlockAdditions>
536+
<BlockMore>
537+
<BlockAddID>1</BlockAddID>
538+
<BlockAdditional>
539+
540+
NOTE style blocks cannot appear after the first cue.</BlockAdditional>
541+
</BlockMore>
542+
</BlockAdditions>
543+
</BlockGroup>
526544
```
527545

528546
#### Cue Block 3
529547

530-
Example Cue 3: timestamp 00:01:03.000, duration 00:00:03.500, Block's content:
531-
532-
```webvtt
533-
Example entry 3: That stuff to the right of the timestamps are cue \
534-
settings.
535-
```
536-
537-
BlockAddition's content ends with an empty line as there's no Cue Identifier and
538-
there were no WebVTT Comment blocks:
539-
540-
```webvtt
548+
The following XML depicts the nested elements of a `BlockGroup` element with of the third WebVTT cue block.
549+
The last line feed character (U+0x000a) is stripped.
550+
551+
The `BlockAddition` content ends with an empty line as there is no WebVTT cue identifier and
552+
there were no WebVTT comment block.
553+
554+
```xml
555+
<BlockGroup>
556+
<Block timestamp="63000">Entry 3: That stuff to the right of the \
557+
timestamps are cue settings.</Block>
558+
<BlockDuration>3500</BlockDuration>
559+
<BlockAdditions>
560+
<BlockMore>
561+
<BlockAddID>1</BlockAddID>
562+
<BlockAdditional>
541563
position:90% align:right size:35%
542564

565+
</BlockAdditional>
566+
</BlockMore>
567+
</BlockAdditions>
568+
</BlockGroup>
543569
```
544570

545571
#### Cue Block 4
546572

547-
Example Cue 4: timestamp 00:03:10.000, duration 00:00:10.000, Block's content:
573+
The following XML depicts the nested elements of a `BlockGroup` element with of the fourth WebVTT cue block.
574+
The last line feed character (U+0x000a) is stripped.
548575

549-
Example entry 4: Entries can even include timestamps. For example:<00:00:05.000>This becomes visible five seconds after the first part.
576+
No `BlockAddition` is used.
550577

551-
This Block does not need a BlockAddition as the Cue did not contain an Identifier,
552-
nor a Settings List, and it wasn't preceded by Comment blocks.
578+
```xml
579+
<BlockGroup>
580+
<Block timestamp="190000">Entry 4: Entries can even include timestamps.
581+
For example:<00:03:15.000>This becomes visible five seconds
582+
after the first part.</Block>
583+
<BlockDuration>10000</BlockDuration>
584+
</BlockGroup>
585+
```
553586

554587
### Storage of WebVTT in Matroska vs. WebM
555588

0 commit comments

Comments
 (0)