Tracks

Text Tracks are a function of HTML5 video for providing time triggered text to the viewer. Video.js makes tracks work across all browsers. There are currently five types of tracks:

Creating the Text File

Timed text requires a text file in WebVTT format. This format defines a list of "cues" that have a start time, and end time, and text to display. Microsoft has a builder that can help you get started on the file.

When creating captions, there's also additional [caption formatting techniques] (http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_FORMAT.HTML#style) that would be good to use, like brackets around sound effects: [ sound effect ]. If you'd like a more in depth style guide for captioning, you can reference the Captioning Key, but keep in mind not all features are supported by WebVTT or (more likely) the Video.js WebVTT implementation.

Adding to Video.js

Once you have your WebVTT file created, you can add it to Video.js using the track tag. Put your track tag after all the source elements, and before any fallback content.

<video id="example_video_1" class="video-js vjs-default-skin"
  controls preload="auto" width="640" height="264"
  data-setup='{"example_option":true}'>
 <source src="http://video-js.zencoder.com/oceans-clip.mp4" type="video/mp4" />
 <source src="http://video-js.zencoder.com/oceans-clip.webm" type="video/webm" />
 <source src="http://video-js.zencoder.com/oceans-clip.ogv" type="video/ogg" />

 <track kind="captions" src="http://example.com/path/to/captions.vtt" srclang="en" label="English" default>

</video>

Subtitles from Another Domain

Because we're pulling in the text track file via Javascript, the same-origin policy applies. If you'd like to have a player served from one domain, but the text track served from another, you'll need to enable CORS in order to do so.

Track Attributes

Additional settings for track tags.

kind

One of the five track types listed above. Kind defaults to subtitles if no kind is included.

label

The label for the track that will be show to the user, for example in a menu that list the different languages available for subtitles.

default

The default attribute can be used to have a track default to showing. Otherwise the viewer would need to select their language from the captions or subtitles menu. NOTE: For chapters, default is required if you want the chapters menu to show.

srclang

The two-letter code (valid BCP 47 language tag) for the language of the text track, for example "en" for English. Here's a list of available language codes.

abAbkhazian
aaAfar
afAfrikaans
sqAlbanian
amAmharic
arArabic
anAragonese
hyArmenian
asAssamese
ayAymara
azAzerbaijani
baBashkir
euBasque
bnBengali (Bangla)
dzBhutani
bhBihari
biBislama
brBreton
bgBulgarian
myBurmese
beByelorussian (Belarusian)
kmCambodian
caCatalan
zhChinese (Simplified)
zhChinese (Traditional)
coCorsican
hrCroatian
csCzech
daDanish
nlDutch
enEnglish
eoEsperanto
etEstonian
foFaeroese
faFarsi
fjFiji
fiFinnish
frFrench
fyFrisian
glGalician
gdGaelic (Scottish)
gvGaelic (Manx)
kaGeorgian
deGerman
elGreek
klGreenlandic
gnGuarani
guGujarati
htHaitian Creole
haHausa
heHebrew
hiHindi
huHungarian
isIcelandic
ioIdo
idIndonesian
iaInterlingua
ieInterlingue
iuInuktitut
ikInupiak
gaIrish
itItalian
jaJapanese
jvJavanese
knKannada
ksKashmiri
kkKazakh
rwKinyarwanda (Ruanda)
kyKirghiz
rnKirundi (Rundi)
koKorean
kuKurdish
loLaothian
laLatin
lvLatvian (Lettish)
liLimburgish ( Limburger)
lnLingala
ltLithuanian
mkMacedonian
mgMalagasy
msMalay
mlMalayalam
mtMaltese
miMaori
mrMarathi
moMoldavian
mnMongolian
naNauru
neNepali
noNorwegian
ocOccitan
orOriya
omOromo (Afan, Galla)
psPashto (Pushto)
plPolish
ptPortuguese
paPunjabi
quQuechua
rmRhaeto-Romance
roRomanian
ruRussian
smSamoan
sgSangro
saSanskrit
srSerbian
shSerbo-Croatian
stSesotho
tnSetswana
snShona
iiSichuan Yi
sdSindhi
siSinhalese
ssSiswati
skSlovak
slSlovenian
soSomali
esSpanish
suSundanese
swSwahili (Kiswahili)
svSwedish
tlTagalog
tgTajik
taTamil
ttTatar
teTelugu
thThai
boTibetan
tiTigrinya
toTonga
tsTsonga
trTurkish
tkTurkmen
twTwi
ugUighur
ukUkrainian
urUrdu
uzUzbek
viVietnamese
voVolap√ľk
waWallon
cyWelsh
woWolof
xhXhosa
yiYiddish
yoYoruba
zuZulu