libbitsub 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/hlsjs.d.ts +6 -0
- package/dist/integrations/hlsjs.d.ts.map +1 -1
- package/dist/integrations/hlsjs.js +3 -0
- package/dist/integrations/hlsjs.js.map +1 -1
- package/dist/integrations/index.d.ts +10 -2
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +10 -2
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/react.d.ts +10 -1
- package/dist/integrations/react.d.ts.map +1 -1
- package/dist/integrations/react.js +4 -1
- package/dist/integrations/react.js.map +1 -1
- package/dist/integrations/shaka.d.ts +6 -0
- package/dist/integrations/shaka.d.ts.map +1 -1
- package/dist/integrations/shaka.js +3 -0
- package/dist/integrations/shaka.js.map +1 -1
- package/dist/integrations/shared.d.ts +2 -0
- package/dist/integrations/shared.d.ts.map +1 -1
- package/dist/integrations/shared.js.map +1 -1
- package/dist/integrations/videojs.d.ts +9 -0
- package/dist/integrations/videojs.d.ts.map +1 -1
- package/dist/integrations/videojs.js +3 -0
- package/dist/integrations/videojs.js.map +1 -1
- package/dist/ts/capabilities.d.ts +6 -0
- package/dist/ts/capabilities.d.ts.map +1 -1
- package/dist/ts/capabilities.js +6 -0
- package/dist/ts/capabilities.js.map +1 -1
- package/dist/ts/diagnostics.d.ts +6 -0
- package/dist/ts/diagnostics.d.ts.map +1 -1
- package/dist/ts/diagnostics.js +6 -0
- package/dist/ts/diagnostics.js.map +1 -1
- package/dist/ts/frame-export.d.ts +4 -0
- package/dist/ts/frame-export.d.ts.map +1 -1
- package/dist/ts/frame-export.js +14 -0
- package/dist/ts/frame-export.js.map +1 -1
- package/dist/ts/parsers.d.ts.map +1 -1
- package/dist/ts/parsers.js +8 -4
- package/dist/ts/parsers.js.map +1 -1
- package/dist/ts/range-loader.d.ts +8 -0
- package/dist/ts/range-loader.d.ts.map +1 -1
- package/dist/ts/range-loader.js +102 -21
- package/dist/ts/range-loader.js.map +1 -1
- package/dist/ts/renderers.d.ts +27 -4
- package/dist/ts/renderers.d.ts.map +1 -1
- package/dist/ts/renderers.js +225 -126
- package/dist/ts/renderers.js.map +1 -1
- package/dist/ts/types.d.ts +45 -0
- package/dist/ts/types.d.ts.map +1 -1
- package/dist/ts/utils.d.ts +16 -0
- package/dist/ts/utils.d.ts.map +1 -1
- package/dist/ts/utils.js +70 -15
- package/dist/ts/utils.js.map +1 -1
- package/dist/ts/video-frame-scheduler.d.ts +18 -1
- package/dist/ts/video-frame-scheduler.d.ts.map +1 -1
- package/dist/ts/video-frame-scheduler.js +83 -4
- package/dist/ts/video-frame-scheduler.js.map +1 -1
- package/dist/ts/worker.d.ts.map +1 -1
- package/dist/ts/worker.js +15 -6
- package/dist/ts/worker.js.map +1 -1
- package/package.json +6 -1
- package/pkg/README.md +6 -4
- package/pkg/libbitsub.d.ts +15 -0
- package/pkg/libbitsub.js +27 -0
- package/pkg/libbitsub_bg.wasm +0 -0
- package/pkg/libbitsub_bg.wasm.d.ts +3 -0
- package/pkg/package.json +1 -1
- package/src/integrations/hlsjs.ts +6 -0
- package/src/integrations/index.ts +10 -2
- package/src/integrations/react.tsx +10 -1
- package/src/integrations/shaka.ts +6 -0
- package/src/integrations/shared.ts +2 -0
- package/src/integrations/videojs.ts +9 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
const defaultWatchdogTimer = {
|
|
2
|
+
now: () => performance.now(),
|
|
3
|
+
request: (callback, delay) => setTimeout(callback, delay),
|
|
4
|
+
cancel: (handle) => clearTimeout(handle)
|
|
5
|
+
};
|
|
6
|
+
const watchdogInterval = 250;
|
|
7
|
+
const watchdogGrace = 1000;
|
|
1
8
|
const defaultAnimationFrameScheduler = {
|
|
2
9
|
request: (callback) => requestAnimationFrame(callback),
|
|
3
10
|
cancel: (handle) => cancelAnimationFrame(handle)
|
|
@@ -13,14 +20,21 @@ export class VideoFrameScheduler {
|
|
|
13
20
|
video;
|
|
14
21
|
onFrame;
|
|
15
22
|
animationFrames;
|
|
23
|
+
watchdogTimer;
|
|
16
24
|
animationFrameHandle = null;
|
|
17
25
|
videoFrameHandle = null;
|
|
26
|
+
watchdogHandle = null;
|
|
27
|
+
lastWatchdogTime = 0;
|
|
28
|
+
lastProgressTime = 0;
|
|
29
|
+
lastVideoTime = 0;
|
|
30
|
+
progressingSince = null;
|
|
18
31
|
generation = 0;
|
|
19
32
|
useVideoFrames;
|
|
20
|
-
constructor(video, frameAware, onFrame, animationFrames = defaultAnimationFrameScheduler) {
|
|
33
|
+
constructor(video, frameAware, onFrame, animationFrames = defaultAnimationFrameScheduler, watchdogTimer = defaultWatchdogTimer) {
|
|
21
34
|
this.video = video;
|
|
22
35
|
this.onFrame = onFrame;
|
|
23
36
|
this.animationFrames = animationFrames;
|
|
37
|
+
this.watchdogTimer = watchdogTimer;
|
|
24
38
|
this.useVideoFrames = supportsFrameAwareSync(video, frameAware);
|
|
25
39
|
}
|
|
26
40
|
get mode() {
|
|
@@ -28,11 +42,21 @@ export class VideoFrameScheduler {
|
|
|
28
42
|
}
|
|
29
43
|
start() {
|
|
30
44
|
this.stop();
|
|
45
|
+
// Fallback is deliberate and permanent for this scheduler's lifetime,
|
|
46
|
+
// including restarts. Re-probing a stalled native-HLS callback source
|
|
47
|
+
// would repeatedly freeze subtitles for the watchdog grace period.
|
|
31
48
|
const generation = this.generation;
|
|
49
|
+
this.resetWatchdogEvidence();
|
|
32
50
|
this.schedule(generation);
|
|
51
|
+
if (this.useVideoFrames)
|
|
52
|
+
this.scheduleWatchdog(generation);
|
|
33
53
|
}
|
|
34
54
|
stop() {
|
|
35
55
|
this.generation++;
|
|
56
|
+
if (this.watchdogHandle !== null) {
|
|
57
|
+
this.watchdogTimer.cancel(this.watchdogHandle);
|
|
58
|
+
this.watchdogHandle = null;
|
|
59
|
+
}
|
|
36
60
|
if (this.videoFrameHandle !== null) {
|
|
37
61
|
const cancelVideoFrameCallback = this.video.cancelVideoFrameCallback;
|
|
38
62
|
if (typeof cancelVideoFrameCallback === 'function') {
|
|
@@ -50,6 +74,56 @@ export class VideoFrameScheduler {
|
|
|
50
74
|
this.animationFrameHandle = null;
|
|
51
75
|
}
|
|
52
76
|
}
|
|
77
|
+
resetWatchdogEvidence() {
|
|
78
|
+
this.lastWatchdogTime = this.watchdogTimer.now();
|
|
79
|
+
this.lastProgressTime = this.lastWatchdogTime;
|
|
80
|
+
this.lastVideoTime = this.video.currentTime;
|
|
81
|
+
this.progressingSince = null;
|
|
82
|
+
}
|
|
83
|
+
scheduleWatchdog(generation) {
|
|
84
|
+
this.watchdogHandle = this.watchdogTimer.request(() => {
|
|
85
|
+
if (generation !== this.generation || !this.useVideoFrames)
|
|
86
|
+
return;
|
|
87
|
+
this.watchdogHandle = null;
|
|
88
|
+
const now = this.watchdogTimer.now();
|
|
89
|
+
const currentTime = this.video.currentTime;
|
|
90
|
+
const elapsed = now - this.lastWatchdogTime;
|
|
91
|
+
const playing = !this.video.paused &&
|
|
92
|
+
!this.video.seeking &&
|
|
93
|
+
!this.video.ended &&
|
|
94
|
+
(this.video.readyState === undefined || this.video.readyState >= 3);
|
|
95
|
+
if (!playing ||
|
|
96
|
+
!Number.isFinite(elapsed) ||
|
|
97
|
+
elapsed < 0 ||
|
|
98
|
+
elapsed > watchdogInterval * 3 ||
|
|
99
|
+
!Number.isFinite(currentTime) ||
|
|
100
|
+
!Number.isFinite(this.lastVideoTime) ||
|
|
101
|
+
currentTime < this.lastVideoTime) {
|
|
102
|
+
this.progressingSince = null;
|
|
103
|
+
this.lastProgressTime = now;
|
|
104
|
+
}
|
|
105
|
+
else if (currentTime > this.lastVideoTime) {
|
|
106
|
+
this.lastProgressTime = now;
|
|
107
|
+
this.progressingSince ??= this.lastWatchdogTime;
|
|
108
|
+
if (now - this.progressingSince >= watchdogGrace) {
|
|
109
|
+
// Invalidate the pending video callback before cancellation: some
|
|
110
|
+
// implementations can still deliver a cancelled callback.
|
|
111
|
+
this.useVideoFrames = false;
|
|
112
|
+
this.stop();
|
|
113
|
+
this.schedule(this.generation);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (now - this.lastProgressTime >= watchdogGrace) {
|
|
118
|
+
// Brief equal samples can come from a quantized media clock. Only
|
|
119
|
+
// sustained inactivity discards progress, and only advancement fails.
|
|
120
|
+
this.progressingSince = null;
|
|
121
|
+
}
|
|
122
|
+
this.lastWatchdogTime = now;
|
|
123
|
+
this.lastVideoTime = currentTime;
|
|
124
|
+
this.scheduleWatchdog(generation);
|
|
125
|
+
}, watchdogInterval);
|
|
126
|
+
}
|
|
53
127
|
schedule(generation) {
|
|
54
128
|
if (generation !== this.generation)
|
|
55
129
|
return;
|
|
@@ -58,9 +132,10 @@ export class VideoFrameScheduler {
|
|
|
58
132
|
if (typeof requestVideoFrameCallback === 'function') {
|
|
59
133
|
try {
|
|
60
134
|
this.videoFrameHandle = requestVideoFrameCallback.call(this.video, (_now, metadata) => {
|
|
61
|
-
this.
|
|
62
|
-
if (generation !== this.generation)
|
|
135
|
+
if (generation !== this.generation || !this.useVideoFrames)
|
|
63
136
|
return;
|
|
137
|
+
this.videoFrameHandle = null;
|
|
138
|
+
this.resetWatchdogEvidence();
|
|
64
139
|
const mediaTime = Number.isFinite(metadata.mediaTime) ? metadata.mediaTime : this.video.currentTime;
|
|
65
140
|
try {
|
|
66
141
|
this.onFrame({
|
|
@@ -82,10 +157,14 @@ export class VideoFrameScheduler {
|
|
|
82
157
|
this.useVideoFrames = false;
|
|
83
158
|
}
|
|
84
159
|
}
|
|
160
|
+
if (this.watchdogHandle !== null) {
|
|
161
|
+
this.watchdogTimer.cancel(this.watchdogHandle);
|
|
162
|
+
this.watchdogHandle = null;
|
|
163
|
+
}
|
|
85
164
|
this.animationFrameHandle = this.animationFrames.request(() => {
|
|
86
|
-
this.animationFrameHandle = null;
|
|
87
165
|
if (generation !== this.generation)
|
|
88
166
|
return;
|
|
167
|
+
this.animationFrameHandle = null;
|
|
89
168
|
try {
|
|
90
169
|
this.onFrame({ mediaTime: this.video.currentTime, presentedFrames: null });
|
|
91
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-frame-scheduler.js","sourceRoot":"","sources":["../../src/ts/video-frame-scheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"video-frame-scheduler.js","sourceRoot":"","sources":["../../src/ts/video-frame-scheduler.ts"],"names":[],"mappings":"AA4BA,MAAM,oBAAoB,GAAkB;IAC1C,GAAG,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;IAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC;IACzD,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;CACzC,CAAA;AAED,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAC5B,MAAM,aAAa,GAAG,IAAI,CAAA;AAE1B,MAAM,8BAA8B,GAA4B;IAC9D,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAC;IACtD,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;CACjD,CAAA;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAuB,EAAE,OAAO,GAAG,IAAI;IAC5E,OAAO,OAAO,IAAI,OAAO,KAAK,CAAC,yBAAyB,KAAK,UAAU,CAAA;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAYX,KAAK;IAEL,OAAO;IACP,eAAe;IACf,aAAa;IAfxB,oBAAoB,GAAkB,IAAI,CAAA;IAC1C,gBAAgB,GAA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,CAAC,CAAA;oBACF,OAAM;gBACR,CAAC;gBAAC,MAAM,CAAC;oBACP,IAAI,CAAC,cAAc,GAAG,KAAK,CAAA;gBAC7B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,cAAc,GAAG,KAAK,CAAA;YAC7B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YACjC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YAC9C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC5B,CAAC;QACD,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE;YAC5D,IAAI,UAAU,KAAK,IAAI,CAAC,UAAU;gBAAE,OAAM;YAC1C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAA;YAChC,IAAI,CAAC;gBACH,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA;YAC5E,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/ts/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/ts/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAiB5D,0CAA0C;AAC1C,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/ts/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAiB5D,0CAA0C;AAC1C,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAmtBD,kEAAkE;AAClE,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgBnD;AAED,iDAAiD;AACjD,wBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAEtC;AAED,uEAAuE;AACvE,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3C;AAuED,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,SAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAMtG;AAkDD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAc1C"}
|
package/dist/ts/worker.js
CHANGED
|
@@ -276,10 +276,12 @@ self.onmessage = async function(event) {
|
|
|
276
276
|
parser.reset();
|
|
277
277
|
pgsParsers.set(request.sessionId, parser);
|
|
278
278
|
}
|
|
279
|
+
// Send only timestamps added by this chunk (from timestampBase).
|
|
280
|
+
const timestampBase = parser.count;
|
|
279
281
|
const added = parser.feed(new Uint8Array(request.data));
|
|
280
|
-
const timestamps = parser.
|
|
282
|
+
const timestamps = parser.getTimestampsFrom(timestampBase);
|
|
281
283
|
postResponse(
|
|
282
|
-
{ type: 'pgsProgress', count: parser.count, added, partial: true, metadata: buildPgsMetadata(parser), timestamps },
|
|
284
|
+
{ type: 'pgsProgress', count: parser.count, added, partial: true, metadata: buildPgsMetadata(parser), timestamps, timestampBase },
|
|
283
285
|
[timestamps.buffer],
|
|
284
286
|
_id
|
|
285
287
|
);
|
|
@@ -350,11 +352,15 @@ self.onmessage = async function(event) {
|
|
|
350
352
|
parser.reset();
|
|
351
353
|
dvbParsers.set(request.sessionId, parser);
|
|
352
354
|
}
|
|
355
|
+
// Send only changed entries: new cues plus the previous last cue,
|
|
356
|
+
// whose end time a new cue can shorten.
|
|
357
|
+
const previousCount = parser.count;
|
|
353
358
|
const added = parser.feed(new Uint8Array(request.data));
|
|
354
|
-
const
|
|
355
|
-
const
|
|
359
|
+
const timestampBase = added > 0 ? Math.max(0, previousCount - 1) : parser.count;
|
|
360
|
+
const timestamps = parser.getTimestampsFrom(timestampBase);
|
|
361
|
+
const endTimestamps = parser.getEndTimestampsFrom(timestampBase);
|
|
356
362
|
postResponse(
|
|
357
|
-
{ type: 'dvbProgress', count: parser.count, added, partial: true, metadata: buildDvbMetadata(parser), timestamps, endTimestamps },
|
|
363
|
+
{ type: 'dvbProgress', count: parser.count, added, partial: true, metadata: buildDvbMetadata(parser), timestamps, endTimestamps, timestampBase },
|
|
358
364
|
[timestamps.buffer, endTimestamps.buffer],
|
|
359
365
|
_id
|
|
360
366
|
);
|
|
@@ -533,7 +539,10 @@ self.onmessage = async function(event) {
|
|
|
533
539
|
}
|
|
534
540
|
case 'getVobSubTimestamps': {
|
|
535
541
|
const parser = vobSubParsers.get(request.sessionId);
|
|
536
|
-
|
|
542
|
+
const timestamps = parser ? parser.getTimestamps() : new Float64Array(0);
|
|
543
|
+
const endTimestamps = new Float64Array(timestamps.length);
|
|
544
|
+
for (let i = 0; i < timestamps.length; i++) endTimestamps[i] = parser.getCueEndTime(i);
|
|
545
|
+
postResponse({ type: 'vobSubTimestamps', timestamps, endTimestamps }, [], _id);
|
|
537
546
|
break;
|
|
538
547
|
}
|
|
539
548
|
case 'clearPgsCache': {
|
package/dist/ts/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/ts/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnD,IAAI,YAAY,GAAkB,IAAI,CAAA;AACtC,IAAI,iBAAiB,GAA2B,IAAI,CAAA;AACpD,IAAI,SAAS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,CAAC,CAAA;IACxB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,YAAY,EAAE,CAAC;QACjB,IAAI,CAAC;YACH,YAAY,CAAC,SAAS,EAAE,CAAA;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;IACD,YAAY,GAAG,IAAI,CAAA;IACnB,iBAAiB,GAAG,IAAI,CAAA;IACxB,KAAK,MAAM,CAAC,EAAE,QAAQ,CAAC,IAAI,gBAAgB,EAAE,CAAC;QAC5C,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,gBAAgB,CAAC,KAAK,EAAE,CAAA;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libbitsub",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"author": "altqx",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "High-performance WASM renderer for graphical subtitles (PGS, VobSub, and DVB)",
|
|
@@ -78,6 +78,9 @@
|
|
|
78
78
|
"build:wasm:bundler": "wasm-pack build --target bundler --out-dir pkg-bundler",
|
|
79
79
|
"build:ts": "tsc",
|
|
80
80
|
"build": "bun run build:wasm:release && bun run build:ts",
|
|
81
|
+
"demo:build": "bun demo/build.ts",
|
|
82
|
+
"demo:dev": "bun run demo:build && wrangler dev --config demo/wrangler.jsonc",
|
|
83
|
+
"demo:deploy": "bun run demo:build && wrangler deploy --config demo/wrangler.jsonc",
|
|
81
84
|
"clean": "rm -rf pkg pkg-bundler dist target",
|
|
82
85
|
"test": "cargo test --workspace",
|
|
83
86
|
"test:ts": "bun test src/ts",
|
|
@@ -88,8 +91,10 @@
|
|
|
88
91
|
},
|
|
89
92
|
"devDependencies": {
|
|
90
93
|
"@types/react": "^19.2.17",
|
|
94
|
+
"dashjs": "5.2.1",
|
|
91
95
|
"prettier": "^3.9.6",
|
|
92
96
|
"react": "^19.2.8",
|
|
97
|
+
"libbitsub-registry": "npm:libbitsub@1.12.0",
|
|
93
98
|
"typescript": "^7.0.2"
|
|
94
99
|
},
|
|
95
100
|
"peerDependencies": {
|
package/pkg/README.md
CHANGED
|
@@ -34,7 +34,7 @@ https://gist.github.com/user-attachments/assets/a89ae9fe-23e4-4bc3-8cad-16a3f0fe
|
|
|
34
34
|
|
|
35
35
|
### Live demo
|
|
36
36
|
|
|
37
|
-
https://
|
|
37
|
+
https://libbitsub.altqx.com
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
@@ -293,9 +293,10 @@ selection does not transfer a caller-owned canvas to a worker; request
|
|
|
293
293
|
|
|
294
294
|
Frame-aware synchronization is enabled by default. On browsers with
|
|
295
295
|
`requestVideoFrameCallback()`, cue lookup uses the `mediaTime` of the frame sent
|
|
296
|
-
to the compositor instead of polling `video.currentTime`.
|
|
297
|
-
back to `requestAnimationFrame()` automatically
|
|
298
|
-
|
|
296
|
+
to the compositor instead of polling `video.currentTime`. The scheduler falls
|
|
297
|
+
back to `requestAnimationFrame()` automatically when frame callbacks are unavailable
|
|
298
|
+
or stop arriving during advancing playback; set `frameAwareSync: false` to force
|
|
299
|
+
that compatibility path. The active path is available as
|
|
299
300
|
`renderer.getSynchronizationMode()` and as `getStats().syncMode`.
|
|
300
301
|
|
|
301
302
|
### VobSub renderer
|
|
@@ -934,6 +935,7 @@ interface VideoSubtitleOptions {
|
|
|
934
935
|
}
|
|
935
936
|
streamingLoad?: boolean // default true — progressive URL loads
|
|
936
937
|
rangeRequests?: boolean // default true — use HTTP Range when supported
|
|
938
|
+
maxSubtitleBytes?: number // default 256 MiB — larger downloads are rejected
|
|
937
939
|
onEvent?: (event: SubtitleRendererEvent) => void
|
|
938
940
|
}
|
|
939
941
|
```
|
package/pkg/libbitsub.d.ts
CHANGED
|
@@ -16,7 +16,15 @@ export class DvbParser {
|
|
|
16
16
|
getCuePageState(index: number): number;
|
|
17
17
|
getCueStartTime(index: number): number;
|
|
18
18
|
getEndTimestamps(): Float64Array;
|
|
19
|
+
/**
|
|
20
|
+
* Get cue end times starting at cue `start`, for incremental updates.
|
|
21
|
+
*/
|
|
22
|
+
getEndTimestampsFrom(start: number): Float64Array;
|
|
19
23
|
getTimestamps(): Float64Array;
|
|
24
|
+
/**
|
|
25
|
+
* Get cue start times starting at cue `start`, for incremental updates.
|
|
26
|
+
*/
|
|
27
|
+
getTimestampsFrom(start: number): Float64Array;
|
|
20
28
|
constructor();
|
|
21
29
|
parse(data: Uint8Array): number;
|
|
22
30
|
renderAtIndex(index: number): SubtitleFrame | undefined;
|
|
@@ -44,6 +52,10 @@ export class PgsParser {
|
|
|
44
52
|
getCuePaletteId(index: number): number;
|
|
45
53
|
getCueStartTime(index: number): number;
|
|
46
54
|
getTimestamps(): Float64Array;
|
|
55
|
+
/**
|
|
56
|
+
* Get timestamps starting at cue `start`, for incremental updates.
|
|
57
|
+
*/
|
|
58
|
+
getTimestampsFrom(start: number): Float64Array;
|
|
47
59
|
constructor();
|
|
48
60
|
parse(data: Uint8Array): number;
|
|
49
61
|
renderAtIndex(index: number): SubtitleFrame | undefined;
|
|
@@ -217,7 +229,9 @@ export interface InitOutput {
|
|
|
217
229
|
readonly dvbparser_getCuePageState: (a: number, b: number) => number;
|
|
218
230
|
readonly dvbparser_getCueStartTime: (a: number, b: number) => number;
|
|
219
231
|
readonly dvbparser_getEndTimestamps: (a: number) => any;
|
|
232
|
+
readonly dvbparser_getEndTimestampsFrom: (a: number, b: number) => any;
|
|
220
233
|
readonly dvbparser_getTimestamps: (a: number) => any;
|
|
234
|
+
readonly dvbparser_getTimestampsFrom: (a: number, b: number) => any;
|
|
221
235
|
readonly dvbparser_lastRenderIssue: (a: number) => [number, number];
|
|
222
236
|
readonly dvbparser_new: () => number;
|
|
223
237
|
readonly dvbparser_parse: (a: number, b: number, c: number) => number;
|
|
@@ -238,6 +252,7 @@ export interface InitOutput {
|
|
|
238
252
|
readonly pgsparser_getCuePaletteId: (a: number, b: number) => number;
|
|
239
253
|
readonly pgsparser_getCueStartTime: (a: number, b: number) => number;
|
|
240
254
|
readonly pgsparser_getTimestamps: (a: number) => any;
|
|
255
|
+
readonly pgsparser_getTimestampsFrom: (a: number, b: number) => any;
|
|
241
256
|
readonly pgsparser_lastRenderIssue: (a: number) => [number, number];
|
|
242
257
|
readonly pgsparser_new: () => number;
|
|
243
258
|
readonly pgsparser_parse: (a: number, b: number, c: number) => number;
|
package/pkg/libbitsub.js
CHANGED
|
@@ -88,6 +88,15 @@ export class DvbParser {
|
|
|
88
88
|
const ret = wasm.dvbparser_getEndTimestamps(this.__wbg_ptr);
|
|
89
89
|
return ret;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Get cue end times starting at cue `start`, for incremental updates.
|
|
93
|
+
* @param {number} start
|
|
94
|
+
* @returns {Float64Array}
|
|
95
|
+
*/
|
|
96
|
+
getEndTimestampsFrom(start) {
|
|
97
|
+
const ret = wasm.dvbparser_getEndTimestampsFrom(this.__wbg_ptr, start);
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
91
100
|
/**
|
|
92
101
|
* @returns {Float64Array}
|
|
93
102
|
*/
|
|
@@ -95,6 +104,15 @@ export class DvbParser {
|
|
|
95
104
|
const ret = wasm.dvbparser_getTimestamps(this.__wbg_ptr);
|
|
96
105
|
return ret;
|
|
97
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Get cue start times starting at cue `start`, for incremental updates.
|
|
109
|
+
* @param {number} start
|
|
110
|
+
* @returns {Float64Array}
|
|
111
|
+
*/
|
|
112
|
+
getTimestampsFrom(start) {
|
|
113
|
+
const ret = wasm.dvbparser_getTimestampsFrom(this.__wbg_ptr, start);
|
|
114
|
+
return ret;
|
|
115
|
+
}
|
|
98
116
|
/**
|
|
99
117
|
* @returns {string}
|
|
100
118
|
*/
|
|
@@ -257,6 +275,15 @@ export class PgsParser {
|
|
|
257
275
|
const ret = wasm.pgsparser_getTimestamps(this.__wbg_ptr);
|
|
258
276
|
return ret;
|
|
259
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Get timestamps starting at cue `start`, for incremental updates.
|
|
280
|
+
* @param {number} start
|
|
281
|
+
* @returns {Float64Array}
|
|
282
|
+
*/
|
|
283
|
+
getTimestampsFrom(start) {
|
|
284
|
+
const ret = wasm.pgsparser_getTimestampsFrom(this.__wbg_ptr, start);
|
|
285
|
+
return ret;
|
|
286
|
+
}
|
|
260
287
|
/**
|
|
261
288
|
* @returns {string}
|
|
262
289
|
*/
|
package/pkg/libbitsub_bg.wasm
CHANGED
|
Binary file
|
|
@@ -19,7 +19,9 @@ export const dvbparser_getCueEndTime: (a: number, b: number) => number;
|
|
|
19
19
|
export const dvbparser_getCuePageState: (a: number, b: number) => number;
|
|
20
20
|
export const dvbparser_getCueStartTime: (a: number, b: number) => number;
|
|
21
21
|
export const dvbparser_getEndTimestamps: (a: number) => any;
|
|
22
|
+
export const dvbparser_getEndTimestampsFrom: (a: number, b: number) => any;
|
|
22
23
|
export const dvbparser_getTimestamps: (a: number) => any;
|
|
24
|
+
export const dvbparser_getTimestampsFrom: (a: number, b: number) => any;
|
|
23
25
|
export const dvbparser_lastRenderIssue: (a: number) => [number, number];
|
|
24
26
|
export const dvbparser_new: () => number;
|
|
25
27
|
export const dvbparser_parse: (a: number, b: number, c: number) => number;
|
|
@@ -40,6 +42,7 @@ export const pgsparser_getCueEndTime: (a: number, b: number) => number;
|
|
|
40
42
|
export const pgsparser_getCuePaletteId: (a: number, b: number) => number;
|
|
41
43
|
export const pgsparser_getCueStartTime: (a: number, b: number) => number;
|
|
42
44
|
export const pgsparser_getTimestamps: (a: number) => any;
|
|
45
|
+
export const pgsparser_getTimestampsFrom: (a: number, b: number) => any;
|
|
43
46
|
export const pgsparser_lastRenderIssue: (a: number) => [number, number];
|
|
44
47
|
export const pgsparser_new: () => number;
|
|
45
48
|
export const pgsparser_parse: (a: number, b: number, c: number) => number;
|
package/pkg/package.json
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* hls.js handles HLS media and WebVTT/IMSC text tracks; use this helper for
|
|
5
5
|
* external PGS/VobSub/MKS bitmap overlays on the same media element.
|
|
6
6
|
*
|
|
7
|
+
* @module
|
|
8
|
+
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
9
11
|
* import Hls from 'hls.js'
|
|
@@ -33,8 +35,10 @@ export interface HlsLike {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
/** Options for attachBitSubToHls(). */
|
|
36
39
|
export type BitSubHlsOptions = AttachBitSubOptions
|
|
37
40
|
|
|
41
|
+
/** Handle returned by attachBitSubToHls(). */
|
|
38
42
|
export interface BitSubHlsHandle extends BitSubController {
|
|
39
43
|
/** Underlying hls.js instance. */
|
|
40
44
|
readonly hls: HlsLike
|
|
@@ -150,5 +154,7 @@ export function attachBitSubToHls(hls: HlsLike, options: BitSubHlsOptions = {}):
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
|
|
157
|
+
/** Shared attach options and controller types. */
|
|
153
158
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
159
|
+
/** Attach or construct a libbitsub controller. */
|
|
154
160
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Optional player integrations for libbitsub.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Prefer deep imports (`libbitsub/videojs`, `libbitsub/shaka`, `libbitsub/hlsjs`,
|
|
5
|
+
* `libbitsub/react`) so unused peer dependencies stay out of your bundle.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
5
8
|
*/
|
|
6
9
|
|
|
10
|
+
/** Shared attach/create helpers used by every player adapter. */
|
|
7
11
|
export {
|
|
8
12
|
attachBitSub,
|
|
9
13
|
createBitSubRenderer,
|
|
@@ -13,6 +17,7 @@ export {
|
|
|
13
17
|
type BitSubSourceOptions
|
|
14
18
|
} from './shared'
|
|
15
19
|
|
|
20
|
+
/** Video.js plugin and player typings. */
|
|
16
21
|
export {
|
|
17
22
|
registerBitSubPlugin,
|
|
18
23
|
type BitSubVideoJsApi,
|
|
@@ -22,10 +27,13 @@ export {
|
|
|
22
27
|
type VideoJsPlayerLike
|
|
23
28
|
} from './videojs'
|
|
24
29
|
|
|
30
|
+
/** Shaka Player adapter. */
|
|
25
31
|
export { attachBitSubToShaka, type BitSubShakaHandle, type BitSubShakaOptions, type ShakaPlayerLike } from './shaka'
|
|
26
32
|
|
|
33
|
+
/** hls.js adapter. */
|
|
27
34
|
export { attachBitSubToHls, type BitSubHlsHandle, type BitSubHlsOptions, type HlsLike } from './hlsjs'
|
|
28
35
|
|
|
36
|
+
/** React hook and overlay component. */
|
|
29
37
|
export {
|
|
30
38
|
BitSubOverlay,
|
|
31
39
|
useBitSub,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Optional React bindings for libbitsub bitmap subtitles.
|
|
3
3
|
*
|
|
4
|
-
* Peer dependency: react >= 18
|
|
4
|
+
* Peer dependency: react >= 18.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
5
7
|
*
|
|
6
8
|
* @example
|
|
7
9
|
* ```tsx
|
|
@@ -26,13 +28,16 @@ import { useEffect, useRef, useState, type CSSProperties, type ReactElement, typ
|
|
|
26
28
|
import { attachBitSub, type AttachBitSubOptions, type BitSubController, type BitSubSourceOptions } from './shared'
|
|
27
29
|
import type { SubtitleDisplaySettings, SubtitleDiagnosticWarning, SubtitleRendererEvent } from '../wrapper'
|
|
28
30
|
|
|
31
|
+
/** Subtitle source fields accepted by the React bindings. */
|
|
29
32
|
export type BitSubReactSource = BitSubSourceOptions
|
|
30
33
|
|
|
34
|
+
/** Options for useBitSub(). */
|
|
31
35
|
export interface UseBitSubOptions extends BitSubReactSource {
|
|
32
36
|
/** When false, do not load even if source fields are set. Default true. */
|
|
33
37
|
enabled?: boolean
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
/** Return value of useBitSub(). */
|
|
36
41
|
export interface UseBitSubResult {
|
|
37
42
|
controller: BitSubController | null
|
|
38
43
|
error: Error | null
|
|
@@ -152,6 +157,7 @@ export function useBitSub(
|
|
|
152
157
|
return { controller, error }
|
|
153
158
|
}
|
|
154
159
|
|
|
160
|
+
/** Props for BitSubOverlay. */
|
|
155
161
|
export interface BitSubOverlayProps extends UseBitSubOptions {
|
|
156
162
|
videoRef: RefObject<HTMLVideoElement | null>
|
|
157
163
|
/** Optional class name applied to a zero-size host span for debugging. */
|
|
@@ -171,6 +177,9 @@ export function BitSubOverlay(props: BitSubOverlayProps): ReactElement | null {
|
|
|
171
177
|
return <span className={className} style={{ display: 'none', ...style }} aria-hidden='true' />
|
|
172
178
|
}
|
|
173
179
|
|
|
180
|
+
/** Shared attach options and controller types. */
|
|
174
181
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
182
|
+
/** Attach or construct a libbitsub controller. */
|
|
175
183
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
|
184
|
+
/** Runtime overlay display settings. */
|
|
176
185
|
export type { SubtitleDisplaySettings }
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Bitmap PGS/VobSub tracks are not native Shaka text tracks — this helper
|
|
5
5
|
* overlays libbitsub on the player media element.
|
|
6
6
|
*
|
|
7
|
+
* @module
|
|
8
|
+
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
9
11
|
* import shaka from 'shaka-player'
|
|
@@ -26,8 +28,10 @@ export interface ShakaPlayerLike {
|
|
|
26
28
|
removeEventListener?(type: string, listener: (...args: unknown[]) => void): void
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
/** Options for attachBitSubToShaka(). */
|
|
29
32
|
export type BitSubShakaOptions = AttachBitSubOptions
|
|
30
33
|
|
|
34
|
+
/** Handle returned by attachBitSubToShaka(). */
|
|
31
35
|
export interface BitSubShakaHandle extends BitSubController {
|
|
32
36
|
/** Underlying Shaka player reference. */
|
|
33
37
|
readonly player: ShakaPlayerLike
|
|
@@ -88,5 +92,7 @@ export function attachBitSubToShaka(player: ShakaPlayerLike, options: BitSubShak
|
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
/** Shared attach options and controller types. */
|
|
91
96
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
97
|
+
/** Attach or construct a libbitsub controller. */
|
|
92
98
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
|
@@ -19,6 +19,7 @@ export type BitSubRenderer = PgsRenderer | VobSubRenderer | DvbRenderer
|
|
|
19
19
|
/** Subtitle source + renderer options without a bound video element. */
|
|
20
20
|
export type BitSubSourceOptions = Omit<AutoVideoSubtitleOptions, 'video'>
|
|
21
21
|
|
|
22
|
+
/** Handle returned by player adapters. */
|
|
22
23
|
export interface BitSubController {
|
|
23
24
|
/** Active renderer, or null when no track is loaded. */
|
|
24
25
|
readonly renderer: BitSubRenderer | null
|
|
@@ -40,6 +41,7 @@ export interface BitSubController {
|
|
|
40
41
|
setVideo(video: HTMLVideoElement | null): void
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
/** Options for attachBitSub(). */
|
|
43
45
|
export interface AttachBitSubOptions extends BitSubSourceOptions {
|
|
44
46
|
/** When false, skip the initial load even if source fields are present. Default true. */
|
|
45
47
|
autoLoad?: boolean
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Optional Video.js plugin for libbitsub bitmap subtitles.
|
|
3
3
|
*
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
4
6
|
* @example
|
|
5
7
|
* ```ts
|
|
6
8
|
* import videojs from 'video.js'
|
|
@@ -26,24 +28,29 @@ export interface VideoJsPlayerLike {
|
|
|
26
28
|
trigger?(event: string, data?: unknown): void
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
/** Minimal Video.js plugin instance surface. */
|
|
29
32
|
export interface VideoJsPluginBase {
|
|
30
33
|
player: VideoJsPlayerLike
|
|
31
34
|
options_: unknown
|
|
32
35
|
dispose(): void
|
|
33
36
|
}
|
|
34
37
|
|
|
38
|
+
/** Minimal Video.js plugin constructor surface. */
|
|
35
39
|
export interface VideoJsPluginConstructor {
|
|
36
40
|
new (player: VideoJsPlayerLike, options?: unknown): VideoJsPluginBase
|
|
37
41
|
prototype: VideoJsPluginBase
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
/** Minimal video.js factory used by the plugin. */
|
|
40
45
|
export interface VideoJsLike {
|
|
41
46
|
getPlugin(name: string): VideoJsPluginConstructor
|
|
42
47
|
registerPlugin(name: string, plugin: unknown): void
|
|
43
48
|
}
|
|
44
49
|
|
|
50
|
+
/** Options for player.bitsub(). */
|
|
45
51
|
export type BitSubVideoJsOptions = AttachBitSubOptions
|
|
46
52
|
|
|
53
|
+
/** Video.js player.bitsub() API. */
|
|
47
54
|
export interface BitSubVideoJsApi {
|
|
48
55
|
/** Active controller, if any. */
|
|
49
56
|
controller(): BitSubController | null
|
|
@@ -196,5 +203,7 @@ export type VideoJsBitSubPlayer = VideoJsPlayerLike & {
|
|
|
196
203
|
bitsub(options?: BitSubVideoJsOptions): BitSubVideoJsApi
|
|
197
204
|
}
|
|
198
205
|
|
|
206
|
+
/** Shared attach options and controller types. */
|
|
199
207
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
208
|
+
/** Attach or construct a libbitsub controller. */
|
|
200
209
|
export { attachBitSub, createBitSubRenderer } from './shared'
|