1

As you might know, most common video container files are like zip archives that contain several other files: the actual video, several audio files for different languages and several text files for subtitles and captions. If these tracks are included in the video file, that's called packaged afaik.

Now, while HTML offers the <track> element to reference additional files, are browsers capable of choosing among different packaged tracks and display different subtitles?

How is browser support?

Andy
  • 4,783
  • 2
  • 26
  • 51
  • 1
    No. You'd have to extract the text (subs) from the video file's bytes and then dynamically create a String of text in webVTT formatting with your subs' text / timestamps. The string can then be loaded in `` as a blob and will then show when the video plays. Depending on the video format... If the subs are in a header at front of file then you can simply load only enough bytes to read the header. You load the video file (_ie:_ header bytes) into a buffer (array) then scan the array (For-loop) for the part that represents the embedded text. – VC.One May 28 '21 at 07:20
  • PS: This other [Answer](https://stackoverflow.com/a/65625118/2057709) shows how to create dynamic webVTT subs from some text. So you'd extract your text from video bytes and then add it and its timestamps to a variable like their example `captions_array`... – VC.One May 28 '21 at 07:39
  • Would you happen to know the reasons? The player can already offer several subtitles that are defined in `` elements, why wouldn't it do so with packaged subtitles? – Andy May 28 '21 at 16:51
  • @VC.One would you mind providing your answer as an answer? – Andy May 28 '21 at 16:52

1 Answers1

1

No, currently they can't, even though the HTML standard encourages browser vendors to implement such controls.

The standard allows several audio and video tracks per media resource, and exposes them via JavaScript:

A media resource can have multiple embedded audio and video tracks. For example, in addition to the primary video and audio tracks, a media resource could have foreign-language dubbed dialogues, director's commentaries, audio descriptions, alternative angles, or sign-language overlays.

4.8.12.10 Media resources with multiple media tracks

Additionally, the standard encourages controls for different audio tracks and captions.

If the [control] attribute is present, […] the user agent should expose a user interface to the user. This user interface should include features to […] change the display of closed captions or embedded sign-language tracks, select different audio tracks or turn on audio descriptions […]

4.8.12.13 User interface

According to can i use audioTracks, some vendors either already support this or are working on support.

Andy
  • 4,783
  • 2
  • 26
  • 51