Re: Storage of WebVTT subtitles in Matroska
Moritz Bunkus via Matroska-devel <[email protected]> Fri, 1 Apr 2016 20:19:58 +0200
| Newsgroups | gmane.comp.multimedia.matroska.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============8428683844628423256==
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="zHDeOHGDnzKksZSU"
Content-Disposition: inline
--zHDeOHGDnzKksZSU
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hey,
> Why not put the identifier and style inside the block addition keeping
> the same formalism?
=E2=80=A6
> or even better (imo) swap line 1 and 2 since what interests the player
> is the style and not the id and the notes.
=E2=80=A6
> This would really allow a player to interpret the whole WebVTT stuff
> as srt without too much effort and then add in a second time the
> support of style
Valid points.
Another update to the proposal:
--start-----------------------------------------------------
(A) CodecID: S_TEXT/WEBVTT
(B) Matroska CodecPrivate: This element contains all global blocks
before the first subtitle entry. This starts at the "WEBVTT" file
identification marker but excludes the optional byte order mark.
(C) Non-global WebVTT blocks (e.g. "NOTE") before a WebVTT Cue Text are
stored in Matroska's BlockAddition element together with the
Matroska Block containing the WebVTT Cue Text these blocks precede
(see below for he actual format).
(D) Matroska Blocks: Each WebVTT Cue Text is stored directly in the
Matroska Block.
A muxer must change all WebVTT Cue Timestamps present within the Cue
Text to be relative to the Matroska Block's timestamp.
The Cue's start timestamp is used as the Matroska Block's timestamp.
The difference between the Cue's end timestamp and its start
timestamp is used as the Matroska Block's duration.
(E) Matroska BlockAdditions: each Matroska Block may be accompanied by
one BlockAdditions element. Its format is as follows:
The first line contains the WebVTT Cue Text's optional Cue Settings
List followed by one line feed character (U+0x000a). The Cue
Settings List may be empty in which case the line consists of the
line feed character only.
The second line contains the WebVTT Cue Text's optional Cue
Identifier followed by one line feed character (U+0x000a). The line
may be empty indicating that there was no Cue Identifier in the
source file in which case the line consists of the line feed
character only.
The third and all following lines contain all WebVTT Comment Blocks
that precede the current WebVTT Cue Block. These may be absent.
If there is no Matroska BlockAddition element stored together with
the Matroska Block then all three components (Cue Settings List, Cue
Identifier, Cue Comments) must be assumed to be absent.
--end-------------------------------------------------------
Rationale for the changes:
(A) Consistency: most text subtitle formats in Matroska use S_TEXT/=E2=80=
=A6.
(B) Again keeping as much data as possible. In WebVTT the file signature
may be followed by additional data. So let's just keep that data
intact. It doesn't cost much, and a demuxer could feed CodecPrivate
directly into a WebVTT parser.
(C), (D) and (E) have been changed according to Denis' proposal to store
the non-text components in BlockAdditions elements.
Example. WebVTT source file:
--start-----------------------------------------------------
WEBVTT with text after the signature
STYLE
::cue {
background-image: linear-gradient(to bottom, dimgray, lightgray);
color: papayawhip;
}
/* Style blocks cannot use blank lines nor "dash dash greater than" */
NOTE comment blocks can be used between style blocks.
STYLE
::cue(b) {
color: peachpuff;
}
REGION
id:bill
width:40%
lines:3
regionanchor:0%,100%
viewportanchor:10%,90%
scroll:up
NOTE
Notes always span a whole block and can cover multiple
lines. Like this one.
An empty line ends the block.
hello
00:00:00.000 --> 00:00:10.000
Example entry 1: Hello <b>world</b>.
NOTE style blocks cannot appear after the first cue.
00:00:25.000 --> 00:00:35.000
Example entry 2: Another entry.
This one has multiple lines.
00:01:03.000 --> 00:01:06.500 position:90% align:right size:35%
Example entry 3: That stuff to the right of the timestamps are cue settings.
00:03:10.000 --> 00:03:20.000
Example entry 4: Entries can even include timestamps.
For example:<00:03:15.000>This becomes visible five seconds
after the first part.
--end-------------------------------------------------------
Resulting CodecPrivate element:
--start-----------------------------------------------------
WEBVTT with text after the signature
STYLE
::cue {
background-image: linear-gradient(to bottom, dimgray, lightgray);
color: papayawhip;
}
/* Style blocks cannot use blank lines nor "dash dash greater than" */
NOTE comment blocks can be used between style blocks.
STYLE
::cue(b) {
color: peachpuff;
}
REGION
id:bill
width:40%
lines:3
regionanchor:0%,100%
viewportanchor:10%,90%
scroll:up
NOTE
Notes always span a whole block and can cover multiple
lines. Like this one.
An empty line ends the block.
--end-------------------------------------------------------
Example Cue 1: timestamp 00:00:00.000, duration 00:00:10.000, Block's
content:
--start-----------------------------------------------------
Example entry 1: Hello <b>world</b>.
--end-------------------------------------------------------
BlockAddition's content:
--start-----------------------------------------------------
hello
--end-------------------------------------------------------
Example Cue 2: timestamp 00:00:25.000, duration 00:00:10.000, Block's
content:
--start-----------------------------------------------------
Example entry 2: Another entry.
This one has multiple lines.
--end-------------------------------------------------------
BlockAddition's content:
--start-----------------------------------------------------
NOTE style blocks cannot appear after the first cue.
--end-------------------------------------------------------
Example Cue 3: timestamp 00:01:03.000, duration 00:00:03.500, Block's
content:
--start-----------------------------------------------------
Example entry 3: That stuff to the right of the timestamps are cue settings.
--end-------------------------------------------------------
BlockAddition's content:
--start-----------------------------------------------------
position:90% align:right size:35%
--end-------------------------------------------------------
Example Cue 4: timestamp 00:03:10.000, duration 00:00:10.000, Block's conte=
nt:
--end-------------------------------------------------------
Example entry 4: Entries can even include timestamps.
For example:<00:00:05.000>This becomes visible five seconds
after the first part.
--end-------------------------------------------------------
This Block does not need a BlockAddition as the Cue did not contain an
Identifier, nor a Settings List, and it wasn't preceded by Comment
blocks.
Kind regards,
mosu
--zHDeOHGDnzKksZSU
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIcBAABCgAGBQJW/rvIAAoJEHSvAK3y4yyFDLEP/0JJRBiTYO5VwtwfmZcGzu/A
uL20eZ+UsZA8FREpHAIfa7qGw16iJbeko95ILu7DIUuf7KNBUUcr4sp1OMw9lV7l
5yznaBZnP7P+BunaUmLo98dFsNnaUa+kBYrQRwQfktchh4h7iGIKF9P7WwHQlN6M
O39STN+BhJa6LQ/NDbtGCRNMKWOFHZOdMLR1qpBsHpBhYToO/2CJgy2mHcKV1wCH
XdUpU9PlqadPsmqwpcqN0rLWu1Md/9xEx5On0/07mPQWKNIqJAjGZQzHknF0Wnoj
oVYaSBAy9ZVtPJiemSSv1Jirnrk+8YDa6RdycGYL+/E8PJ8HPHxSiJRzcVywjw9q
8IXB5ZrFhVcOlIhpOzZIpGu8hpqalJmVoMqNm+jWr60mcBiKgU5X7mesiSC9p0u6
304IgyPlZWVftzH08ohuu6lh6IUvTsnuMPAjPxFZVZeGC+MuqEMliWkNKEszG9ht
K7sGGcSl2n0d9dw0lp4Wy/CcQR8IYuQF2UXuNor+VHcuWWf7eG46i91KMgXWVlHy
xVGA6brbgUQG+dFtYCFLPDmxIsuNbI+KBoaUfLAcLlxZJOmmdKZN9gwt1GxVQY2z
97ImhEoyEsjdL1VstNaQdFXIQDuuCCKi+dz9jyaQ3FdU8M+77C1vDVpl+jlHcr4n
ssoRLNv64q9O/3TX1xYU
=2uik
-----END PGP SIGNATURE-----
--zHDeOHGDnzKksZSU--
--===============8428683844628423256==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KTWF0cm9za2Et
ZGV2ZWwgbWFpbGluZyBsaXN0Ck1hdHJvc2thLWRldmVsQGxpc3RzLm1hdHJvc2thLm9yZwpodHRw
Oi8vbGlzdHMubWF0cm9za2Eub3JnL2NnaS1iaW4vbWFpbG1hbi9saXN0aW5mby9tYXRyb3NrYS1k
ZXZlbApSZWFkIE1hdHJvc2thLURldmVsIG9uIEdNYW5lOiBodHRwOi8vZGlyLmdtYW5lLm9yZy9n
bWFuZS5jb21wLm11bHRpbWVkaWEubWF0cm9za2EuZGV2ZWw=
--===============8428683844628423256==--