From c90b3bc7e1795fcf1e881a2b514b2bcfd767b18c Mon Sep 17 00:00:00 2001 From: Sarah Rimron-Soutter Date: Wed, 12 Aug 2026 10:43:14 +0100 Subject: [PATCH] fix: forward parse708captions and captionServices to the mp4 caption parser Both options reached the transmuxer worker's init config but were dropped at the fMP4 CaptionParser call site, which was constructed with no options. As a result parse708captions and captionServices only ever applied to MPEG-TS streams, never to fMP4/CMAF. Co-Authored-By: Claude Fable 5 --- src/transmuxer-worker.js | 5 ++++- test/transmuxer-worker.test.js | 39 +++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/transmuxer-worker.js b/src/transmuxer-worker.js index 815f1d118..0d78cb0b7 100644 --- a/src/transmuxer-worker.js +++ b/src/transmuxer-worker.js @@ -191,7 +191,10 @@ class MessageHandlers { pushMp4Captions(data) { if (!this.captionParser) { this.captionParser = new CaptionParser(); - this.captionParser.init(); + this.captionParser.init({ + parse708captions: this.options.parse708captions, + captionServices: this.options.captionServices + }); } const segment = new Uint8Array(data.data, data.byteOffset, data.byteLength); const parsed = this.captionParser.parse( diff --git a/test/transmuxer-worker.test.js b/test/transmuxer-worker.test.js index 1f29881f3..79e3c8027 100644 --- a/test/transmuxer-worker.test.js +++ b/test/transmuxer-worker.test.js @@ -10,11 +10,11 @@ import { // needed for plugin registration import '../src/videojs-http-streaming'; -const createTransmuxer = () => { - return createTransmuxer_({ +const createTransmuxer = (options) => { + return createTransmuxer_(Object.assign({ remux: false, keepOriginalTimestamps: true - }); + }, options)); }; // The final done message from the Transmux worker @@ -354,6 +354,39 @@ QUnit.test('can parse mp4 captions', function(assert) { }); }); +QUnit.test('parses mp4 captions when initialized with caption parsing options', function(assert) { + const done = assert.async(); + const data = mp4CaptionsSegment(); + + this.transmuxer = createTransmuxer({ + parse708captions: false, + captionServices: {SERVICE1: {language: 'en'}} + }); + this.transmuxer.onmessage = (e) => { + const message = e.data; + + assert.equal(message.action, 'mp4Captions', 'returned mp4Captions event'); + assert.equal(message.captions.length, 2, 'two 608 captions'); + assert.deepEqual( + message.captions.map((caption) => caption.stream), + ['CC1', 'CC1'], + 'only 608 caption streams are present' + ); + assert.deepEqual(message.logs.length, 0, 'no logs returned'); + + done(); + }; + + this.transmuxer.postMessage({ + action: 'pushMp4Captions', + data, + timescales: 30000, + trackIds: [1], + byteLength: data.byteLength, + byteOffset: 0 + }); +}); + QUnit.test('returns empty array without mp4 captions', function(assert) { const done = assert.async(); const data = muxedSegment();