jassub 2.0.16 → 2.0.17

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.
@@ -0,0 +1,25 @@
1
+ export interface SubtitleCallbackMetadata {
2
+ fps: number;
3
+ processingDuration: number;
4
+ droppedFrames: number;
5
+ presentedFrames: number;
6
+ mistimedFrames: number;
7
+ presentationTime: DOMHighResTimeStamp;
8
+ expectedDisplayTime: DOMHighResTimeStamp;
9
+ width: number;
10
+ height: number;
11
+ mediaTime: number;
12
+ frameDelay: DOMHighResTimeStamp;
13
+ }
14
+ export declare class Debug {
15
+ fps: (delta: any) => number;
16
+ processingDuration: (delta: any) => number;
17
+ droppedFrames: number;
18
+ presentedFrames: number;
19
+ mistimedFrames: number;
20
+ _drop(): void;
21
+ _startTime: number;
22
+ _startFrame(): void;
23
+ onsubtitleFrameCallback?: (now: DOMHighResTimeStamp, metadata: SubtitleCallbackMetadata) => void;
24
+ _endFrame(meta: VideoFrameCallbackMetadata): void;
25
+ }
package/dist/debug.js ADDED
@@ -0,0 +1,41 @@
1
+ import throughput from 'throughput';
2
+ export class Debug {
3
+ // 5 second average
4
+ fps = throughput(5);
5
+ processingDuration = throughput(5);
6
+ droppedFrames = 0;
7
+ presentedFrames = 0;
8
+ mistimedFrames = 0;
9
+ _drop() {
10
+ ++this.droppedFrames;
11
+ }
12
+ _startTime = 0;
13
+ _startFrame() {
14
+ this._startTime = performance.now();
15
+ }
16
+ onsubtitleFrameCallback = console.log;
17
+ _endFrame(meta) {
18
+ ++this.presentedFrames;
19
+ const fps = this.fps(1);
20
+ const now = performance.now();
21
+ const processingDuration = this.processingDuration((now - this._startTime) / fps);
22
+ const frameDelay = Math.max(0, meta.expectedDisplayTime - now);
23
+ if (frameDelay)
24
+ ++this.mistimedFrames;
25
+ this.onsubtitleFrameCallback?.(now, {
26
+ fps,
27
+ processingDuration,
28
+ droppedFrames: this.droppedFrames,
29
+ presentedFrames: this.presentedFrames,
30
+ mistimedFrames: this.mistimedFrames,
31
+ presentationTime: now,
32
+ expectedDisplayTime: meta.expectedDisplayTime + (frameDelay > 0 ? fps / 1000 : 0),
33
+ frameDelay,
34
+ width: meta.width,
35
+ height: meta.height,
36
+ mediaTime: meta.mediaTime
37
+ });
38
+ console.info('%cFPS: %c%f %c| Frame Time: %c%d ms %c| Dropped Frames: %c%d %c| 5s Avg', 'color: #888', 'color: #0f0; font-weight: bold', fps.toFixed(1), 'color: #888', 'color: #0ff; font-weight: bold', processingDuration, 'color: #888', 'color: #f00; font-weight: bold', this.droppedFrames, 'color: #888');
39
+ }
40
+ }
41
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AAgBnC,MAAM,OAAO,KAAK;IAChB,mBAAmB;IACnB,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;IACnB,kBAAkB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;IAClC,aAAa,GAAG,CAAC,CAAA;IACjB,eAAe,GAAG,CAAC,CAAA;IACnB,cAAc,GAAG,CAAC,CAAA;IAElB,KAAK;QACH,EAAE,IAAI,CAAC,aAAa,CAAA;IACtB,CAAC;IAED,UAAU,GAAG,CAAC,CAAA;IACd,WAAW;QACT,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IACrC,CAAC;IAED,uBAAuB,GAA4E,OAAO,CAAC,GAAG,CAAA;IAE9G,SAAS,CAAE,IAAgC;QACzC,EAAE,IAAI,CAAC,eAAe,CAAA;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACvB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAA;QACjF,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,GAAG,CAAC,CAAA;QAC9D,IAAI,UAAU;YAAE,EAAE,IAAI,CAAC,cAAc,CAAA;QAErC,IAAI,CAAC,uBAAuB,EAAE,CAAC,GAAG,EAAE;YAClC,GAAG;YACH,kBAAkB;YAClB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,gBAAgB,EAAE,GAAG;YACrB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACjF,UAAU;YACV,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAA;QAEF,OAAO,CAAC,IAAI,CACV,yEAAyE,EACzE,aAAa,EACb,gCAAgC,EAChC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EACd,aAAa,EACb,gCAAgC,EAChC,kBAAkB,EAClB,aAAa,EACb,gCAAgC,EAChC,IAAI,CAAC,aAAa,EAClB,aAAa,CACd,CAAA;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jassub",
3
- "version": "2.0.16",
3
+ "version": "2.0.17",
4
4
  "description": "libass subtitle renderer for modern browsers",
5
5
  "main": "dist/jassub.js",
6
6
  "type": "module",
@@ -8,6 +8,7 @@
8
8
  "dist/wasm/*",
9
9
  "dist/worker/*",
10
10
  "dist/jassub.*",
11
+ "dist/debug.*",
11
12
  "!dist/wasm/jassub-worker-modern.js",
12
13
  "README.md",
13
14
  "LICENSE",