Is it possible for HTML5 video to play subtitles embedded in mp4 file as a track?

9.1k views Asked by At

I imported Webvtt file into mp4 file as a track, following the instruction Subtitling with GPAC

,and I checked that subtitles are properly shown when I using GPAC's Osmo4 player.

Now, I'd like to play this video with subtitle through HTML5 video tag, but it seems that HTML media track element is requiring src attribute that designate location of the webvtt file.

Is there any way to play embedded subtitle?

2

There are 2 answers

2
cconcolato On BEST ANSWER

It is now possible with MP4Box.js to extract on-the-fly the subtitles from the MP4 and to play them in the browser. You should check this demo in particular the Audio/Video/WebVTT example.

1
Jaruba On

No, HTML5 Video Tag does not currently support internal subtitle and audio tracks.

The correct way of inserting subtitles in HTML5 Video Tag is:

<video width="640" height="480" controls>
  <source src="video.mp4" type="video/mp4" />
  <source src="video.webm" type="video/webm" />
  <track src="subtitles.vtt" kind="subtitles" srclang="en" label="English" />
</video>

Additional Information on HTML5 Video Subtitling and WebVTT