video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
https://hlsjs.video-dev.org/demo
Other
14.69k stars 2.56k forks source link

Why does CUES_PARSED not trigger when renderTextTracksNatively = false #5607

Closed rosspi closed 1 year ago

rosspi commented 1 year ago

My understanding is that if I set renderTextTracksNatively to false in the config:

var hls = new Hls({ 
  renderTextTracksNatively: false  
});

then a NON_NATIVE_TEXT_TRACKS_FOUND and CUES_PARSED event should be raised (and presumably the latter one multiple times as the video progresses), but the CUES_PARSED event is never triggered. Why is this?

hls.on(Hls.Events.NON_NATIVE_TEXT_TRACKS_FOUND, (event, data) => {
    // Yes this worked.
}); 

hls.on(Hls.Events.CUES_PARSED, (event, data) => {
    // This never happens...
});

I want to intercept the captions and draw them using a custom html approach.

robwalch commented 1 year ago

Hi @rosspi,

the CUES_PARSED event is never triggered. Why is this?

CUES_PARSED is triggered for VTT and IMSC1 subtitle tracks only when enabled, and always for 608 captions found in the media playlist.

  1. Does your HLS stream have playlists with segments that contain subtitles (hls.subtitleTracks.length > 0) or 608 captions?
  2. If subtitles, then are any of them enabled (hls.subtitleTrack !== -1)?

Cues for 608 captions are always emitted because they are found in the video segments, and the player will not go back and reload video just because the application has enabled the display of captions. Subtitle segments are only loaded and parsed when enabled which is a prerequisite for this event to emit.

rosspi commented 1 year ago

Thanks rob.