htmlcaptionwebvttclosed-captions

WebVTT captions not showing


I'm adding captions to a video I recorded, however none of the captions that I created in my captions.vtt file aren't showing. What is wrong with my code?

websites.html
<video width="320" height="480" controls>
        <source src="IMG_1771.mp4" type="video/mp4">
            <track kind="captions" label="Video Captions" src="captions.vtt"  />
    </video>


captions.vtt
WEBVTT

Title
00:00.000 --> 00:00.300 
Good Morning

Subtitle
00:00.500 --> 00:02.000 
My name is John Doe

Subtitle 2
00:02.500 --> 00:04.000  
And today I will be giving reasons why video enhances websites

Solution

  • To play a subtitle on its own you should always define default attribute within the track tag to indicate which track is enabled Since you got only one track here you should indicate it as an active one.

    Also, As MDN mentioned in the attribute section of track tag, whenever you add kind attribute to track tag you should indicate srclang too and it is necessary.

    So the output should be something like this:

    <video width="320" height="480" controls>
        <source src="IMG_1771.mp4" type="video/mp4">
        <track default kind="captions" label="Video Captions" srclang="en" src="captions.vtt"/>
    </video>