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.66k stars 2.56k forks source link

How do we enable subtitles baked in the .ts file? #6647

Open KoningWouter opened 2 weeks ago

KoningWouter commented 2 weeks ago

What do you want to do with Hls.js?

We have a stream that has subtitles baked into the .ts file. So it doesn't have a subtitle track in the .m3u8 file.

Since there is a SubtitleStreamController we would think that subtitle tracks that are baked into the ts file (not in the m3u8 file) are supported. But we can't get it to work.

What have you tried so far?

In VLC we are able to select the subtitle track and get it to display.

We tried logging events:

hlsRef.current.on(Hls.Events.SUBTITLE_FRAG_PROCESSED, (event, data) => { console.log('subtitle frag processed'); }); hlsRef.current.on(Hls.Events.SUBTITLE_TRACK_LOADED, (event, data) => { console.log('subtitle track loaded'); }); hlsRef.current.on(Hls.Events.SUBTITLE_TRACK_LOADING, (event, data) => { console.log('subtitle track loading'); }); hlsRef.current.on(Hls.Events.SUBTITLE_TRACK_SWITCH, (event, data) => { console.log('subtitle track switched'); console.log(data); console.log(hlsRef.current.subtitleTracks.length); }); hlsRef.current.on(Hls.Events.SUBTITLE_TRACK_CLEARED, (event, data) => { console.log('subtitle track cleared'); }); hlsRef.current.on(Hls.Events.SUBTITLE_TRACK_UPDATED, (event, data) => { console.log('subtitle track updated'); }); hlsRef.current.on(Hls.Events.CUES_PARSED, (event, data) => { console.log('cues parsed'); }); hlsRef.current.on(Hls.Events.NON_NATIVE_TEXT_TRACKS_FOUND, (event, data) => { console.log('Non native text tracks found'); }, );

But none of these events fire.

Are subtitle tracks baked into the ts file supported by Hls.js and if not could anybody give us some clues on how to implement it?

robwalch commented 2 weeks ago

SubtitleStreamController is responsible for loading WebVTT and IMSC1 subtitle segments only with the SubtitleTrackController responsible for selection of the media option playlists containing those segments.

608 captions (and all captions and subtitle cues) are handled by the TimelineController. 608 Captions are parsed on FRAG_PARSING_USERDATA and output to a "captions" TextTrack or via CUES_PARSED events depending on the renderTextTracksNatively option which defaults to true (output to TextTrack).