“The WebVTT format (Web Video Text Tracks) is a format intended for marking up external text track resources. The main use for WebVTT files is captioning video content.” (WebVTT, retr. April 23 2012). A WebVTT includes a list of so-called cues that can be used by a player to overlay information on the video (e.g. texts or graphics) and for navigation.
WebVTT can be used in the track element of HTML5 video. One can associate different track files with a single video, e.g. multiple language files or multiple formats or various types. As of April 2012, browsers either do not yet implement this or only partially (like Chrome), but some JavaScript-based HTML5 players do implement various subsets of either WebVTT or competing standards such as the simple SRT format.
See also:
Do not trust details. Need to test this first - Daniel K. Schneider 19:25, 23 April 2012 (CEST)
The WebVTT format is a fairly complex plain text format. It surprisingly doesn't use XML. However, its data part (the cue contents) can include some XML-like markup.
A WebVTT file has the following structure:
In addition:
AddType text/vtt .vtt
Simple example
This works with Chrome 18, but you will have to enable track using the chrome://flags URI. Search for track, the click to activate. Track file:
WEBVTT
Introduction
00:00:01.000 --> 00:01:10.000
Wikipedia is a great adventure. It may have
its shortcomings, but it is the largest collective
knowledge construction endevour
Disclaimer
00:01:10.000 --> 00:02:10.000
This is just a track demo using VTT
As you can see, there is a "WEBVTT" header and cues are separated by blank lines. We will explain the cue syntax below.
HTML5 portion (read the HTML5 audio and video article for details):
<video id="movie1" controls preload="metadata">
<source src="videos/state-of-wikipedia-480x272.mp4"/>
<source src="videos/state-of-wikipedia-480x272.ogv"/>
<source src="videos/state-of-wikipedia-480x272.webm"/>
<track kind="subtitles" label="EN subtitles" src="subtitles_en.vtt" srclang="en" default/>
<track kind="subtitles" label="Soustitre en FR" src="subtitles_fr.vtt" srclang="fr"/>
Your browser doesn't support HTML5. Maybe you should upgrade.
</video>
Live example files:
Cues roughly have the following structure:
"-->"
, \r
, \n
, and \r\n
00.00.01.000 --> 00.01.01.017 00.01.000 --> 01.01.017 00.00.01.000 --> 00.01.01.017 T:50%
The following simple example demonstrates the use of header, timing line and a single text line.
WEBVTT
1
00:00:01.000 --> 00:00:20.000
<v DKS>This is a <b>very short</b> video that is not about WEBVTT
2
00:00:21.000 --> 00:00:40.000
You see a typical example
of a robot moving forward
On the timing line one can define position, alignment and size.
Line position
Horizontal position
Horizontal alignment
Text width
Vertical text
Example
WEBVTT
1
00:00.000 --> 01:00.000 vertical:rl
Pile of characters
2
00:01.000 --> 00:02.000 S:50%
Bon soir !
You also can use karaoke style cues, i.e. (if we understood right), text that scrolls up.
source: HTML5 doctor)
WEBVTT
1
00:00:01.000 --> 00:00:10.000
Never gonna give you up <00:00:01.000>
Never gonna let you down <00:00:05.000>
Never gonna run around and desert you
You can use HTML p
tags.
WEBVTT
Introduction
00:00:10.000 --> 00:01:10.000
<p>Wikipedia is a great adventure</p>
<p>It may have shortcomings, but it remains the largest collective knowledge construction endevour</p>
Disclaimer
00:01:10.000 --> 00:02:10.000
<p>This is just a track demo using VTT</p>
If we understood right, anything can go into the content lines of a cue, provided that some interpreter can read it. The following shows a JSON data structure that could be interpreted by some HTML5 player.
WEBVTT
Wikipedia
00:01:15.200 --> 00:02:18.800
{
"title": "State of Wikipedia",
"description": "Jimmy Wales talking ...",
"src": "http://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/120px-Wikipedia-logo-v2.svg.png",
"href": "http://en.wikipedia.org/wiki/Wikipedia"
}
When you succeeded to add your subtitles, you might wish to personalise them a little bit with CSS.
Here it is the solution and the way to do it. See the VTT file below. Read carrefully. You'll see the code <c ...></c>
WEBVTT
Introduction
00:00:01.000 --> 00:01:10.000
<c.vIntro>Wikipedia is a great adventure. It may have
its shortcomings, but it is the largest collective
knowledge construction endevour</c>
Disclaimer
00:01:10.000 --> 00:02:10.000
This is just a track demo using VTT
Now, in your css file (that belong to your webpage of course), just add this :
.vIntro {
color: coral;
text-transform: uppercase;
font-family: "Helvetica Neue";
font-weight: lighter;
font-size: 18px;
text-decoration: underline;
}
Now you are able to use CSS for your VTT files.
As of April 2012:
chrome://flags
If your browser doesn't support VTT, some HTML5 video players do provide support. See HTML5 audio and video for some more information about these. There exist probably over a dozen good players. Below we show a live example using such a player.
Simple example 1 (taken from the draft specification)
WEBVTT
00:11.000 --> 00:13.000
<v Roger Bingham>We are in New York City
00:13.000 --> 00:16.000
<v Roger Bingham>We're actually at the Lucern Hotel, just down the street
Simple live example using the LeanBack Player
<div class="leanback-player-video">
<video controls="controls" preload="metadata" poster="wikipedialogo.png" width="480" height="272">
<source src="videos/state-of-wikipedia-480x272.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
<source src="videos/state-of-wikipedia-480x272.webm" type='video/webm; codecs="vp8, vorbis"' />
<source src="videos/state-of-wikipedia-480x272.ogv" type='video/ogg; codecs="theora, vorbis"' />
<track enabled="true" kind="subtitles" label="EN"
src="subtitles_en.srt" srclang="en" type="text/x-srt"/>
<track enabled="true" kind="subtitles" label="EN VTT"
src="subtitles_en.vtt" srclang="en" type="text/vtt"/>
<track enabled="true" kind="subtitles" label="FR"
src="subtitles_fr.vtt" srclang="fr" type="text/vtt"/>
<object class="leanback-player-flash-fallback" width="640" height="360"
type="application/x-shockwave-flash"
data="http://releases.flowplayer.org/swf/flowplayer.swf">
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer.swf" />
<param name="allowFullScreen" value="true" />
<param name="wmode" value="opaque" />
<param name="bgcolor" value="#000000" />
<param name="flashVars"
value="config={'playlist':['wikipedialogo.png',
{'url':'videos/state-of-wikipedia-480x272.mp4','autoPlay':false,'autobuffering':false}]}" />
</object>
<div class="leanback-player-html-fallback" style="width: 640px; height: 360px;">
<img src="wikipedialogo.png" width="640" height="360" alt="Poster Image"
title="No HTML5-Video playback capabilities found. Please download the video(s) below." />
<div>
<strong>Download Video:</strong>
<a href="videos/state-of-wikipedia-480x272.mp4">.mp4</a>
<a href="videos/state-of-wikipedia-480x272.webm">.webm</a>
<a href="videos/state-of-wikipedia-480x272.ogv">.ogv</a>
</div>
</div>
</div>
Live example file:
Track files:
As you can see this player relies on extra markup: