Skip to content

Commit c90b3bc

Browse files
Esskclaude
andcommitted
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 <noreply@anthropic.com>
1 parent a9f9d7a commit c90b3bc

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

src/transmuxer-worker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ class MessageHandlers {
191191
pushMp4Captions(data) {
192192
if (!this.captionParser) {
193193
this.captionParser = new CaptionParser();
194-
this.captionParser.init();
194+
this.captionParser.init({
195+
parse708captions: this.options.parse708captions,
196+
captionServices: this.options.captionServices
197+
});
195198
}
196199
const segment = new Uint8Array(data.data, data.byteOffset, data.byteLength);
197200
const parsed = this.captionParser.parse(

test/transmuxer-worker.test.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import {
1010
// needed for plugin registration
1111
import '../src/videojs-http-streaming';
1212

13-
const createTransmuxer = () => {
14-
return createTransmuxer_({
13+
const createTransmuxer = (options) => {
14+
return createTransmuxer_(Object.assign({
1515
remux: false,
1616
keepOriginalTimestamps: true
17-
});
17+
}, options));
1818
};
1919

2020
// The final done message from the Transmux worker
@@ -354,6 +354,39 @@ QUnit.test('can parse mp4 captions', function(assert) {
354354
});
355355
});
356356

357+
QUnit.test('parses mp4 captions when initialized with caption parsing options', function(assert) {
358+
const done = assert.async();
359+
const data = mp4CaptionsSegment();
360+
361+
this.transmuxer = createTransmuxer({
362+
parse708captions: false,
363+
captionServices: {SERVICE1: {language: 'en'}}
364+
});
365+
this.transmuxer.onmessage = (e) => {
366+
const message = e.data;
367+
368+
assert.equal(message.action, 'mp4Captions', 'returned mp4Captions event');
369+
assert.equal(message.captions.length, 2, 'two 608 captions');
370+
assert.deepEqual(
371+
message.captions.map((caption) => caption.stream),
372+
['CC1', 'CC1'],
373+
'only 608 caption streams are present'
374+
);
375+
assert.deepEqual(message.logs.length, 0, 'no logs returned');
376+
377+
done();
378+
};
379+
380+
this.transmuxer.postMessage({
381+
action: 'pushMp4Captions',
382+
data,
383+
timescales: 30000,
384+
trackIds: [1],
385+
byteLength: data.byteLength,
386+
byteOffset: 0
387+
});
388+
});
389+
357390
QUnit.test('returns empty array without mp4 captions', function(assert) {
358391
const done = assert.async();
359392
const data = muxedSegment();

0 commit comments

Comments
 (0)