@omnimedia/omnitool 1.0.0 → 1.1.0-10
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/LICENSE +21 -0
- package/README.md +120 -2
- package/package.json +59 -27
- package/s/_archive/types.ts +107 -0
- package/s/context.ts +7 -0
- package/s/demo/demo.bundle.ts +68 -0
- package/s/demo/demo.css +59 -0
- package/s/demo/routines/filmstrip-test.ts +68 -0
- package/s/demo/routines/load-video.ts +7 -0
- package/s/demo/routines/transcode-test.ts +46 -0
- package/s/demo/routines/transcriber-test.ts +34 -0
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/demo/routines/waveform-test.ts +12 -0
- package/s/driver/driver.test.ts +15 -0
- package/s/driver/driver.ts +124 -0
- package/s/driver/driver.worker.bundle.ts +7 -0
- package/s/driver/fns/host.ts +13 -0
- package/s/driver/fns/schematic.ts +106 -0
- package/s/driver/fns/work.ts +249 -0
- package/s/driver/parts/constants.ts +17 -0
- package/s/driver/parts/machina.ts +27 -0
- package/s/driver/utils/load-decoder-source.ts +12 -0
- package/s/driver/utils/sleep.ts +3 -0
- package/s/features/speech/transcribe/default-spec.ts +11 -0
- package/s/features/speech/transcribe/parts/load-pipe.ts +19 -0
- package/s/features/speech/transcribe/parts/prep-audio.ts +23 -0
- package/s/features/speech/transcribe/parts/transcribe.ts +70 -0
- package/s/features/speech/transcribe/transcriber.ts +46 -0
- package/s/features/speech/transcribe/types.ts +82 -0
- package/s/features/speech/transcribe/worker.bundle.ts +40 -0
- package/s/features/transition/parts/fragment.ts +24 -0
- package/s/features/transition/parts/types.ts +94 -0
- package/s/features/transition/parts/uniforms.ts +29 -0
- package/s/features/transition/parts/vertex.ts +31 -0
- package/s/features/transition/transition.ts +60 -0
- package/s/index.html.ts +58 -0
- package/s/index.ts +2 -39
- package/s/tests.test.ts +8 -0
- package/s/timeline/index.ts +15 -0
- package/s/timeline/parts/basics.ts +17 -0
- package/s/timeline/parts/compositor/export.ts +77 -0
- package/s/timeline/parts/compositor/parts/html-tree.ts +37 -0
- package/s/timeline/parts/compositor/parts/schedulers.ts +85 -0
- package/s/timeline/parts/compositor/parts/tree-builder.ts +184 -0
- package/s/timeline/parts/compositor/parts/webcodecs-tree.ts +30 -0
- package/s/timeline/parts/compositor/playback.ts +81 -0
- package/s/timeline/parts/compositor/samplers/html.ts +115 -0
- package/s/timeline/parts/compositor/samplers/webcodecs.ts +60 -0
- package/s/timeline/parts/filmstrip.ts +159 -0
- package/s/timeline/parts/item.ts +90 -0
- package/s/timeline/parts/media.ts +35 -0
- package/s/timeline/parts/resource-pool.ts +27 -0
- package/s/timeline/parts/resource.ts +11 -0
- package/s/timeline/parts/waveform.ts +62 -0
- package/s/timeline/sugar/builders.ts +102 -0
- package/s/timeline/sugar/o.ts +150 -0
- package/s/timeline/sugar/omni-test.ts +38 -0
- package/s/timeline/sugar/omni.ts +40 -0
- package/s/timeline/types.ts +29 -0
- package/s/timeline/utils/audio-stream.ts +15 -0
- package/s/timeline/utils/checksum.ts +20 -0
- package/s/timeline/utils/datafile.ts +21 -0
- package/s/timeline/utils/dummy-data.ts +7 -0
- package/s/timeline/utils/matrix.ts +33 -0
- package/s/timeline/utils/video-cursor.ts +40 -0
- package/s/tools/common/loader.ts +26 -0
- package/s/tools/common/transformer-pipeline.ts +26 -0
- package/s/tools/speech-recognition/common/model.ts +26 -0
- package/s/tools/speech-recognition/whisper/fns/host.ts +25 -0
- package/s/tools/speech-recognition/whisper/fns/schematic.ts +23 -0
- package/s/tools/speech-recognition/whisper/fns/work.ts +91 -0
- package/s/tools/speech-recognition/whisper/parts/types.ts +38 -0
- package/s/tools/speech-recognition/whisper/parts/worker.bundle.ts +7 -0
- package/s/tools/speech-recognition/whisper/tool.ts +70 -0
- package/x/context.d.ts +4 -0
- package/x/context.js +6 -0
- package/x/context.js.map +1 -0
- package/x/demo/demo.bundle.d.ts +1 -0
- package/x/demo/demo.bundle.js +55 -0
- package/x/demo/demo.bundle.js.map +1 -0
- package/x/demo/demo.bundle.min.js +120 -0
- package/x/demo/demo.bundle.min.js.map +7 -0
- package/x/demo/demo.css +59 -0
- package/x/demo/routines/filmstrip-test.d.ts +1 -0
- package/x/demo/routines/filmstrip-test.js +62 -0
- package/x/demo/routines/filmstrip-test.js.map +1 -0
- package/x/demo/routines/load-video.d.ts +1 -0
- package/x/demo/routines/load-video.js +6 -0
- package/x/demo/routines/load-video.js.map +1 -0
- package/x/demo/routines/transcode-test.d.ts +6 -0
- package/x/demo/routines/transcode-test.js +40 -0
- package/x/demo/routines/transcode-test.js.map +1 -0
- package/x/demo/routines/transcriber-test.d.ts +4 -0
- package/x/demo/routines/transcriber-test.js +33 -0
- package/x/demo/routines/transcriber-test.js.map +1 -0
- package/x/demo/routines/transitions-test.d.ts +5 -0
- package/x/demo/routines/transitions-test.js +35 -0
- package/x/demo/routines/transitions-test.js.map +1 -0
- package/x/demo/routines/waveform-test.d.ts +1 -0
- package/x/demo/routines/waveform-test.js +11 -0
- package/x/demo/routines/waveform-test.js.map +1 -0
- package/x/driver/driver.d.ts +20 -0
- package/x/driver/driver.js +104 -0
- package/x/driver/driver.js.map +1 -0
- package/x/driver/driver.test.d.ts +5 -0
- package/x/driver/driver.test.js +12 -0
- package/x/driver/driver.test.js.map +1 -0
- package/x/driver/driver.worker.bundle.d.ts +1 -0
- package/x/driver/driver.worker.bundle.js +4 -0
- package/x/driver/driver.worker.bundle.js.map +1 -0
- package/x/driver/driver.worker.bundle.min.js +3537 -0
- package/x/driver/driver.worker.bundle.min.js.map +7 -0
- package/x/driver/fns/host.d.ts +25 -0
- package/x/driver/fns/host.js +7 -0
- package/x/driver/fns/host.js.map +1 -0
- package/x/driver/fns/schematic.d.ts +84 -0
- package/x/driver/fns/schematic.js +2 -0
- package/x/driver/fns/schematic.js.map +1 -0
- package/x/driver/fns/work.d.ts +26 -0
- package/x/driver/fns/work.js +201 -0
- package/x/driver/fns/work.js.map +1 -0
- package/x/driver/parts/constants.d.ts +2 -0
- package/x/driver/parts/constants.js +17 -0
- package/x/driver/parts/constants.js.map +1 -0
- package/x/driver/parts/machina.d.ts +23 -0
- package/x/driver/parts/machina.js +14 -0
- package/x/driver/parts/machina.js.map +1 -0
- package/x/driver/utils/load-decoder-source.d.ts +3 -0
- package/x/driver/utils/load-decoder-source.js +11 -0
- package/x/driver/utils/load-decoder-source.js.map +1 -0
- package/x/driver/utils/sleep.d.ts +1 -0
- package/x/driver/utils/sleep.js +4 -0
- package/x/driver/utils/sleep.js.map +1 -0
- package/x/features/speech/transcribe/default-spec.d.ts +2 -0
- package/x/features/speech/transcribe/default-spec.js +8 -0
- package/x/features/speech/transcribe/default-spec.js.map +1 -0
- package/x/features/speech/transcribe/parts/load-pipe.d.ts +2 -0
- package/x/features/speech/transcribe/parts/load-pipe.js +13 -0
- package/x/features/speech/transcribe/parts/load-pipe.js.map +1 -0
- package/x/features/speech/transcribe/parts/prep-audio.d.ts +5 -0
- package/x/features/speech/transcribe/parts/prep-audio.js +21 -0
- package/x/features/speech/transcribe/parts/prep-audio.js.map +1 -0
- package/x/features/speech/transcribe/parts/transcribe.d.ts +5 -0
- package/x/features/speech/transcribe/parts/transcribe.js +56 -0
- package/x/features/speech/transcribe/parts/transcribe.js.map +1 -0
- package/x/features/speech/transcribe/transcriber.d.ts +5 -0
- package/x/features/speech/transcribe/transcriber.js +33 -0
- package/x/features/speech/transcribe/transcriber.js.map +1 -0
- package/x/features/speech/transcribe/types.d.ts +66 -0
- package/x/features/speech/transcribe/types.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.d.ts +1 -0
- package/x/features/speech/transcribe/worker.bundle.js +33 -0
- package/x/features/speech/transcribe/worker.bundle.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.min.js +2916 -0
- package/x/features/speech/transcribe/worker.bundle.min.js.map +7 -0
- package/x/features/transition/parts/fragment.d.ts +1 -0
- package/x/features/transition/parts/fragment.js +25 -0
- package/x/features/transition/parts/fragment.js.map +1 -0
- package/x/features/transition/parts/types.d.ts +23 -0
- package/x/features/transition/parts/types.js +2 -0
- package/x/features/transition/parts/types.js.map +1 -0
- package/x/features/transition/parts/uniforms.d.ts +31 -0
- package/x/features/transition/parts/uniforms.js +27 -0
- package/x/features/transition/parts/uniforms.js.map +1 -0
- package/x/features/transition/parts/vertex.d.ts +1 -0
- package/x/features/transition/parts/vertex.js +32 -0
- package/x/features/transition/parts/vertex.js.map +1 -0
- package/x/features/transition/transition.d.ts +5 -0
- package/x/features/transition/transition.js +50 -0
- package/x/features/transition/transition.js.map +1 -0
- package/x/index.d.ts +2 -9
- package/x/index.html +115 -0
- package/x/index.html.d.ts +2 -0
- package/x/index.html.js +52 -0
- package/x/index.html.js.map +1 -0
- package/x/index.js +2 -29
- package/x/index.js.map +1 -1
- package/x/tests.test.d.ts +1 -0
- package/x/tests.test.js +6 -0
- package/x/tests.test.js.map +1 -0
- package/x/timeline/index.d.ts +11 -0
- package/x/timeline/index.js +12 -0
- package/x/timeline/index.js.map +1 -0
- package/x/timeline/parts/basics.d.ts +12 -0
- package/x/timeline/parts/basics.js +2 -0
- package/x/timeline/parts/basics.js.map +1 -0
- package/x/timeline/parts/compositor/export.d.ts +9 -0
- package/x/timeline/parts/compositor/export.js +64 -0
- package/x/timeline/parts/compositor/export.js.map +1 -0
- package/x/timeline/parts/compositor/parts/html-tree.d.ts +3 -0
- package/x/timeline/parts/compositor/parts/html-tree.js +40 -0
- package/x/timeline/parts/compositor/parts/html-tree.js.map +1 -0
- package/x/timeline/parts/compositor/parts/schedulers.d.ts +15 -0
- package/x/timeline/parts/compositor/parts/schedulers.js +64 -0
- package/x/timeline/parts/compositor/parts/schedulers.js.map +1 -0
- package/x/timeline/parts/compositor/parts/tree-builder.d.ts +37 -0
- package/x/timeline/parts/compositor/parts/tree-builder.js +147 -0
- package/x/timeline/parts/compositor/parts/tree-builder.js.map +1 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.d.ts +3 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js +28 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js.map +1 -0
- package/x/timeline/parts/compositor/playback.d.ts +19 -0
- package/x/timeline/parts/compositor/playback.js +71 -0
- package/x/timeline/parts/compositor/playback.js.map +1 -0
- package/x/timeline/parts/compositor/samplers/html.d.ts +3 -0
- package/x/timeline/parts/compositor/samplers/html.js +106 -0
- package/x/timeline/parts/compositor/samplers/html.js.map +1 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.d.ts +2 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js +55 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js.map +1 -0
- package/x/timeline/parts/filmstrip.d.ts +39 -0
- package/x/timeline/parts/filmstrip.js +117 -0
- package/x/timeline/parts/filmstrip.js.map +1 -0
- package/x/timeline/parts/item.d.ts +68 -0
- package/x/timeline/parts/item.js +16 -0
- package/x/timeline/parts/item.js.map +1 -0
- package/x/timeline/parts/media.d.ts +10 -0
- package/x/timeline/parts/media.js +30 -0
- package/x/timeline/parts/media.js.map +1 -0
- package/x/timeline/parts/resource-pool.d.ts +7 -0
- package/x/timeline/parts/resource-pool.js +19 -0
- package/x/timeline/parts/resource-pool.js.map +1 -0
- package/x/timeline/parts/resource.d.ts +8 -0
- package/x/timeline/parts/resource.js +2 -0
- package/x/timeline/parts/resource.js.map +1 -0
- package/x/timeline/parts/waveform.d.ts +8 -0
- package/x/timeline/parts/waveform.js +51 -0
- package/x/timeline/parts/waveform.js.map +1 -0
- package/x/timeline/sugar/builders.d.ts +1 -0
- package/x/timeline/sugar/builders.js +104 -0
- package/x/timeline/sugar/builders.js.map +1 -0
- package/x/timeline/sugar/o.d.ts +32 -0
- package/x/timeline/sugar/o.js +114 -0
- package/x/timeline/sugar/o.js.map +1 -0
- package/x/timeline/sugar/omni-test.d.ts +1 -0
- package/x/timeline/sugar/omni-test.js +22 -0
- package/x/timeline/sugar/omni-test.js.map +1 -0
- package/x/timeline/sugar/omni.d.ts +14 -0
- package/x/timeline/sugar/omni.js +28 -0
- package/x/timeline/sugar/omni.js.map +1 -0
- package/x/timeline/types.d.ts +24 -0
- package/x/timeline/types.js +2 -0
- package/x/timeline/types.js.map +1 -0
- package/x/timeline/utils/audio-stream.d.ts +6 -0
- package/x/timeline/utils/audio-stream.js +17 -0
- package/x/timeline/utils/audio-stream.js.map +1 -0
- package/x/timeline/utils/checksum.d.ts +8 -0
- package/x/timeline/utils/checksum.js +21 -0
- package/x/timeline/utils/checksum.js.map +1 -0
- package/x/timeline/utils/datafile.d.ts +9 -0
- package/x/timeline/utils/datafile.js +20 -0
- package/x/timeline/utils/datafile.js.map +1 -0
- package/x/timeline/utils/dummy-data.d.ts +2 -0
- package/x/timeline/utils/dummy-data.js +3 -0
- package/x/timeline/utils/dummy-data.js.map +1 -0
- package/x/timeline/utils/matrix.d.ts +8 -0
- package/x/timeline/utils/matrix.js +26 -0
- package/x/timeline/utils/matrix.js.map +1 -0
- package/x/timeline/utils/video-cursor.d.ts +10 -0
- package/x/timeline/utils/video-cursor.js +36 -0
- package/x/timeline/utils/video-cursor.js.map +1 -0
- package/x/tools/common/loader.d.ts +19 -0
- package/x/tools/common/loader.js +18 -0
- package/x/tools/common/loader.js.map +1 -0
- package/x/tools/common/transformer-pipeline.d.ts +8 -0
- package/x/tools/common/transformer-pipeline.js +24 -0
- package/x/tools/common/transformer-pipeline.js.map +1 -0
- package/x/tools/speech-recognition/common/model.d.ts +14 -0
- package/x/tools/speech-recognition/common/model.js +16 -0
- package/x/tools/speech-recognition/common/model.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/host.d.ts +13 -0
- package/x/tools/speech-recognition/whisper/fns/host.js +19 -0
- package/x/tools/speech-recognition/whisper/fns/host.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.d.ts +19 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.js +2 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/work.d.ts +12 -0
- package/x/tools/speech-recognition/whisper/fns/work.js +74 -0
- package/x/tools/speech-recognition/whisper/fns/work.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/types.d.ts +31 -0
- package/x/tools/speech-recognition/whisper/parts/types.js +2 -0
- package/x/tools/speech-recognition/whisper/parts/types.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.d.ts +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js +4 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js +8 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js.map +7 -0
- package/x/tools/speech-recognition/whisper/tool.d.ts +12 -0
- package/x/tools/speech-recognition/whisper/tool.js +63 -0
- package/x/tools/speech-recognition/whisper/tool.js.map +1 -0
- package/s/parts/compositor.ts +0 -5
- package/s/parts/export.ts +0 -5
- package/s/parts/video-decoder.ts +0 -27
- package/s/parts/video-encoder.ts +0 -15
- package/s/tools/generate-id.ts +0 -7
- package/s/tools/mp4boxjs/LICENSE.md +0 -24
- package/s/tools/mp4boxjs/demuxer.ts +0 -106
- package/s/tools/mp4boxjs/mp4box.adapter.ts +0 -148
- package/s/tools/mp4boxjs/mp4box.js +0 -8206
- package/s/types.ts +0 -10
- package/x/parts/compositor.d.ts +0 -4
- package/x/parts/compositor.js +0 -5
- package/x/parts/compositor.js.map +0 -1
- package/x/parts/export.d.ts +0 -7
- package/x/parts/export.js +0 -5
- package/x/parts/export.js.map +0 -1
- package/x/parts/video-decoder.d.ts +0 -8
- package/x/parts/video-decoder.js +0 -20
- package/x/parts/video-decoder.js.map +0 -1
- package/x/parts/video-encoder.d.ts +0 -6
- package/x/parts/video-encoder.js +0 -12
- package/x/parts/video-encoder.js.map +0 -1
- package/x/tools/generate-id.d.ts +0 -1
- package/x/tools/generate-id.js +0 -8
- package/x/tools/generate-id.js.map +0 -1
- package/x/tools/mp4boxjs/demuxer.d.ts +0 -24
- package/x/tools/mp4boxjs/demuxer.js +0 -88
- package/x/tools/mp4boxjs/demuxer.js.map +0 -1
- package/x/tools/mp4boxjs/mp4box.adapter.d.ts +0 -128
- package/x/tools/mp4boxjs/mp4box.adapter.js +0 -11
- package/x/tools/mp4boxjs/mp4box.adapter.js.map +0 -1
- package/x/types.d.ts +0 -7
- package/x/types.js.map +0 -1
- /package/x/{types.js → features/speech/transcribe/types.js} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Comrade } from "@e280/comrade";
|
|
2
|
+
import { context } from "../../../context.js";
|
|
3
|
+
import { setupWhisperHost } from "./fns/host.js";
|
|
4
|
+
import { SpeechRecognizer } from "../common/model.js";
|
|
5
|
+
export class Whisper extends SpeechRecognizer {
|
|
6
|
+
thread;
|
|
7
|
+
constructor(thread) {
|
|
8
|
+
super('whisper', "onnx-community/whisper-tiny_timestamped");
|
|
9
|
+
this.thread = thread;
|
|
10
|
+
}
|
|
11
|
+
static async setup() {
|
|
12
|
+
const thread = await Comrade.thread({
|
|
13
|
+
label: "OmnitoolDriver",
|
|
14
|
+
workerUrl: new URL("/tools/speech-recognition/whisper/parts/worker.bundle.min.js", import.meta.url),
|
|
15
|
+
setupHost: setupWhisperHost({
|
|
16
|
+
...this.loaderEvents,
|
|
17
|
+
...this.speechRecognizerEvents
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
return new this(thread);
|
|
21
|
+
}
|
|
22
|
+
async init() {
|
|
23
|
+
// there should be called loading of the model in worker instead when transcribe is called ..
|
|
24
|
+
}
|
|
25
|
+
async #transcribe(source, options) {
|
|
26
|
+
const arrayBuffer = await source.arrayBuffer();
|
|
27
|
+
const audioCTX = new AudioContext({ sampleRate: 16000 });
|
|
28
|
+
const audioData = await audioCTX.decodeAudioData(arrayBuffer);
|
|
29
|
+
let audio;
|
|
30
|
+
if (audioData.numberOfChannels === 2) {
|
|
31
|
+
const SCALING_FACTOR = Math.sqrt(2);
|
|
32
|
+
const left = audioData.getChannelData(0);
|
|
33
|
+
const right = audioData.getChannelData(1);
|
|
34
|
+
audio = new Float32Array(left.length);
|
|
35
|
+
for (let i = 0; i < audioData.length; ++i) {
|
|
36
|
+
audio[i] = (SCALING_FACTOR * (left[i] + right[i])) / 2;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
audio = audioData.getChannelData(0);
|
|
41
|
+
}
|
|
42
|
+
const driver = await context.driver;
|
|
43
|
+
const duration = await driver.getAudioDuration(source);
|
|
44
|
+
return await this.thread.work.transcribe({
|
|
45
|
+
audio,
|
|
46
|
+
duration,
|
|
47
|
+
model: this.model,
|
|
48
|
+
subtask: this.multilingual ? "transcribe" : null,
|
|
49
|
+
language: this.multilingual && options?.language !== "auto"
|
|
50
|
+
? options?.language ?? "english"
|
|
51
|
+
: null
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async transcribe(source) {
|
|
55
|
+
const result = await this.#transcribe(source);
|
|
56
|
+
const words = result?.chunks.map((chunk) => ({
|
|
57
|
+
text: chunk.text.trim(),
|
|
58
|
+
timestamp: chunk.timestamp,
|
|
59
|
+
}));
|
|
60
|
+
return words;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../s/tools/speech-recognition/whisper/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAS,MAAM,eAAe,CAAA;AAG7C,OAAO,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAGnD,MAAM,OAAO,OAAQ,SAAQ,gBAAgB;IACzB;IAAnB,YAAmB,MAAgC;QAClD,KAAK,CAAC,SAAS,EAAE,yCAAyC,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VideoClip} from "../types.js"
|
|
2
|
-
|
|
3
|
-
export class OmniVideoDecoder {
|
|
4
|
-
|
|
5
|
-
#decoder = new VideoDecoder({
|
|
6
|
-
output: () => this.#output(),
|
|
7
|
-
error: () => this.#error()
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
private getLoadedClip: (clip: Clip) =>
|
|
12
|
-
LoadedVideoClip | undefined
|
|
13
|
-
) {}
|
|
14
|
-
|
|
15
|
-
#output() {}
|
|
16
|
-
|
|
17
|
-
#error() {}
|
|
18
|
-
|
|
19
|
-
decodeVideo(clip: Clip) {
|
|
20
|
-
const loaded = this.getLoadedClip(clip)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
seek(clip: Clip) {
|
|
24
|
-
const loaded = this.getLoadedClip(clip)
|
|
25
|
-
loaded?.demuxer.seek()
|
|
26
|
-
}
|
|
27
|
-
}
|
package/s/parts/video-encoder.ts
DELETED
package/s/tools/generate-id.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2012. Telecom ParisTech/TSI/MM/GPAC Cyril Concolato
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
|
6
|
-
* Redistributions of source code must retain the above copyright
|
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
|
10
|
-
documentation and/or other materials provided with the distribution.
|
|
11
|
-
* Neither the name of the copyright holder nor the
|
|
12
|
-
names of its contributors may be used to endorse or promote products
|
|
13
|
-
derived from this software without specific prior written permission.
|
|
14
|
-
|
|
15
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
-
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
19
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import MP4Box, {MP4File, MP4Info, MP4MediaTrack} from "./mp4box.adapter.js"
|
|
2
|
-
|
|
3
|
-
export type Status = "render" | "decode" | "demux" | "fetch"
|
|
4
|
-
type SetStatus = (status: Status, message: string) => void
|
|
5
|
-
type OnChunk = (chunk: EncodedVideoChunk) => void
|
|
6
|
-
type OnConfig = (config: VideoDecoderConfig) => void
|
|
7
|
-
type OnReady = (boolean: boolean) => void
|
|
8
|
-
|
|
9
|
-
export class MP4FileSink {
|
|
10
|
-
#setStatus: SetStatus
|
|
11
|
-
#file: MP4File
|
|
12
|
-
#offset = 0
|
|
13
|
-
|
|
14
|
-
constructor(file: MP4File, setStatus: SetStatus) {
|
|
15
|
-
this.#file = file
|
|
16
|
-
this.#setStatus = setStatus
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
write(chunk: ArrayBuffer) {
|
|
20
|
-
const buffer = new ArrayBuffer(chunk.byteLength)
|
|
21
|
-
//@ts-ignore
|
|
22
|
-
new Uint8Array(buffer).set(chunk)
|
|
23
|
-
//@ts-ignore
|
|
24
|
-
buffer.fileStart = this.#offset
|
|
25
|
-
this.#offset += buffer.byteLength
|
|
26
|
-
this.#setStatus("fetch", (this.#offset / (1024 ** 2)).toFixed(1) + " MiB")!
|
|
27
|
-
//@ts-ignore
|
|
28
|
-
this.#file!.appendBuffer(buffer)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
close() {
|
|
32
|
-
this.#setStatus("fetch", "Done")
|
|
33
|
-
this.#file.flush()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class MP4Demuxer {
|
|
38
|
-
#onConfig: OnConfig
|
|
39
|
-
#onChunk: OnChunk
|
|
40
|
-
#OnReady: OnReady
|
|
41
|
-
#setStatus: SetStatus
|
|
42
|
-
#framesCount: (frames: number) => void
|
|
43
|
-
#file: MP4File
|
|
44
|
-
|
|
45
|
-
constructor(file: File, {onConfig, onChunk, setStatus, framesCount, OnReady}: {onConfig: OnConfig, onChunk: OnChunk, setStatus: SetStatus, framesCount: (frames: number) => void, OnReady: OnReady}) {
|
|
46
|
-
this.#onConfig = onConfig
|
|
47
|
-
this.#onChunk = onChunk
|
|
48
|
-
this.#setStatus = setStatus
|
|
49
|
-
this.#framesCount = framesCount
|
|
50
|
-
this.#OnReady = OnReady
|
|
51
|
-
|
|
52
|
-
this.#file = MP4Box.createFile()
|
|
53
|
-
this.#file.onError = error => setStatus("demux", error)
|
|
54
|
-
this.#file.onReady = this.#onReady.bind(this)
|
|
55
|
-
this.#file.onSamples = this.#onSamples.bind(this)
|
|
56
|
-
const fileSink = new MP4FileSink(this.#file, setStatus)
|
|
57
|
-
file.stream().pipeTo(new WritableStream(fileSink, {highWaterMark: 1}))
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
seek() {
|
|
61
|
-
console.log("seek", this.#file.seek)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
#description(track: MP4MediaTrack) {
|
|
65
|
-
const trak = this.#file.getTrackById(track.id)
|
|
66
|
-
for (const entry of trak.mdia!.minf!.stbl!.stsd!.entries) {
|
|
67
|
-
//@ts-ignore
|
|
68
|
-
const box = entry.avcC || entry.hvcC || entry.vpcC || entry.av1C
|
|
69
|
-
if (box) {
|
|
70
|
-
//@ts-ignore
|
|
71
|
-
const stream = new MP4Box.DataStream(undefined, 0, MP4Box.DataStream.BIG_ENDIAN)
|
|
72
|
-
box.write(stream)
|
|
73
|
-
return new Uint8Array(stream.buffer!, 8) // Remove the box header.
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
throw new Error("avcC, hvcC, vpcC, or av1C box not found")
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
#onReady(info: MP4Info) {
|
|
80
|
-
this.#OnReady(true)
|
|
81
|
-
this.#setStatus("demux", "Ready")
|
|
82
|
-
const track = info.videoTracks[0]
|
|
83
|
-
this.#onConfig({
|
|
84
|
-
codec: track.codec.startsWith('vp08') ? 'vp8' : track.codec,
|
|
85
|
-
codedHeight: track.video.height,
|
|
86
|
-
codedWidth: track.video.width,
|
|
87
|
-
description: this.#description(track),
|
|
88
|
-
});
|
|
89
|
-
this.#framesCount(track.nb_samples)
|
|
90
|
-
this.#file.setExtractionOptions(track.id)
|
|
91
|
-
// this.#file.start()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#onSamples(track_id: number, ref: any, samples: any) {
|
|
95
|
-
for (const sample of samples) {
|
|
96
|
-
this.#onChunk(new EncodedVideoChunk({
|
|
97
|
-
type: sample.is_sync ? "key" : "delta",
|
|
98
|
-
timestamp: 1e6 * sample.cts / sample.timescale,
|
|
99
|
-
duration: 1e6 * sample.duration / sample.timescale,
|
|
100
|
-
data: sample.data
|
|
101
|
-
}))
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import {mp4box} from "./mp4box.js"
|
|
3
|
-
|
|
4
|
-
export interface MP4MediaTrack {
|
|
5
|
-
id: number;
|
|
6
|
-
created: Date;
|
|
7
|
-
modified: Date;
|
|
8
|
-
movie_duration: number;
|
|
9
|
-
layer: number;
|
|
10
|
-
alternate_group: number;
|
|
11
|
-
volume: number;
|
|
12
|
-
track_width: number;
|
|
13
|
-
track_height: number;
|
|
14
|
-
timescale: number;
|
|
15
|
-
duration: number;
|
|
16
|
-
bitrate: number;
|
|
17
|
-
codec: string;
|
|
18
|
-
language: string;
|
|
19
|
-
nb_samples: number;
|
|
20
|
-
type: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface MP4VideoData {
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface MP4VideoTrack extends MP4MediaTrack {
|
|
29
|
-
video: MP4VideoData;
|
|
30
|
-
}
|
|
31
|
-
export interface MP4AudioTrack extends MP4MediaTrack {
|
|
32
|
-
audio: MP4AudioData;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface MP4Info {
|
|
36
|
-
duration: number;
|
|
37
|
-
timescale: number;
|
|
38
|
-
fragment_duration: number;
|
|
39
|
-
isFragmented: boolean;
|
|
40
|
-
isProgressive: boolean;
|
|
41
|
-
hasIOD: boolean;
|
|
42
|
-
brands: string[];
|
|
43
|
-
created: Date;
|
|
44
|
-
modified: Date;
|
|
45
|
-
tracks: MP4Track[];
|
|
46
|
-
audioTracks: MP4AudioTrack[];
|
|
47
|
-
videoTracks: MP4VideoTrack[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface MP4AudioData {
|
|
51
|
-
sample_rate: number;
|
|
52
|
-
channel_count: number;
|
|
53
|
-
sample_size: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface Moov {
|
|
57
|
-
type: string;
|
|
58
|
-
hdr_size: Number;
|
|
59
|
-
size: Number;
|
|
60
|
-
start: Number;
|
|
61
|
-
traks: any;
|
|
62
|
-
uuid: String | undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface MP4File {
|
|
66
|
-
onMoovStart?: () => void;
|
|
67
|
-
onReady?: (info: MP4Info) => void;
|
|
68
|
-
onError?: (e: string) => void;
|
|
69
|
-
onSamples?: (track_id: number, _ref: any, samples: any) => void;
|
|
70
|
-
setExtractionOptions: (id: number) => void;
|
|
71
|
-
|
|
72
|
-
moov: Moov;
|
|
73
|
-
|
|
74
|
-
appendBuffer(data: MP4ArrayBuffer): number;
|
|
75
|
-
start(): void;
|
|
76
|
-
stop(): void;
|
|
77
|
-
flush(): void;
|
|
78
|
-
getTrackById: (id: number) => Trak
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
type MP4Track = MP4VideoTrack | MP4AudioTrack;
|
|
82
|
-
|
|
83
|
-
export interface MP4Box {
|
|
84
|
-
createFile(): MP4File;
|
|
85
|
-
DataStream: new (arrayBuffer: ArrayBuffer, byteOffset: number, endianness: boolean) => XDataStream
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type MP4ArrayBuffer = ArrayBuffer & {fileStart: number};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export interface TrackOptions {
|
|
92
|
-
timescale: number;
|
|
93
|
-
width: number;
|
|
94
|
-
height: number;
|
|
95
|
-
nb_samples: number;
|
|
96
|
-
avcDecoderConfigRecord: AllowSharedBufferSource | undefined;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface SampleOptions {
|
|
100
|
-
duration: number;
|
|
101
|
-
dts: number;
|
|
102
|
-
cts: number;
|
|
103
|
-
is_sync: boolean;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface MP4File {
|
|
107
|
-
onMoovStart?: () => void;
|
|
108
|
-
onReady?: (info: MP4Info) => void;
|
|
109
|
-
onError?: (e: string) => void;
|
|
110
|
-
|
|
111
|
-
appendBuffer(data: MP4ArrayBuffer): number;
|
|
112
|
-
start(): void;
|
|
113
|
-
stop(): void;
|
|
114
|
-
flush(): void;
|
|
115
|
-
addTrack(trackOptions: TrackOptions): MP4Track;
|
|
116
|
-
addSample(track: MP4Track, data: ArrayBuffer, sampleOptions: SampleOptions):void;
|
|
117
|
-
save(file: string):void;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export class XDataStream {
|
|
121
|
-
static BIG_ENDIAN: boolean;
|
|
122
|
-
static LITTLE_ENDIAN: boolean;
|
|
123
|
-
buffer?: ArrayBuffer;
|
|
124
|
-
constructor(arrayBuffer: ArrayBuffer, byteOffset: number, endianness: boolean) {}
|
|
125
|
-
// TODO: Complete interface
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface Trak {
|
|
129
|
-
mdia?: {
|
|
130
|
-
minf?: {
|
|
131
|
-
stbl?: {
|
|
132
|
-
stsd?: {
|
|
133
|
-
entries: {
|
|
134
|
-
avcC?: {
|
|
135
|
-
write: (stream: XDataStream) => void
|
|
136
|
-
}
|
|
137
|
-
hvcC?: {
|
|
138
|
-
write: (stream: XDataStream) => void
|
|
139
|
-
}
|
|
140
|
-
}[]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// TODO: Complete interface
|
|
146
|
-
}
|
|
147
|
-
export default mp4box as MP4Box;
|
|
148
|
-
export const DataStreamx = mp4box.DataStream as XDataStream
|