alpha2 0.6.1 → 0.7.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 +3 -3
- package/dist/effects.d.ts +3 -2
- package/dist/export-failure.d.ts +6 -0
- package/dist/export-failure.js +18 -1
- package/dist/export-retry.d.ts +2 -1
- package/dist/export-retry.js +12 -5
- package/dist/extract.d.ts +0 -5
- package/dist/extract.js +5 -12
- package/dist/extractor.d.ts +16 -3
- package/dist/extractor.js +2 -1
- package/dist/generated/project-schema.d.ts +31 -1
- package/dist/generated/project-schema.js +5 -0
- package/dist/generated/project-shape.js +14 -1
- package/dist/gpu-recovery.d.ts +13 -5
- package/dist/gpu-recovery.js +19 -8
- package/dist/hdr-frames.js +2 -0
- package/dist/media-source.d.ts +3 -0
- package/dist/media-source.js +13 -0
- package/dist/media.d.ts +12 -1
- package/dist/media.js +15 -1
- package/dist/mediabunny.d.ts +4 -1
- package/dist/mediabunny.js +22 -23
- package/dist/player.js +2 -0
- package/dist/plugin-manifest.d.ts +119 -0
- package/dist/plugin-manifest.js +583 -0
- package/dist/plugin-supplied.d.ts +55 -0
- package/dist/plugin-supplied.js +221 -0
- package/dist/plugins.d.ts +87 -9
- package/dist/plugins.js +196 -47
- package/dist/project-data.d.ts +19 -0
- package/dist/project-data.js +210 -7
- package/dist/project.d.ts +1 -1
- package/dist/project.js +1 -1
- package/dist/sha256.d.ts +1 -1
- package/package.json +1 -1
- package/wasm/alpha2_compose_bg.wasm +0 -0
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_extensions_pdf_bg.wasm +0 -0
- package/wasm/alpha2_wasm.d.ts +14 -12
- package/wasm/alpha2_wasm.js +48 -46
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +6 -6
- /package/wasm/snippets/{alpha2-wasm-6749ed8b34a74067/inline4.js → alpha2-wasm-7cccf477e10e3d0d/inline0.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-6749ed8b34a74067/inline0.js → alpha2-wasm-7cccf477e10e3d0d/inline1.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-6749ed8b34a74067/inline1.js → alpha2-wasm-7cccf477e10e3d0d/inline2.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-6749ed8b34a74067/inline2.js → alpha2-wasm-7cccf477e10e3d0d/inline3.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-6749ed8b34a74067/inline3.js → alpha2-wasm-7cccf477e10e3d0d/inline4.js} +0 -0
package/dist/mediabunny.js
CHANGED
|
@@ -5,8 +5,9 @@ import { chromaSitingForStream } from "./chroma-siting.js";
|
|
|
5
5
|
import { decoderOrderKey, decoderPlaneOrder } from "./decoder-order.js";
|
|
6
6
|
import { decodeFailureOf, withSoftwareFallback } from "./decoder-fallback.js";
|
|
7
7
|
import { isUnreadableFrame, withReadbackRetries } from "./frame-intake.js";
|
|
8
|
-
import { ALL_FORMATS, AudioSample, AudioSampleSink, AudioSampleSource,
|
|
9
|
-
import { audioFrameGrid, MAX_AUDIO_CHANNELS, microsecondsToTicks, placeOnAudioFrameGrid, presentationSlackTicks, readMatroskaCodecDelay, readVideoOrientation, roundingQuantum, ROUNDING_SCAN_BYTES, ROUNDING_SCAN_FRAMES, validateStallTimeout, } from "./media.js";
|
|
8
|
+
import { ALL_FORMATS, AudioSample, AudioSampleSink, AudioSampleSource, BufferTarget, canEncodeAudio, canEncodeVideo, StreamTarget, EncodedPacketSink, Input, MkvOutputFormat, MovOutputFormat, Mp4OutputFormat, Output, Quality, VideoSample, VideoSampleSink, VideoSampleSource, WebMOutputFormat, } from "mediabunny";
|
|
9
|
+
import { audioFrameGrid, MAX_AUDIO_CHANNELS, microsecondsToTicks, placeOnAudioFrameGrid, presentationSlackTicks, readMatroskaCodecDelay, readVideoOrientation, roundingQuantum, ROUNDING_SCAN_BYTES, ROUNDING_SCAN_FRAMES, validateStallTimeout, isRangeReader, } from "./media.js";
|
|
10
|
+
import { mediaSource } from "./media-source.js";
|
|
10
11
|
import { DecodeUnavailableError, decodeRefusalMessage, isPlanarVideoFrame, PlanarDecodeUnavailableError, } from "./hdr-frames.js";
|
|
11
12
|
import { resolveExportFormat } from "./containers.js";
|
|
12
13
|
import { ExportFailureError } from "./export-failure.js";
|
|
@@ -86,9 +87,7 @@ export class MediabunnyVideoDecoder {
|
|
|
86
87
|
if (limits.maxCachedFrames < MIN_CACHED_FRAMES)
|
|
87
88
|
throw new RangeError(`maxCachedFrames must be at least ${MIN_CACHED_FRAMES}`);
|
|
88
89
|
validateStallTimeout(limits.stallTimeoutMs);
|
|
89
|
-
const source = resource
|
|
90
|
-
? new BlobSource(resource)
|
|
91
|
-
: new BufferSource(resource);
|
|
90
|
+
const source = mediaSource(resource);
|
|
92
91
|
const input = new Input({ source, formats: ALL_FORMATS });
|
|
93
92
|
try {
|
|
94
93
|
const track = await input.getPrimaryVideoTrack();
|
|
@@ -654,13 +653,17 @@ function mediabunnyVideoFrameBytes(frame) {
|
|
|
654
653
|
function byteReader(resource) {
|
|
655
654
|
if (resource instanceof Blob)
|
|
656
655
|
return async (offset, length) => new Uint8Array(await resource.slice(offset, offset + length).arrayBuffer());
|
|
656
|
+
if (isRangeReader(resource))
|
|
657
|
+
return (offset, length) => resource.read(Math.min(offset, resource.size), Math.min(offset + length, resource.size));
|
|
657
658
|
const bytes = resource instanceof ArrayBuffer
|
|
658
659
|
? new Uint8Array(resource)
|
|
659
660
|
: new Uint8Array(resource.buffer, resource.byteOffset, resource.byteLength);
|
|
660
661
|
return (offset, length) => Promise.resolve(bytes.subarray(offset, offset + length));
|
|
661
662
|
}
|
|
662
663
|
function byteLength(resource) {
|
|
663
|
-
return resource instanceof Blob
|
|
664
|
+
return resource instanceof Blob || isRangeReader(resource)
|
|
665
|
+
? resource.size
|
|
666
|
+
: resource.byteLength;
|
|
664
667
|
}
|
|
665
668
|
function bufferBytes(source) {
|
|
666
669
|
if (source === undefined)
|
|
@@ -762,10 +765,10 @@ async function firstFramePlanes(track, hardwareAcceleration, timeoutMs) {
|
|
|
762
765
|
*/
|
|
763
766
|
export async function probePlanarDecode(resource, options) {
|
|
764
767
|
const timeoutMs = options.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
|
|
765
|
-
const name = resource instanceof File
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
768
|
+
const name = resource instanceof File || isRangeReader(resource)
|
|
769
|
+
? (resource.name ?? "the video")
|
|
770
|
+
: "the video";
|
|
771
|
+
const source = mediaSource(resource);
|
|
769
772
|
const input = new Input({ source, formats: ALL_FORMATS });
|
|
770
773
|
try {
|
|
771
774
|
const track = await input.getPrimaryVideoTrack();
|
|
@@ -921,9 +924,7 @@ export async function probeAudioDecode(name, track, declared) {
|
|
|
921
924
|
*/
|
|
922
925
|
export async function probeAudioStreams(resource) {
|
|
923
926
|
const input = new Input({
|
|
924
|
-
source: resource
|
|
925
|
-
? new BlobSource(resource)
|
|
926
|
-
: new BufferSource(resource),
|
|
927
|
+
source: mediaSource(resource),
|
|
927
928
|
formats: ALL_FORMATS,
|
|
928
929
|
});
|
|
929
930
|
try {
|
|
@@ -948,9 +949,7 @@ export async function probeAudioStreams(resource) {
|
|
|
948
949
|
/** {@link probeAudioDecode} on the primary audio track; rejects with `Error` when there is none. */
|
|
949
950
|
export async function probeAudioSource(name, resource) {
|
|
950
951
|
const input = new Input({
|
|
951
|
-
source: resource
|
|
952
|
-
? new BlobSource(resource)
|
|
953
|
-
: new BufferSource(resource),
|
|
952
|
+
source: mediaSource(resource),
|
|
954
953
|
formats: ALL_FORMATS,
|
|
955
954
|
});
|
|
956
955
|
try {
|
|
@@ -1024,9 +1023,7 @@ export class MediabunnyAudioDecoder {
|
|
|
1024
1023
|
static async open(sourceId, resource, binding, options = {}) {
|
|
1025
1024
|
const stallTimeoutMs = options.stallTimeoutMs ?? DEFAULT_STALL_TIMEOUT_MS;
|
|
1026
1025
|
validateStallTimeout(stallTimeoutMs);
|
|
1027
|
-
const source = resource
|
|
1028
|
-
? new BlobSource(resource)
|
|
1029
|
-
: new BufferSource(resource);
|
|
1026
|
+
const source = mediaSource(resource);
|
|
1030
1027
|
const input = new Input({ source, formats: ALL_FORMATS });
|
|
1031
1028
|
const track = options.stream === undefined
|
|
1032
1029
|
? await input.getPrimaryAudioTrack()
|
|
@@ -2557,8 +2554,9 @@ export class MediabunnyAdapterFactory {
|
|
|
2557
2554
|
async openVideo(sourceId, input) {
|
|
2558
2555
|
if (!(input instanceof Blob) &&
|
|
2559
2556
|
!(input instanceof ArrayBuffer) &&
|
|
2560
|
-
!ArrayBuffer.isView(input)
|
|
2561
|
-
|
|
2557
|
+
!ArrayBuffer.isView(input) &&
|
|
2558
|
+
!isRangeReader(input)) {
|
|
2559
|
+
throw new TypeError("mediabunny input must be a Blob, ArrayBuffer view or range reader");
|
|
2562
2560
|
}
|
|
2563
2561
|
return MediabunnyVideoDecoder.open(sourceId, input);
|
|
2564
2562
|
}
|
|
@@ -2569,8 +2567,9 @@ export class MediabunnyAdapterFactory {
|
|
|
2569
2567
|
async openAudio(sourceId, input) {
|
|
2570
2568
|
if (!(input instanceof Blob) &&
|
|
2571
2569
|
!(input instanceof ArrayBuffer) &&
|
|
2572
|
-
!ArrayBuffer.isView(input)
|
|
2573
|
-
|
|
2570
|
+
!ArrayBuffer.isView(input) &&
|
|
2571
|
+
!isRangeReader(input))
|
|
2572
|
+
throw new TypeError("mediabunny input must be a Blob, ArrayBuffer view or range reader");
|
|
2574
2573
|
if (this.#audioResampler === undefined)
|
|
2575
2574
|
throw new TypeError("mediabunny audio needs alpha2/wasm: pass it to the MediabunnyAdapterFactory");
|
|
2576
2575
|
return MediabunnyAudioDecoder.open(sourceId, input, this.#audioResampler);
|
package/dist/player.js
CHANGED
|
@@ -233,6 +233,8 @@ export class Alpha2Player {
|
|
|
233
233
|
frameIndex: null,
|
|
234
234
|
timeTicks: null,
|
|
235
235
|
gpuMs: null,
|
|
236
|
+
measured: false,
|
|
237
|
+
submissions: null,
|
|
236
238
|
message: "the GPU device was lost",
|
|
237
239
|
};
|
|
238
240
|
let step = this.#ladder.onLoss(report, await this.#backend.probeSurface());
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ExtractorDescriptor } from "./extractor.js";
|
|
2
|
+
/** The ABI this build implements. */
|
|
3
|
+
export declare const PLUGIN_ABI = "alpha2-plugin/1";
|
|
4
|
+
/** Mirrors `alpha2_engine::extract::MAX_MANIFEST_BYTES`: the longest manifest, in UTF-8 bytes. */
|
|
5
|
+
export declare const MAX_MANIFEST_BYTES: number;
|
|
6
|
+
/** Mirrors `alpha2_engine::extract::MAX_PLUGIN_ARTIFACTS`. */
|
|
7
|
+
export declare const MAX_PLUGIN_ARTIFACTS = 64;
|
|
8
|
+
/** Mirrors `alpha2_engine::extract::MAX_PLUGIN_RESOURCES`. */
|
|
9
|
+
export declare const MAX_PLUGIN_RESOURCES = 64;
|
|
10
|
+
/** Mirrors `alpha2_engine::extract::MAX_PLUGIN_SLOTS`, counted within the resources. */
|
|
11
|
+
export declare const MAX_PLUGIN_SLOTS = 16;
|
|
12
|
+
/** Mirrors `alpha2_engine::extract::MAX_PLUGIN_ARTIFACT_BYTES`. */
|
|
13
|
+
export declare const MAX_PLUGIN_ARTIFACT_BYTES: number;
|
|
14
|
+
/** Mirrors `alpha2_engine::extract::MAX_PLUGIN_RESOURCE_BYTES`, one pinned resource. */
|
|
15
|
+
export declare const MAX_PLUGIN_RESOURCE_BYTES: number;
|
|
16
|
+
/** Mirrors `alpha2_engine::extract::MAX_PLUGIN_RESOURCES_TOTAL_BYTES`, pinned resources only. */
|
|
17
|
+
export declare const MAX_PLUGIN_RESOURCES_TOTAL_BYTES: number;
|
|
18
|
+
/** Mirrors `alpha2_engine::extract::MAX_SLOT_NAME_BYTES`. */
|
|
19
|
+
export declare const MAX_SLOT_NAME_BYTES = 64;
|
|
20
|
+
/** Mirrors `alpha2_engine::extract::MAX_SLOT_ACCEPT`. */
|
|
21
|
+
export declare const MAX_SLOT_ACCEPT = 16;
|
|
22
|
+
/** Mirrors `alpha2_engine::extract::MAX_SLOT_ACCEPT_BYTES`. */
|
|
23
|
+
export declare const MAX_SLOT_ACCEPT_BYTES = 64;
|
|
24
|
+
/** Mirrors `alpha2_engine::extract::MAX_ABOUT_NAME_CHARS`, in Unicode code points. */
|
|
25
|
+
export declare const MAX_ABOUT_NAME_CHARS = 80;
|
|
26
|
+
/** Mirrors `alpha2_engine::extract::MAX_ABOUT_SUMMARY_CHARS`. */
|
|
27
|
+
export declare const MAX_ABOUT_SUMMARY_CHARS = 400;
|
|
28
|
+
/** Mirrors `alpha2_engine::extract::MAX_ABOUT_AUTHOR_CHARS`. */
|
|
29
|
+
export declare const MAX_ABOUT_AUTHOR_CHARS = 80;
|
|
30
|
+
/** Mirrors `alpha2_engine::extract::MAX_ABOUT_HOMEPAGE_CHARS`. */
|
|
31
|
+
export declare const MAX_ABOUT_HOMEPAGE_CHARS = 2048;
|
|
32
|
+
/** Mirrors `alpha2_engine::extract::MAX_ABOUT_LICENSE_CHARS`. */
|
|
33
|
+
export declare const MAX_ABOUT_LICENSE_CHARS = 256;
|
|
34
|
+
/** Mirrors `alpha2_engine::extract::MAX_OUTPUT_LABEL_CHARS`. */
|
|
35
|
+
export declare const MAX_OUTPUT_LABEL_CHARS = 80;
|
|
36
|
+
/** Mirrors `alpha2_engine::extract::MAX_OUTPUT_DESCRIPTION_CHARS`. */
|
|
37
|
+
export declare const MAX_OUTPUT_DESCRIPTION_CHARS = 400;
|
|
38
|
+
/** Mirrors `alpha2_engine::extract::MAX_EXTRACTOR_OUTPUTS`. */
|
|
39
|
+
export declare const MAX_EXTRACTOR_OUTPUTS = 32;
|
|
40
|
+
/**
|
|
41
|
+
* A plugin that was refused, did not load or failed, with the code every surface uses.
|
|
42
|
+
* `details` is what a caller reads besides the code: `{ slot, reason }` for
|
|
43
|
+
* `PLUGIN_RESOURCE_INVALID`.
|
|
44
|
+
*/
|
|
45
|
+
export declare class PluginError extends Error {
|
|
46
|
+
readonly code: string;
|
|
47
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
48
|
+
constructor(code: string, message: string, options?: ErrorOptions & {
|
|
49
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** One build of a plugin. */
|
|
53
|
+
export interface PluginArtifact {
|
|
54
|
+
/** `wasm32`, or the Rust target triple a native artifact is built for. */
|
|
55
|
+
readonly target: string;
|
|
56
|
+
readonly type: "wasm" | "cdylib" | "staticlib";
|
|
57
|
+
/** A path under the manifest's own directory, or an absolute `https:` URL. */
|
|
58
|
+
readonly url: string;
|
|
59
|
+
/** 64 lowercase hexadecimal digits. */
|
|
60
|
+
readonly sha256: string;
|
|
61
|
+
readonly bytes: number;
|
|
62
|
+
}
|
|
63
|
+
/** A file the manifest pins. */
|
|
64
|
+
export interface PinnedPluginResource {
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly url: string;
|
|
67
|
+
readonly sha256: string;
|
|
68
|
+
readonly bytes: number;
|
|
69
|
+
readonly supplied?: undefined;
|
|
70
|
+
}
|
|
71
|
+
/** A slot the caller fills with a file or a directory when it loads the plugin. */
|
|
72
|
+
export interface SuppliedPluginResource {
|
|
73
|
+
readonly name: string;
|
|
74
|
+
readonly supplied: {
|
|
75
|
+
readonly shape: "file" | "directory";
|
|
76
|
+
/** `true` when left out. */
|
|
77
|
+
readonly required?: boolean;
|
|
78
|
+
/** The largest single file the plugin takes from the slot, in bytes. */
|
|
79
|
+
readonly max_bytes?: number;
|
|
80
|
+
/** File name suffixes a picker offers, such as `.onnx`. */
|
|
81
|
+
readonly accept?: readonly string[];
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export type PluginResource = PinnedPluginResource | SuppliedPluginResource;
|
|
85
|
+
/** What an interface shows about a plugin: plain text, never markup. */
|
|
86
|
+
export interface PluginAbout {
|
|
87
|
+
readonly name: string;
|
|
88
|
+
readonly summary?: string;
|
|
89
|
+
readonly author?: string;
|
|
90
|
+
/** An `https:` URL. */
|
|
91
|
+
readonly homepage?: string;
|
|
92
|
+
/** An SPDX license expression. */
|
|
93
|
+
readonly license?: string;
|
|
94
|
+
}
|
|
95
|
+
/** A plugin's manifest, as `schema/plugin-manifest.v1.json` describes it. */
|
|
96
|
+
export interface PluginManifest {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
/** The package's semantic version. */
|
|
99
|
+
readonly version: string;
|
|
100
|
+
readonly abi: typeof PLUGIN_ABI;
|
|
101
|
+
readonly kind: "extractor";
|
|
102
|
+
readonly artifacts: readonly PluginArtifact[];
|
|
103
|
+
readonly resources?: readonly PluginResource[];
|
|
104
|
+
readonly about?: PluginAbout;
|
|
105
|
+
/** As the engine reads it: `max_size`, `block_frames` and `params_schema` filled in. */
|
|
106
|
+
readonly descriptor: ExtractorDescriptor;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reads and checks a manifest by the rules the engine's loaders use, fetching nothing. The
|
|
110
|
+
* descriptor comes back as the engine reads it, with `max_size`, `block_frames` and
|
|
111
|
+
* `params_schema` filled in and `null` options left out.
|
|
112
|
+
*
|
|
113
|
+
* Throws a {@link PluginError}: `PLUGIN_ABI_UNSUPPORTED` for another `abi`, checked first, and
|
|
114
|
+
* `PLUGIN_LOAD_FAILED` for text past {@link MAX_MANIFEST_BYTES}, text that is not JSON, or a
|
|
115
|
+
* manifest that breaks a rule of `docs/plugin-abi.md`.
|
|
116
|
+
*/
|
|
117
|
+
export declare function parsePluginManifest(text: string): PluginManifest;
|
|
118
|
+
/** Reads a descriptor JSON as {@link parsePluginManifest} reads a manifest's. */
|
|
119
|
+
export declare function readPluginDescriptor(value: unknown): ExtractorDescriptor;
|