ФоÑÐ¼Ð°Ñ Web Video Text Tracks (WebVTT)ÑÑо ÑоÑÐ¼Ð°Ñ Ð´Ð»Ñ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ ÑинÑ
ÑонизиÑованнÑÑ
ÑекÑÑовÑÑ
ÑÑеков (Ñакие как ÑÑбÑиÑÑÑ Ð¸Ð»Ð¸ подпиÑи) Ñ Ð¿Ð¾Ð¼Ð¾ÑÑÑ ÑлеменÑов <track>
. ÐÑÐ½Ð¾Ð²Ð½Ð°Ñ ÑÐµÐ»Ñ Ñайлов WebVTT â добавиÑÑ ÑекÑÑовÑе Ð½Ð°Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ðº ÑлеменÑам <video>
. WebVTT ÑвлÑеÑÑÑ ÑекÑÑовÑм ÑоÑмаÑом, коÑоÑÑй должен бÑÑÑ Ð·Ð°ÐºÐ¾Ð´Ð¸Ñован Ñ Ð¸ÑполÑзованием UTF-8. Ð ÑÑиÑ
ÑайлаÑ
Ð²Ñ Ð¼Ð¾Ð¶ÐµÑе иÑполÑзоваÑÑ Ð¿ÑÐ¾Ð±ÐµÐ»Ñ Ð¸ ÑÐ°Ð±Ñ Ð´Ð»Ñ Ð¾ÑÑÑÑпов. СÑÑеÑÑвÑÐµÑ Ñакже неболÑÑой API Ð´Ð»Ñ Ð¿ÑедÑÑÐ°Ð²Ð»ÐµÐ½Ð¸Ñ Ð¸ ÑпÑÐ°Ð²Ð»ÐµÐ½Ð¸Ñ ÑÑими доÑожками и даннÑми, необÑ
одимÑми Ð´Ð»Ñ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ ÑекÑÑа в нÑжное вÑемÑ.
MIME Ñип Ñайлов WebVTT â text/vtt
.
Файл WebVTT (.vtt
) ÑодеÑÐ¶Ð¸Ñ Ñеплики (cues), коÑоÑÑе могÑÑ Ð±ÑÑÑ Ð¾Ð´Ð½Ð¾Ð¹ ÑÑÑокой или неÑколÑкими ÑÑÑоками, как показано ниже:
WEBVTT 00:01.000 --> 00:04.000 Ðикогда не пейÑе жидкий азоÑ. 00:05.000 --> 00:09.000 - ÐÑо пÑобÑÑÑ Ð²Ð°Ñ Ð¶ÐµÐ»Ñдок. - ÐÑ Ð¼Ð¾Ð¶ÐµÑе ÑмеÑеÑÑ.Тело WebVTT Ñайла
СÑÑÑкÑÑÑа WebVTT ÑоÑÑÐ¾Ð¸Ñ Ð¸Ð· ÑледÑÑÑÐ¸Ñ ÐºÐ¾Ð¼Ð¿Ð¾Ð½ÐµÐ½Ñов, некоÑоÑÑе из коÑоÑÑÑ ÑвлÑÑÑÑÑ Ð½ÐµÐ¾Ð±ÑзаÑелÑнÑми, в ÑледÑÑÑем поÑÑдке:
ÐеобÑзаÑелÑнÑй знак поÑÑдка байÑов (BOM).
СÑÑока "WEBVTT
".
ÐополниÑелÑнÑй ÑекÑÑовÑй заголовок ÑпÑава Ð¾Ñ WEBVTT.
WEBVTT.
-->
".ÐÑÑÑÐ°Ñ ÑÑÑока, коÑоÑÐ°Ñ ÑквиваленÑна двÑм поÑледоваÑелÑнÑм пеÑеводам ÑÑÑоки.
ÐÐ¾Ð»Ñ Ð¸Ð»Ð¸ более Ñеплик или комменÑаÑиев .
ÐÐ¾Ð»Ñ Ð¸Ð»Ð¸ более пÑÑÑÑÑ ÑÑÑок.
WEBVTTÐÑÐ¸Ð¼ÐµÑ 2 - ÐÑÐµÐ½Ñ Ð¿ÑоÑÑой Ñайл WebVTT Ñ ÑекÑÑовÑм заголовком
WEBVTT - ÐÑÐ¾Ñ Ñайл не ÑодеÑÐ¶Ð¸Ñ Ñеплик.ÐÑÐ¸Ð¼ÐµÑ 3 - ÐбÑÑнÑй WebVTT Ñ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ¾Ð¼ и Ñепликами
WEBVTT - ÐÑÐ¾Ñ Ñайл ÑодеÑÐ¶Ð¸Ñ Ñеплики. 14 00:01:14.815 --> 00:01:18.114 - ЧÑо? - Ðде Ð¼Ñ ÑейÑаÑ? 15 00:01:18.171 --> 00:01:20.991 - ÐÑо болÑÑÐ°Ñ ÑÑÑана леÑÑÑÐ¸Ñ Ð¼ÑÑей. 16 00:01:21.058 --> 00:01:23.868 - [ Ðизг леÑÑÑÐ¸Ñ Ð¼ÑÑей ] - Ðни не попадÑÑ Ð² Ñвои волоÑÑ. They're after the bugs.ÐнÑÑÑеннÑÑ ÑÑÑÑкÑÑÑа Ñайла WebVTT
ÐавайÑе веÑнÑмÑÑ Ðº Ð¾Ð´Ð½Ð¾Ð¼Ñ Ð¸Ð· наÑÐ¸Ñ Ð¿ÑедÑдÑÑÐ¸Ñ Ð¿ÑимеÑов и ÑаÑÑмоÑÑим ÑÑÑÑкÑÑÑÑ Ñеплик более подÑобно.
WEBVTT 00:01.000 --> 00:04.000 - Never drink liquid nitrogen. 00:05.000 --> 00:09.000 - It will perforate your stomach. - You could die. NOTE ÐÑо поÑледнÑÑ ÑÑÑока в Ñайле
Рданном ÑлÑÑае ÐºÐ°Ð¶Ð´Ð°Ñ Ñеплика:
-->
.ÐÑ Ñакже можем ÑазмеÑÑиÑÑ ÐºÐ¾Ð¼Ð¼ÐµÐ½ÑаÑии в наÑем Ñайле .vtt
, ÑÑÐ¾Ð±Ñ Ð¿Ð¾Ð¼Ð¾ÑÑ Ð½Ð°Ð¼ запомниÑÑ Ð²Ð°Ð¶Ð½ÑÑ Ð¸Ð½ÑоÑмаÑÐ¸Ñ Ð¾ ÑаÑÑÑÑ
наÑего Ñайла. Ðни Ð´Ð¾Ð»Ð¶Ð½Ñ Ð±ÑÑÑ Ð² оÑделÑнÑÑ
ÑÑÑокаÑ
, наÑинаÑÑиÑ
ÑÑ Ñо Ñлова NOTE
. ÐодÑобнее об ÑÑом Ñказано в ÑледÑÑÑем Ñазделе.
Ðажно не иÑполÑзоваÑÑ Ð´Ð¾Ð¿Ð¾Ð»Ð½Ð¸ÑелÑнÑе пÑÑÑÑе ÑÑÑоки в Ñеплике, напÑимеÑ, Ð¼ÐµÐ¶Ð´Ñ ÑÑÑокой ÑÐ¸Ð½Ñ ÑонизаÑии и ÑекÑÑом Ñеплики. WebVTT иÑполÑзÑÐµÑ ÑÑÑоÑнÑе ÑазделиÑели, поÑÑÐ¾Ð¼Ñ Ð¿ÑÑÑÐ°Ñ ÑÑÑока обознаÑÐ¸Ñ Ð¾ÐºÐ¾Ð½Ñание Ñеплики.
ÐомменÑаÑии в WebVTTComments are an optional component that can be used to add information to a WebVTT file. Comments are intended for those reading the file and are not seen by users. Comments may contain newlines but cannot contain a blank line, which is equivalent to two consecutive newlines. A blank line signifies the end of a comment.
A comment cannot contain the string -->
, the ampersand character (&
), or the less-than sign (<
). If you wish to use such characters, you need to escape them using for example &
for ampersand and <
for less-than. It is also recommended that you use the greater-than escape sequence (>
) instead of the greater-than character (>
) to avoid confusion with tags.
A comment consists of three parts:
NOTE
.Common WebVTT example
NOTE This is a comment
Multi-line comment
NOTE One comment that is spanning more than one line. NOTE You can also make a comment across more than one line this way.
Common comment usage
WEBVTT - Translation of that film I like NOTE This translation was done by Kyle so that some friends can watch it with their parents. 1 00:02:15.000 --> 00:02:20.000 - Ta en kopp varmt te. - Det är inte varmt. 2 00:02:20.000 --> 00:02:25.000 - Har en kopp te. - Det smakar som te. NOTE This last line may not translate well. 3 00:02:25.000 --> 00:02:30.000 - Ta en kopp
Реплики WebVTT можно ÑÑилизоваÑÑ, иÑполÑзÑÑ Ð¿ÑевдоÑÐ»ÐµÐ¼ÐµÐ½Ñ ::cue
.
video::cue {
background-image: linear-gradient(to bottom, dimgray, lightgray);
color: papayawhip;
}
video::cue(b) {
color: peachpuff;
}
Рданном пÑимеÑе Ñоном видео бÑÐ´ÐµÑ ÑеÑÑй гÑадиенÑ, Ñ ÑвеÑом ÑекÑÑа "papayawhip"
. Также, ÑекÑÑ, вÑделеннÑй жиÑнÑм ÑÑиÑÑом Ñ Ð¿Ð¾Ð¼Ð¾ÑÑÑ ÑлеменÑа <b>
, Ð¸Ð¼ÐµÐµÑ ÑÐ²ÐµÑ "peachpuff"
.
ФÑÐ°Ð³Ð¼ÐµÐ½Ñ HTML, пÑиведÑннÑй ниже, оÑобÑÐ°Ð¶Ð°ÐµÑ Ð²Ð¸Ð´ÐµÐ¾.
<video controls autoplay src="video.webm">
<track default src="track.vtt" />
</video>
Within the WebVTT file itself
You can also define the style directly in the WebVTT file. In this case, you insert your CSS rules into the file with each rule preceded by the string "STYLE"
all by itself on a line of text, as shown below:
WEBVTT 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; } 00:00:00.000 --> 00:00:10.000 - Hello <b>world</b>. NOTE style blocks cannot appear after the first cue.
We can also use identifiers inside WebVTT file, which can be used for defining a new style for some particular cues in the file. The example where we wanted the transcription text to be red highlighted and the other part to remain normal, we can define it as follows using CSS. Where it must be noted that the CSS uses escape sequences the way they are used in HTML pages:
WEBVTT 1 00:00.000 --> 00:02.000 That's an, an, that's an L! crédit de transcription 00:04.000 --> 00:05.000 Transcrit par Célestesâ¢
::cue(#\31) {
color: lime;
}
::cue(#crédit\ de\ transcription) {
color: red;
}
Positioning of text tracks is also supported, by including positioning information after the timings in a cue, as seen below (see Cue settings for more information):
WEBVTT 00:00:00.000 --> 00:00:04.000 position:10%,line-left align:left size:35% Where did he go? 00:00:03.000 --> 00:00:06.500 position:90% align:right size:35% I think he went down this lane. 00:00:04.000 --> 00:00:06.500 position:45%,line-right align:center size:35% What are you waiting for?WebVTT cues
A cue is a single subtitle block that has a single start time, end time, and textual payload. A cue consists of five components:
Here is an example of a cue:
1 - Title Crawl 00:00:05.000 --> 00:00:10.000 line:0 position:20% size:60% align:start Some time ago in a place rather distant....Cue identifier
The identifier is a name that identifies the cue. It can be used to reference the cue from a script. It must not contain a newline and cannot contain the string "-->
". It must end with a single new line. They do not have to be unique, although it is common to number them (e.g., 1, 2, 3).
Here are a few examples:
A basic cue identifier
1 - Title Crawl
Common usage of identifiers
WEBVTT 1 00:00:22.230 --> 00:00:24.606 This is the first subtitle. 2 00:00:30.739 --> 00:00:34.074 This is the second. 3 00:00:34.159 --> 00:00:35.743 Third
A cue timing indicates when the cue is shown. It has a start and end time which are represented by timestamps. The end time must be greater than the start time, and the start time must be greater than or equal to all previous start times. Cues may have overlapping timings.
If the WebVTT file is being used for chapters (<track>
kind
is chapters
) then the file cannot have overlapping timings.
Each cue timing contains five components:
-->
".The timestamps must be in one of two formats:
mm:ss.ttt
hh:mm:ss.ttt
Where the components are defined as follows:
hh
Represents hours and must be at least two digits. It can be greater than two digits (e.g., 9999:00:00.000
).
mm
Represents minutes and must be between 00 and 59, inclusive.
ss
Represents seconds and must be between 00 and 59, inclusive.
ttt
Represents milliseconds and must be between 000 and 999, inclusive.
Here are a few cue timing examples:
Basic cue timing examples
00:00:22.230 --> 00:00:24.606 00:00:30.739 --> 00:00:34.074 00:00:34.159 --> 00:00:35.743 00:00:35.827 --> 00:00:40.122
Overlapping cue timing examples
00:00:00.000 --> 00:00:10.000 00:00:05.000 --> 00:01:00.000 00:00:30.000 --> 00:00:50.000
Non-overlapping cue timing examples
00:00:00.000 --> 00:00:10.000 00:00:10.000 --> 00:01:00.581 00:01:00.581 --> 00:02:00.100 00:02:01.000 --> 00:02:01.000
Cue settings are optional components used to position where the cue payload text will be displayed over the video. This includes whether the text is displayed horizontally or vertically. There can be zero or more of them, and they can be used in any order so long as each setting is used no more than once.
The cue settings are added to the right of the cue timings. There must be one or more spaces between the cue timing and the first setting and between each setting. A setting's name and value are separated by a colon. The settings are case sensitive so use lower case as shown. There are five cue settings:
vertical
Indicates that the text will be displayed vertically rather than horizontally, such as in some Asian languages. There are two possible values:
rl
The writing direction is right to left
lr
The writing direction is left to right
line
If vertical is not set, specifies where the text appears vertically. If vertical is set, line specifies where text appears horizontally. Its value can be:
The number is the height of the first line of the cue as it appears on the video. Positive numbers indicate top down and negative numbers indicate bottom up.
It must be an integer (i.e., no decimals) between 0 and 100 inclusive and must be followed by a percent sign (%).
vertical
omitted vertical:rl
vertical:lr
line:0
top right left line:-1
bottom left right line:0%
top right left line:100%
bottom left right
position
Specifies where the text will appear horizontally. If vertical is set, position specifies where the text will appear vertically. The value is a percentage, that is an integer (no decimals) between 0 and 100 inclusive followed by a percent sign (%).
Positionvertical
omitted vertical:rl
vertical:lr
position:0%
left top top position:100%
right bottom bottom
size
Specifies the width of the text area. If vertical is set, size specifies the height of the text area. The value is a percentage, that is an integer (no decimals) between 0 and 100 inclusive followed by a percent sign (%).
Sizevertical
omitted vertical:rl
vertical:lr
size:100%
full width full height full height size:50%
half width half height half height
align
Specifies the alignment of the text. Text is aligned within the space given by the size cue setting if it is set.
Alignvertical
omitted vertical:rl
vertical:lr
align:start
left top top align:center
centered horizontally centered vertically centered vertically align:end
right bottom bottom
Let's study an example of cue setting.
The first line demonstrates no settings. The second line might be used to overlay text on a sign or label. The third line might be used for a title. The last line might be used for an Asian language.
00:00:05.000 --> 00:00:10.000 00:00:05.000 --> 00:00:10.000 line:63% position:72% align:start 00:00:05.000 --> 00:00:10.000 line:0 position:20% size:60% align:start 00:00:05.000 --> 00:00:10.000 vertical:rt line:-1 align:endCue payload
The payload is where the main information or content is located. In normal usage the payload contains the subtitles to be displayed. The payload text may contain newlines but it cannot contain a blank line, which is equivalent to two consecutive newlines. A blank line signifies the end of a cue.
A cue text payload cannot contain the string -->
, the ampersand character (&
), or the less-than sign (<
). Instead use the escape sequence &
for ampersand and <
for less-than. It is also recommended that you use the greater-than escape sequence >
instead of the greater-than character (>
) to avoid confusion with tags. If you are using the WebVTT file for metadata these restrictions do not apply.
In addition to the three escape sequences mentioned above, there are fours others. They are listed in the table below.
Name Character Escape sequence Ampersand&
&
Less-than <
<
Greater-than >
>
Left-to-right mark none ‎
Right-to-left mark none ‏
Non-breaking space
Cue payload text tags
There are a number of tags, such as <b>
, that can be used. However, if the WebVTT file is used in a <track>
element where the attribute kind
is chapters
then you cannot use tags.
The timestamp must be greater that the cue's start timestamp, greater than any previous timestamp in the cue payload, and less than the cue's end timestamp. The active text is the text between the timestamp and the next timestamp or to the end of the payload if there is not another timestamp in the payload. Any text before the active text in the payload is previous text. Any text beyond the active text is future text. This enables karaoke style captions.
1 00:16.500 --> 00:18.500 When the moon <00:17.500>hits your eye 1 00:00:18.500 --> 00:00:20.500 Like a <00:19.000>big-a <00:19.500>pizza <00:20.000>pie 1 00:00:20.500 --> 00:00:21.500 That's <00:00:21.000>amore
The following tags are the HTML tags allowed in a cue and require opening and closing tags (e.g., <b>text</b>
).
<c></c>
)
Style the contained text using a CSS class.
<i></i>
)
Italicize the contained text.
<b></b>
)
Bold the contained text.
<u></u>
)
Underline the contained text.
<ruby></ruby>
)
Used with ruby text tags to display ruby characters (i.e., small annotative characters above other characters).
<ruby>WWW<rt>World Wide Web</rt>oui<rt>yes</rt></ruby>
<rt></rt>
)
Used with ruby tags to display ruby characters (i.e., small annotative characters above other characters).
<ruby>WWW<rt>World Wide Web</rt>oui<rt>yes</rt></ruby>
<v></v>
)
Similar to class tag, also used to style the contained text using CSS.
The methods used in WebVTT are those which are used to alter the cue or region as the attributes for both interfaces are different. We can categorize them for better understanding relating to each interface in WebVTT:
VTTCueThe methods which are available in the VTTCue
interface are:
getCueAsHTML()
to get the HTML of that cue.VTTCue()
for creating new instances of this interface.Different properties allowing to read and set the characteristics of the cue, like its position, alignment or size are also available. Check VTTCue
for a complete list.
The VTTRegion
provides methods used for region are listed below along with description of their functionality, especially it allows to adjust the scrolling setting of all nodes present in the given region.
There are few steps that can be followed to write a simple webVTT file. Before start, it must be noted that you can make use of a notepad and then save the file as '.vtt' file. Steps are given below:
Open a notepad.
The first line of WebVTT is standardized similar to the way some other languages require you to put headers as the file starts to indicate the file type. On the very first line you have to write:
WEBVTT
Leave the second line blank, and on the third line the time for first cue is to be specified. For example, for a first cue starting at time 1 second and ending at 5 seconds, it is written as:
00:01.000 --> 00:05.000
On the next line you can write the caption for this cue which will run from the first second to the fifth second, inclusive.
Following the similar steps, a complete WebVTT file for specific video or audio file can be made.
CSS pseudo classes allow us to classify the type of object which we want to differentiate from other types of objects. It works in similar manner in WebVTT files as it works in HTML file.
It is one of the good features supported by WebVTT is the localization and use of class elements which can be used in same way they are used in HTML and CSS to classify the style for particular type of objects, but here these are used for styling and classifying the Cues as shown below:
WEBVTT 04:02.500 --> 04:05.000 J'ai commencé le basket à l'âge de 13, 14 ans 04:05.001 --> 04:07.800 Sur les <i.foreignphrase><lang en>playground</lang></i>, ici à Montpellier
In the above example it can be observed that we can use the identifier and pseudo class name for defining the language of caption, where <i>
tag is for italics.
The type of pseudo class is determined by the selector it is using and working is similar in nature as it works in HTML. Following CSS pseudo classes can be used:
lang
(Language): e.g., p:lang(it)
.link
: e.g., a:link
.nth-last-child
: e.g., p:nth-last-child(2)
.nth-child(n)
: e.g., p:nth-child(2)
.Where p and a are the tags which are used in HTML for paragraph and link, respectively and they can be replaced by identifiers which are used for Cues in WebVTT file.
СпеÑиÑикаÑии СовмеÑÑимоÑÑÑ Ñ Ð±ÑаÑзеÑами api.VTTCue api.TextTrack api.VTTRegion NotesPrior to Firefox 50, the AlignSetting
enum (representing possible values for VTTCue.align
) incorrectly included the value "middle"
instead of "center"
. This has been corrected.
WebVTT was implemented in Firefox 24 behind the preference media.webvtt.enabled
, which is disabled by default; you can enable it by setting this preference to true
. WebVTT is enabled by default starting in Firefox 31 and can be disabled by setting the preference to false
.
Prior to Firefox 58, the REGION
keyword was creating VTTRegion
objects, but they were not being used. Firefox 58 now fully supports VTTRegion
and its use; however, this feature is disabled by default behind the preference media.webvtt.regions.enabled
; set it to true
to enable region support in Firefox 58. Regions are enabled by default starting in Firefox 59 (see bugs Firefox bug 1338030 and Firefox bug 1415805).
::cue
and ::cue()
pseudo-elementsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4