videojs / videojs-contrib-dash

Video.js plugin for supporting the MPEG-DASH playback through a video.js player

Home Page:https://videojs.github.io/videojs-contrib-dash/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No captions show when using contrib-dash

sevagsim opened this issue · comments

Description

The reference player here does not show captions (at the 15 second mark, for example) for the following DASH file (https://dash.akamaized.net/akamai/test/caption_test/ElephantsDream/elephants_dream_480p_heaac5_1.mpd)

The issue does not exist on the DASH.js reference player.

Repro steps

  1. Play the video on each reference player and enable the text track and then visit the part of the video with captions (e.g. 15 second mark)

Results

Expected

To show captions at 15 second mark.

Actual

No captions show

versions

videojs

Newest version of videojs, and newest version of videojs-contrib-dash

browsers

I only tried on Chrome

OSes

I only tried on Mac

I found what the problem is, and, unfortunately, it's a problem with the way dash.js handles captions. As you can see here, captions in single WebVTT files are added to the current text track. Since in videojs-contrib-dash, we by default have no text track selected, the caption data is read on stream start and sucked into a bottomless black void. Compare that to dash.js, where the first text track is selected by default. This is why it works in the dash.js player but not in videojs-contrib-dash.

Just as a test, I tried doing

  mediaPlayer.on(dashjs.MediaPlayer.events.MANIFEST_LOADED, (event) => {
    mediaPlayer.setTextTrack(0);
  });

and the captions displayed. Of course, this doesn't cause the UI to update.

If possible, you may want to consider switching to fragmented VTT, which requires encapsulating them in MP4s. It suffers from the same problem of dumping captions to the active text track, but at least it will update on every fragment. (Note: I don't know if multiple languages would muck that up)

By far the best solution is to have dash.js change their architecture to support adding captions to non-active text tracks, though I don't know how realistic that is.

Compare that to dash.js, where the first text track is selected by default

@squarebracket Thanks for looking into this. On the DashJS reference player, if you click on the button "Show Options" there is a checkbox with a label: "Enable Text At Loading" -- if you uncheck that, the caption is not loaded by default. It will only load when you select the track from the list of tracks on the player UI (you can see the network request being sent only when you select the english text track when that option is unchecked).

Huh. And it does the same thing we do (namely setting the text track index to be -1). Interesting.

Try adding setTextDefaultEnabled: false to your player setup options as per https://github.com/videojs/videojs-contrib-dash#passing-options-to-dashjs and see if that works? If it does then maybe we should set that by default -- perhaps there's some weird logic in dash.js that's mucking things up in terms of timing.

Setting setTextDefaultEnabled: false seems to work. Should this be documented somewhere? Or be set as the default?

It should be set to false by default.