@omnimedia/omnitool 1.1.0-1 → 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/README.md +1 -1
- package/package.json +12 -9
- package/s/context.ts +1 -1
- package/s/demo/demo.bundle.ts +6 -2
- package/s/demo/demo.css +5 -0
- package/s/demo/routines/filmstrip-test.ts +2 -2
- package/s/demo/routines/transcode-test.ts +4 -2
- package/s/demo/routines/transcriber-test.ts +34 -0
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/driver/driver.ts +17 -9
- package/s/driver/fns/host.ts +7 -6
- package/s/driver/fns/schematic.ts +45 -22
- package/s/driver/fns/work.ts +163 -151
- package/s/driver/utils/load-decoder-source.ts +3 -4
- 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 +6 -1
- package/s/timeline/index.ts +1 -0
- package/s/timeline/parts/basics.ts +1 -1
- 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/item.ts +38 -6
- package/s/timeline/parts/media.ts +21 -0
- package/s/timeline/parts/waveform.ts +1 -1
- package/s/timeline/sugar/builders.ts +102 -0
- package/s/timeline/sugar/o.ts +117 -27
- package/s/timeline/sugar/omni-test.ts +2 -2
- package/s/timeline/sugar/omni.ts +21 -11
- package/s/timeline/types.ts +29 -0
- package/s/timeline/utils/audio-stream.ts +15 -0
- package/s/timeline/utils/checksum.ts +2 -1
- 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.js +1 -1
- package/x/context.js.map +1 -1
- package/x/demo/demo.bundle.js +6 -2
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +39 -37
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/demo.css +5 -0
- package/x/demo/routines/filmstrip-test.d.ts +1 -1
- package/x/demo/routines/filmstrip-test.js +2 -2
- package/x/demo/routines/filmstrip-test.js.map +1 -1
- package/x/demo/routines/transcode-test.js +4 -2
- package/x/demo/routines/transcode-test.js.map +1 -1
- 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/driver/driver.d.ts +3 -5
- package/x/driver/driver.js +16 -9
- package/x/driver/driver.js.map +1 -1
- package/x/driver/driver.worker.bundle.min.js +2537 -148
- package/x/driver/driver.worker.bundle.min.js.map +4 -4
- package/x/driver/fns/host.d.ts +9 -2
- package/x/driver/fns/host.js +3 -3
- package/x/driver/fns/host.js.map +1 -1
- package/x/driver/fns/schematic.d.ts +39 -21
- package/x/driver/fns/work.d.ts +11 -4
- package/x/driver/fns/work.js +111 -102
- package/x/driver/fns/work.js.map +1 -1
- package/x/driver/utils/load-decoder-source.d.ts +2 -1
- package/x/driver/utils/load-decoder-source.js +2 -3
- package/x/driver/utils/load-decoder-source.js.map +1 -1
- 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 +2 -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.html +13 -3
- package/x/index.html.js +6 -1
- package/x/index.html.js.map +1 -1
- package/x/timeline/index.d.ts +1 -0
- package/x/timeline/index.js +1 -0
- package/x/timeline/index.js.map +1 -1
- package/x/timeline/parts/basics.d.ts +1 -1
- 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/item.d.ts +34 -8
- package/x/timeline/parts/item.js +6 -3
- package/x/timeline/parts/item.js.map +1 -1
- package/x/timeline/parts/media.d.ts +3 -0
- package/x/timeline/parts/media.js +17 -0
- package/x/timeline/parts/media.js.map +1 -1
- package/x/timeline/parts/waveform.js +1 -1
- package/x/timeline/parts/waveform.js.map +1 -1
- 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 +23 -5
- package/x/timeline/sugar/o.js +93 -27
- package/x/timeline/sugar/o.js.map +1 -1
- package/x/timeline/sugar/omni-test.js +1 -1
- package/x/timeline/sugar/omni-test.js.map +1 -1
- package/x/timeline/sugar/omni.d.ts +5 -2
- package/x/timeline/sugar/omni.js +17 -9
- package/x/timeline/sugar/omni.js.map +1 -1
- 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.js +2 -1
- package/x/timeline/utils/checksum.js.map +1 -1
- 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/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnimedia/omnitool",
|
|
3
|
-
"version": "1.1.0-
|
|
3
|
+
"version": "1.1.0-10",
|
|
4
4
|
"description": "open source video processing tools",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Przemysław Gałęzki",
|
|
@@ -23,20 +23,23 @@
|
|
|
23
23
|
"test-debug": "node inspect x/tests.test.js"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@e280/science": "^0.0.
|
|
27
|
-
"@e280/scute": "^0.0.0-
|
|
28
|
-
"@types/node": "^24.0
|
|
26
|
+
"@e280/science": "^0.0.6",
|
|
27
|
+
"@e280/scute": "^0.0.0-7",
|
|
28
|
+
"@types/node": "^24.2.0",
|
|
29
29
|
"http-server": "^14.1.1",
|
|
30
30
|
"npm-run-all": "^4.1.5",
|
|
31
|
-
"typescript": "^5.
|
|
31
|
+
"typescript": "^5.9.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@benev/slate": "^0.3.9",
|
|
35
|
-
"@e280/comrade": "^0.0.0-
|
|
36
|
-
"@e280/renraku": "^0.5.0-
|
|
37
|
-
"@e280/stz": "^0.0.0-
|
|
35
|
+
"@e280/comrade": "^0.0.0-23",
|
|
36
|
+
"@e280/renraku": "^0.5.0-29",
|
|
37
|
+
"@e280/stz": "^0.0.0-34",
|
|
38
|
+
"@huggingface/transformers": "^3.7.1",
|
|
38
39
|
"comrade": "^0.0.3",
|
|
39
|
-
"
|
|
40
|
+
"gl-transitions": "^1.43.0",
|
|
41
|
+
"gsap": "^3.13.0",
|
|
42
|
+
"mediabunny": "^1.14.3",
|
|
40
43
|
"mp4-muxer": "^5.2.1",
|
|
41
44
|
"pixi.js": "^8.10.1",
|
|
42
45
|
"wavesurfer.js": "^7.10.0",
|
package/s/context.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Driver} from "./driver/driver.js"
|
|
2
2
|
|
|
3
|
-
const workerUrl = new URL("../driver/driver.worker.bundle.js", import.meta.url)
|
|
3
|
+
const workerUrl = new URL("../driver/driver.worker.bundle.min.js", import.meta.url)
|
|
4
4
|
|
|
5
5
|
export const context = {
|
|
6
6
|
driver: Driver.setup({workerUrl})
|
package/s/demo/demo.bundle.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {context} from "../context.js"
|
|
3
3
|
import {waveformTest} from "./routines/waveform-test.js"
|
|
4
4
|
import {filmstripTest} from "./routines/filmstrip-test.js"
|
|
5
|
+
import {transcriberTest} from "./routines/transcriber-test.js"
|
|
5
6
|
import {setupTranscodeTest} from "./routines/transcode-test.js"
|
|
6
7
|
|
|
7
8
|
const driver = await context.driver
|
|
@@ -14,6 +15,7 @@ fetchButton?.addEventListener("click", startDemoFetch)
|
|
|
14
15
|
importButton?.addEventListener("click", startDemoImport)
|
|
15
16
|
|
|
16
17
|
waveformTest()
|
|
18
|
+
const transcriber = await transcriberTest(driver)
|
|
17
19
|
|
|
18
20
|
// hello world test
|
|
19
21
|
{
|
|
@@ -26,9 +28,11 @@ waveformTest()
|
|
|
26
28
|
async function startDemoImport()
|
|
27
29
|
{
|
|
28
30
|
const [fileHandle] = await window.showOpenFilePicker()
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
+
const file = await fileHandle.getFile()
|
|
32
|
+
const transcode = setupTranscodeTest(driver, file)
|
|
33
|
+
await filmstripTest(file)
|
|
31
34
|
run(transcode, fileHandle.name)
|
|
35
|
+
await transcriber.transcribe(file)
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
async function startDemoFetch()
|
package/s/demo/demo.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Filmstrip} from "../../timeline/parts/filmstrip.js"
|
|
2
2
|
|
|
3
|
-
export async function filmstripTest(
|
|
3
|
+
export async function filmstripTest(file: File) {
|
|
4
4
|
const rangeSlider = document.querySelector(".range") as HTMLInputElement
|
|
5
5
|
const rangeView = document.querySelector(".range-view")!
|
|
6
6
|
const rangeSizeSlider = document.querySelector(".range-size")! as HTMLInputElement
|
|
@@ -10,7 +10,7 @@ export async function filmstripTest(fileHandle: FileSystemFileHandle) {
|
|
|
10
10
|
const FPS_10 = 1000/10 / 1000
|
|
11
11
|
let rangeSize = 0.5
|
|
12
12
|
const filmstrip = await Filmstrip.init(
|
|
13
|
-
|
|
13
|
+
file,
|
|
14
14
|
{
|
|
15
15
|
onChange(tiles) {
|
|
16
16
|
// Sort by time (optional, for clean ordering)
|
|
@@ -10,7 +10,7 @@ export function setupTranscodeTest(driver: Driver, source: DecoderSource) {
|
|
|
10
10
|
const ctx = canvas.getContext("2d")
|
|
11
11
|
|
|
12
12
|
async function run() {
|
|
13
|
-
const
|
|
13
|
+
const video = driver.decodeVideo({
|
|
14
14
|
source,
|
|
15
15
|
async onFrame(frame) {
|
|
16
16
|
const composed = await driver.composite([
|
|
@@ -30,9 +30,11 @@ export function setupTranscodeTest(driver: Driver, source: DecoderSource) {
|
|
|
30
30
|
return composed
|
|
31
31
|
}
|
|
32
32
|
})
|
|
33
|
+
const audio = driver.decodeAudio({source})
|
|
33
34
|
|
|
34
35
|
await driver.encode({
|
|
35
|
-
|
|
36
|
+
video,
|
|
37
|
+
audio,
|
|
36
38
|
config: {
|
|
37
39
|
audio: {codec: "opus", bitrate: 128000},
|
|
38
40
|
video: {codec: "vp9", bitrate: 1000000}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {Driver} from "../../driver/driver.js"
|
|
2
|
+
import {makeTranscriber} from "../../features/speech/transcribe/transcriber.js"
|
|
3
|
+
|
|
4
|
+
export async function transcriberTest(driver: Driver) {
|
|
5
|
+
const transcriber = await makeTranscriber({
|
|
6
|
+
driver,
|
|
7
|
+
spec: {
|
|
8
|
+
model: "onnx-community/whisper-tiny_timestamped",
|
|
9
|
+
device: "webgpu",
|
|
10
|
+
strideLength: 5,
|
|
11
|
+
chunkLength: 30,
|
|
12
|
+
dtype: "fp32"
|
|
13
|
+
},
|
|
14
|
+
workerUrl: new URL("/features/speech/transcribe/worker.bundle.min.js", import.meta.url),
|
|
15
|
+
onLoading({progress, total}) {
|
|
16
|
+
console.log(progress, total, "total")
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
return {
|
|
20
|
+
transcribe: async (file: File) => {
|
|
21
|
+
const result = await transcriber.transcribe({
|
|
22
|
+
source: file,
|
|
23
|
+
language: "english",
|
|
24
|
+
onReport(report) {
|
|
25
|
+
console.log("report", report)
|
|
26
|
+
},
|
|
27
|
+
onTranscription(transcription) {
|
|
28
|
+
console.log("transcript", transcription)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
console.log(result, "transcript result")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {Application, Sprite} from "pixi.js"
|
|
2
|
+
|
|
3
|
+
import {Driver} from "../../driver/driver.js"
|
|
4
|
+
import {DecoderSource} from "../../driver/fns/schematic.js"
|
|
5
|
+
import {makeTransition} from "../../features/transition/transition.js"
|
|
6
|
+
|
|
7
|
+
export async function setupTransitionsTest(driver: Driver, source: DecoderSource) {
|
|
8
|
+
const app = new Application()
|
|
9
|
+
await app.init({width: 300, height: 300, preference: "webgl"})
|
|
10
|
+
const sprite = new Sprite({width: 300, height: 300})
|
|
11
|
+
|
|
12
|
+
app.stage.addChild(sprite)
|
|
13
|
+
|
|
14
|
+
document.body.appendChild(app.canvas)
|
|
15
|
+
const transition = makeTransition({name: "circle", renderer: app.renderer})
|
|
16
|
+
|
|
17
|
+
async function run() {
|
|
18
|
+
const video = driver.decodeVideo({
|
|
19
|
+
source,
|
|
20
|
+
async onFrame(frame) {
|
|
21
|
+
const texture = transition.render({
|
|
22
|
+
from: frame,
|
|
23
|
+
to: frame,
|
|
24
|
+
progress: 0.7,
|
|
25
|
+
width: app.canvas.width,
|
|
26
|
+
height: app.canvas.height
|
|
27
|
+
})
|
|
28
|
+
sprite.texture = texture
|
|
29
|
+
return frame
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
await driver.encode({
|
|
34
|
+
video,
|
|
35
|
+
config: {
|
|
36
|
+
audio: {codec: "opus", bitrate: 128000},
|
|
37
|
+
video: {codec: "vp9", bitrate: 1000000}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {run}
|
|
43
|
+
}
|
package/s/driver/driver.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class Driver {
|
|
|
50
50
|
return await videoTrack?.computeDuration()
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
decodeVideo(input: DecoderInput) {
|
|
54
54
|
let lastFrame: VideoFrame | null = null
|
|
55
55
|
const videoTransform = new TransformStream<VideoFrame, VideoFrame>({
|
|
56
56
|
async transform(chunk, controller) {
|
|
@@ -61,19 +61,27 @@ export class Driver {
|
|
|
61
61
|
lastFrame = frame
|
|
62
62
|
}
|
|
63
63
|
})
|
|
64
|
-
|
|
65
|
-
this.thread.work.decode[tune]({transfer: [videoTransform.writable, audioTransform.writable]})({
|
|
64
|
+
this.thread.work.decodeVideo[tune]({transfer: [videoTransform.writable]})({
|
|
66
65
|
source: input.source,
|
|
67
66
|
video: videoTransform.writable,
|
|
67
|
+
start: input.start,
|
|
68
|
+
end: input.end
|
|
69
|
+
})
|
|
70
|
+
return videoTransform.readable
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
decodeAudio(input: DecoderInput) {
|
|
74
|
+
const audioTransform = new TransformStream<AudioData, AudioData>()
|
|
75
|
+
this.thread.work.decodeAudio[tune]({transfer: [audioTransform.writable]})({
|
|
76
|
+
source: input.source,
|
|
68
77
|
audio: audioTransform.writable,
|
|
78
|
+
start: input.start,
|
|
79
|
+
end: input.end
|
|
69
80
|
})
|
|
70
|
-
return
|
|
71
|
-
audio: audioTransform.readable,
|
|
72
|
-
video: videoTransform.readable
|
|
73
|
-
}
|
|
81
|
+
return audioTransform.readable
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
async encode({
|
|
84
|
+
async encode({video, audio, config}: EncoderInput) {
|
|
77
85
|
const handle = await window.showSaveFilePicker()
|
|
78
86
|
const writable = await handle.createWritable()
|
|
79
87
|
// making bridge because file picker writable is not transferable
|
|
@@ -85,7 +93,7 @@ export class Driver {
|
|
|
85
93
|
await writable.close()
|
|
86
94
|
}
|
|
87
95
|
})
|
|
88
|
-
return await this.thread.work.encode[tune]({transfer: [
|
|
96
|
+
return await this.thread.work.encode[tune]({transfer: [audio ?? [], video ?? [], bridge]})({video, audio, config, bridge})
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
async composite(
|
package/s/driver/fns/host.ts
CHANGED
|
@@ -3,10 +3,11 @@ import {Comrade} from "@e280/comrade"
|
|
|
3
3
|
import {Machina} from "../parts/machina.js"
|
|
4
4
|
import {DriverSchematic} from "./schematic.js"
|
|
5
5
|
|
|
6
|
-
export const setupDriverHost = (machina: Machina) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}))
|
|
6
|
+
export const setupDriverHost = (machina: Machina) => (
|
|
7
|
+
Comrade.host<DriverSchematic>(_shell => ({
|
|
8
|
+
async world() {
|
|
9
|
+
machina.count++
|
|
10
|
+
},
|
|
11
|
+
}))
|
|
12
|
+
)
|
|
12
13
|
|
|
@@ -2,16 +2,26 @@
|
|
|
2
2
|
import {AsSchematic} from "@e280/comrade"
|
|
3
3
|
import type {AudioEncodingConfig, StreamTargetChunk, VideoEncodingConfig} from "mediabunny"
|
|
4
4
|
|
|
5
|
+
import {Mat6} from "../../timeline/utils/matrix.js"
|
|
6
|
+
|
|
5
7
|
export type DriverSchematic = AsSchematic<{
|
|
6
8
|
|
|
7
9
|
// happens on the web worker
|
|
8
10
|
work: {
|
|
9
11
|
hello(): Promise<void>
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
decodeAudio(input: {
|
|
12
14
|
source: DecoderSource
|
|
13
|
-
video: WritableStream<VideoFrame>
|
|
14
15
|
audio: WritableStream<AudioData>
|
|
16
|
+
start?: number
|
|
17
|
+
end?: number
|
|
18
|
+
}): Promise<void>
|
|
19
|
+
|
|
20
|
+
decodeVideo(input: {
|
|
21
|
+
source: DecoderSource
|
|
22
|
+
video: WritableStream<VideoFrame>
|
|
23
|
+
start?: number
|
|
24
|
+
end?: number
|
|
15
25
|
}): Promise<void>
|
|
16
26
|
|
|
17
27
|
encode(input: EncoderInput & {bridge: WritableStream<StreamTargetChunk>}): Promise<void>
|
|
@@ -26,20 +36,22 @@ export type DriverSchematic = AsSchematic<{
|
|
|
26
36
|
}>
|
|
27
37
|
|
|
28
38
|
export interface EncoderInput {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
video?: ReadableStream<VideoFrame>
|
|
40
|
+
audio?: ReadableStream<AudioData>
|
|
41
|
+
config: RenderConfig
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RenderConfig {
|
|
45
|
+
video: VideoEncodingConfig
|
|
46
|
+
audio: AudioEncodingConfig
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
export type DecoderSource =
|
|
49
|
+
export type DecoderSource = Blob | string | URL
|
|
40
50
|
|
|
41
51
|
export interface DecoderInput {
|
|
42
52
|
source: DecoderSource
|
|
53
|
+
start?: number
|
|
54
|
+
end?: number
|
|
43
55
|
onFrame?: (frame: VideoFrame) => Promise<VideoFrame>
|
|
44
56
|
}
|
|
45
57
|
|
|
@@ -59,25 +71,36 @@ export interface MuxOpts {
|
|
|
59
71
|
|
|
60
72
|
export type Composition = Layer | (Layer | Composition)[]
|
|
61
73
|
|
|
62
|
-
export type Transform = {
|
|
63
|
-
x?: number
|
|
64
|
-
y?: number
|
|
65
|
-
scale?: number
|
|
66
|
-
opacity?: number
|
|
67
|
-
anchor?: number
|
|
68
|
-
}
|
|
69
|
-
|
|
70
74
|
export type TextLayer = {
|
|
71
75
|
kind: 'text'
|
|
72
76
|
content: string
|
|
73
77
|
fontSize?: number
|
|
74
78
|
color?: string
|
|
75
|
-
|
|
79
|
+
matrix?: Mat6
|
|
80
|
+
}
|
|
76
81
|
|
|
77
82
|
export type ImageLayer = {
|
|
78
83
|
kind: 'image'
|
|
79
84
|
frame: VideoFrame
|
|
80
|
-
|
|
85
|
+
matrix?: Mat6
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type TransitionLayer = {
|
|
89
|
+
kind: 'transition'
|
|
90
|
+
name: string
|
|
91
|
+
progress: number
|
|
92
|
+
from: VideoFrame
|
|
93
|
+
to: VideoFrame
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type GapLayer = {
|
|
97
|
+
kind: 'gap'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type Audio = {
|
|
101
|
+
kind: "audio"
|
|
102
|
+
data: AudioData
|
|
103
|
+
}
|
|
81
104
|
|
|
82
|
-
export type Layer = TextLayer | ImageLayer
|
|
105
|
+
export type Layer = TextLayer | ImageLayer | TransitionLayer | GapLayer
|
|
83
106
|
|