Skip to content

hls.js patch down to its export list: the HLS save reads samples from the moof; the subtitle guard and unread text tracks go - #612

Merged
Nawid3333 merged 1 commit into
mainfrom
fix/hls-patch-exports-only
Oct 29, 2026
Merged

Nawid3333 merged 1 commit into
mainfrom
fix/hls-patch-exports-only

Conversation

@Nawid3333

Copy link
Copy Markdown
Owner

FastStream's hls.js patch goes from 3 changes (4 hunks, 40 lines) to 1 (the export list, 11 lines). Nothing the user sees changes.

  • outputSamples dropped. The HLS save needs each sample's size, duration, composition offset and flags. hls.js already returns them inside the fragment's moof (data1): its trun is written from exactly that list. samplesFromMoof in hls2mp4.mjs reads them back. Proof before removing the hunks: all 3,383 samples of the 38 save tests (H.264, HEVC, AAC, MP3, AC-3, discontinuities, holes, a damaged packet) came out identical both ways, and a flag read from the wrong bit failed that comparison. There are two new unit tests, one with a negative video offset (it fails when the offset is read unsigned). The moof is always present: hls.js leaves it out only for bare MPEG audio, and FastStream's transmuxer asks for MP3 in MP4.
  • The #7460 subtitle guard dropped. It was upstream's own stopgap (Disable part loading for subtitle playlists video-dev/hls.js#7463), which upstream withdrew in #7626 (in 1.7.0) once subtitle parts load properly. It never ran in FastStream: it sits inside the low-latency branch, and FastStream sets lowLatencyMode: false.
  • hls.js's unread text tracks off. FastStream turns hls.js subtitles off and never reads video.textTracks. Even so, hls.js decoded CEA-608 captions into hidden tracks and made cues of ID3, emsg and DATERANGE metadata for every fragment. enableWebVTT, enableIMSC1, enableCEA708Captions and the three metadata-cue switches are now off.

The remaining export list goes upstream as its own PR, after which the patch can go entirely.

Verified locally: lint, typecheck, 3378 unit tests, vendor sync. The HLS playback and save e2e specs run in CI.

🤖 Generated with Claude Code

…from the moof; the subtitle guard and hls.js's unread text tracks go

The patch made three changes; two go, the export list stays.

outputSamples (2 hunks): the HLS save writes a plain MP4 and needs each
sample's size, duration, composition offset and flags, so the patch added
MP4Remuxer's sample list to its result. The same values are in the result
already: the fragment's moof (data1), whose trun MP4Remuxer writes from that
list. hls2mp4's samplesFromMoof reads them back. Before the hunks went, all
3,383 samples of the 38 saves in hls2mp4.test.mjs and
saveDownloadsAhead.test.mjs (H.264, HEVC, AAC, MP3, AC-3, discontinuities,
holes, a damaged packet) came out identical both ways, compared in pushChunk;
a flag read from the wrong bit failed that comparison. The moof is always
there: hls.js leaves it empty only for bare MPEG audio, and the transmuxer
asks for MP3 in MP4 (typeSupported.mpeg false). Two unit tests: a hand-built
moof with a negative video offset (fails when the offset is read unsigned),
and the refusals.

The #7460 subtitle part guard (1 hunk) was not FastStream's: it is
video-dev/hls.js#7463 (2025-08), which upstream withdrew in #7626 (2026-01, in
1.7.0) when SubtitleStreamController learnt to load VTT parts. It never ran
here: it sits in shouldLoadParts's config.lowLatencyMode branch, and
HLSPlayer sets lowLatencyMode false.

HLSPlayer: enableWebVTT, enableIMSC1, enableCEA708Captions and the three
metadata-cue switches off. FastStream turns hls.js's subtitles off
(subtitleTrack -1) and reads no video.textTracks; hls.js still decoded
CEA-608 captions into hidden tracks (createNativeTrack, 'hidden') and made
cues of ID3, emsg and EXT-X-DATERANGE metadata for every fragment. Nothing
the user sees changes.

The patch is 1 hunk, 11 lines (4 hunks, 40 lines before).

Verified locally: lint, typecheck, 3378 unit tests, vendor sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Nawid3333
Nawid3333 merged commit 16c2135 into main Oct 29, 2026
23 checks passed
@Nawid3333
Nawid3333 deleted the fix/hls-patch-exports-only branch October 29, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant