@omnimedia/omnitool 1.1.0-1 → 1.1.0-100
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 +556 -72
- package/package.json +20 -15
- package/s/context.ts +0 -7
- package/s/demo/demo.bundle.ts +104 -39
- package/s/demo/demo.css +246 -11
- package/s/demo/routines/export-test.ts +16 -0
- package/s/demo/routines/filmstrip-test.ts +23 -19
- package/s/demo/routines/load-video.ts +2 -3
- package/s/demo/routines/playback-test.ts +61 -0
- package/s/demo/routines/timeline-setup.ts +81 -0
- package/s/demo/routines/transcode-test.ts +21 -5
- 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 +35 -8
- package/s/driver/driver-worker.ts +9 -0
- package/s/driver/driver.test.ts +1 -1
- package/s/driver/driver.ts +52 -43
- package/s/driver/fns/host.ts +7 -6
- package/s/driver/fns/schematic.ts +69 -25
- package/s/driver/fns/work.ts +102 -214
- package/s/driver/parts/compositor.ts +319 -0
- package/s/driver/parts/machina.ts +19 -20
- package/s/driver/utils/find-pixi-filter.ts +24 -0
- package/s/driver/utils/load-decoder-source.ts +3 -4
- package/s/features/bg-remover/bg-remover.ts +26 -0
- package/s/features/bg-remover/default-spec.ts +11 -0
- package/s/features/bg-remover/types.ts +27 -0
- package/s/features/bg-remover/worker.bundle.ts +52 -0
- package/s/features/parts/expose-errors.ts +41 -0
- package/s/features/parts/load-pipe.ts +17 -0
- package/s/features/parts/types.ts +19 -0
- package/s/features/speech/transcribe/default-spec.ts +11 -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 +76 -0
- package/s/features/speech/transcribe/worker.bundle.ts +42 -0
- package/s/features/transition/parts/fragment.ts +24 -0
- package/s/features/transition/parts/types.ts +27 -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 +103 -20
- package/s/index.ts +1 -0
- package/s/tests.bundle.ts +11 -0
- package/s/tests.html.ts +28 -0
- package/s/timeline/index.ts +17 -1
- package/s/timeline/parts/animations/make.ts +38 -0
- package/s/timeline/parts/animations/presets.ts +138 -0
- package/s/timeline/parts/animations/properties.ts +30 -0
- package/s/timeline/parts/animations/registry.ts +13 -0
- package/s/timeline/parts/animations/types.ts +80 -0
- package/s/timeline/parts/basics.ts +1 -1
- package/s/timeline/parts/captions.ts +91 -0
- package/s/timeline/parts/filmstrip.ts +43 -16
- package/s/timeline/parts/filters.ts +453 -0
- package/s/timeline/parts/item.ts +124 -11
- package/s/timeline/parts/media.ts +43 -1
- package/s/timeline/parts/resource-pool.ts +8 -5
- package/s/timeline/parts/resource.ts +3 -0
- package/s/timeline/parts/transitions.ts +102 -0
- package/s/timeline/parts/waveform/parts/collect.ts +72 -0
- package/s/timeline/parts/waveform/parts/render.ts +45 -0
- package/s/timeline/parts/waveform/parts/types.ts +24 -0
- package/s/timeline/parts/waveform/waveform.ts +161 -0
- package/s/timeline/renderers/export/parts/audio-gain.ts +17 -0
- package/s/timeline/renderers/export/parts/audio-mix.ts +133 -0
- package/s/timeline/renderers/export/parts/cursor.ts +291 -0
- package/s/timeline/renderers/export/parts/produce-audio.ts +64 -0
- package/s/timeline/renderers/export/parts/produce-video.ts +49 -0
- package/s/timeline/renderers/export/parts/resamplers.ts +48 -0
- package/s/timeline/renderers/export/produce.ts +28 -0
- package/s/timeline/renderers/parts/handy.ts +441 -0
- package/s/timeline/renderers/parts/samplers/audio/parts/find.ts +19 -0
- package/s/timeline/renderers/parts/samplers/audio/parts/init.ts +60 -0
- package/s/timeline/renderers/parts/samplers/audio/parts/sink.ts +38 -0
- package/s/timeline/renderers/parts/samplers/audio/parts/types.ts +16 -0
- package/s/timeline/renderers/parts/samplers/audio/sampler.ts +35 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/defaults.ts +23 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/image-sink.ts +51 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/sample.ts +99 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/sequence.ts +97 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/transition.ts +28 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/types.ts +11 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/video-sink.ts +38 -0
- package/s/timeline/renderers/parts/samplers/visual/sampler.ts +31 -0
- package/s/timeline/renderers/parts/schedulers.ts +96 -0
- package/s/timeline/renderers/player/parts/playback.ts +213 -0
- package/s/timeline/renderers/player/player.ts +86 -0
- package/s/timeline/renderers/renderers.test.ts +403 -0
- package/s/timeline/sugar/helpers.ts +239 -0
- package/s/timeline/sugar/o.ts +443 -48
- package/s/timeline/sugar/omni.test.ts +210 -0
- package/s/timeline/sugar/omni.ts +38 -12
- package/s/timeline/types.ts +62 -0
- package/s/timeline/utils/anim.ts +63 -0
- package/s/timeline/utils/checksum.ts +5 -2
- package/s/timeline/utils/datafile.ts +15 -4
- package/s/timeline/utils/dummy-data.ts +3 -3
- package/s/timeline/utils/matrix.ts +54 -0
- package/s/timeline/utils/terps.ts +81 -0
- package/s/units/fps.ts +8 -0
- package/s/units/ms.ts +8 -0
- package/s/units/seconds.ts +8 -0
- package/x/WebGLRenderer-4CHIZDHY.js +2 -0
- package/x/WebGLRenderer-4CHIZDHY.js.map +7 -0
- package/x/WebGPURenderer-O6WXU2QR.js +2 -0
- package/x/WebGPURenderer-O6WXU2QR.js.map +7 -0
- package/x/browserAll-WNIOTNNP.js +2 -0
- package/x/browserAll-WNIOTNNP.js.map +7 -0
- package/x/chunk-23FOBGX6.js +2 -0
- package/x/chunk-23FOBGX6.js.map +7 -0
- package/x/chunk-73XOWA4F.js +393 -0
- package/x/chunk-73XOWA4F.js.map +7 -0
- package/x/chunk-IAWJKNX5.js +42 -0
- package/x/chunk-IAWJKNX5.js.map +7 -0
- package/x/chunk-KCMVLWBS.js +157 -0
- package/x/chunk-KCMVLWBS.js.map +7 -0
- package/x/chunk-MR32SQ27.js +2 -0
- package/x/chunk-MR32SQ27.js.map +7 -0
- package/x/chunk-VCUJJYRJ.js +327 -0
- package/x/chunk-VCUJJYRJ.js.map +7 -0
- package/x/chunk-XNIZ4L5W.js +269 -0
- package/x/chunk-XNIZ4L5W.js.map +7 -0
- package/x/chunk-ZLGNQFUI.js +15 -0
- package/x/chunk-ZLGNQFUI.js.map +7 -0
- package/x/context.d.ts +1 -4
- package/x/context.js +1 -5
- package/x/context.js.map +1 -1
- package/x/demo/WebGLRenderer-RSJAHIG2.js +2 -0
- package/x/demo/WebGLRenderer-RSJAHIG2.js.map +7 -0
- package/x/demo/WebGPURenderer-MGFAJCYY.js +2 -0
- package/x/demo/WebGPURenderer-MGFAJCYY.js.map +7 -0
- package/x/demo/browserAll-PTRBXBRP.js +2 -0
- package/x/demo/browserAll-PTRBXBRP.js.map +7 -0
- package/x/demo/chunk-CUYOGHWU.js +42 -0
- package/x/demo/chunk-CUYOGHWU.js.map +7 -0
- package/x/demo/chunk-DGTDNJ7W.js +2 -0
- package/x/demo/chunk-DGTDNJ7W.js.map +7 -0
- package/x/demo/chunk-FZ5BYF63.js +15 -0
- package/x/demo/chunk-FZ5BYF63.js.map +7 -0
- package/x/demo/chunk-KWN4NNES.js +269 -0
- package/x/demo/chunk-KWN4NNES.js.map +7 -0
- package/x/demo/chunk-OJ3FPXW7.js +157 -0
- package/x/demo/chunk-OJ3FPXW7.js.map +7 -0
- package/x/demo/chunk-PSLUOGTZ.js +393 -0
- package/x/demo/chunk-PSLUOGTZ.js.map +7 -0
- package/x/demo/chunk-VLCVEIFU.js +327 -0
- package/x/demo/chunk-VLCVEIFU.js.map +7 -0
- package/x/demo/chunk-ZWCPT5FR.js +2 -0
- package/x/demo/chunk-ZWCPT5FR.js.map +7 -0
- package/x/demo/demo.bundle.js +94 -36
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +7359 -107
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/demo.css +246 -11
- package/x/demo/routines/export-test.d.ts +2 -0
- package/x/demo/routines/export-test.js +10 -0
- package/x/demo/routines/export-test.js.map +1 -0
- package/x/demo/routines/filmstrip-test.d.ts +1 -1
- package/x/demo/routines/filmstrip-test.js +21 -18
- package/x/demo/routines/filmstrip-test.js.map +1 -1
- package/x/demo/routines/load-video.d.ts +1 -1
- package/x/demo/routines/load-video.js +1 -2
- package/x/demo/routines/load-video.js.map +1 -1
- package/x/demo/routines/playback-test.d.ts +2 -0
- package/x/demo/routines/playback-test.js +51 -0
- package/x/demo/routines/playback-test.js.map +1 -0
- package/x/demo/routines/timeline-setup.d.ts +6 -0
- package/x/demo/routines/timeline-setup.js +59 -0
- package/x/demo/routines/timeline-setup.js.map +1 -0
- package/x/demo/routines/transcode-test.js +17 -5
- 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/demo/routines/waveform-test.d.ts +2 -1
- package/x/demo/routines/waveform-test.js +29 -8
- package/x/demo/routines/waveform-test.js.map +1 -1
- package/x/demo/webworkerAll-JENRT6BT.js +2 -0
- package/x/demo/webworkerAll-JENRT6BT.js.map +7 -0
- package/x/driver/driver-worker.d.ts +1 -0
- package/x/driver/driver-worker.js +6 -0
- package/x/driver/driver-worker.js.map +1 -0
- package/x/driver/driver.d.ts +24 -9
- package/x/driver/driver.js +51 -40
- package/x/driver/driver.js.map +1 -1
- package/x/driver/driver.test.js +1 -1
- package/x/driver/driver.test.js.map +1 -1
- package/x/driver/driver.worker.bundle.min.js +137 -1137
- package/x/driver/driver.worker.bundle.min.js.map +4 -4
- package/x/driver/fns/host.d.ts +12 -4
- package/x/driver/fns/host.js +3 -3
- package/x/driver/fns/host.js.map +1 -1
- package/x/driver/fns/schematic.d.ts +65 -25
- package/x/driver/fns/work.d.ts +14 -7
- package/x/driver/fns/work.js +83 -174
- package/x/driver/fns/work.js.map +1 -1
- package/x/driver/parts/compositor.d.ts +39 -0
- package/x/driver/parts/compositor.js +264 -0
- package/x/driver/parts/compositor.js.map +1 -0
- package/x/driver/parts/machina.d.ts +0 -20
- package/x/driver/parts/machina.js +6 -10
- package/x/driver/parts/machina.js.map +1 -1
- package/x/driver/utils/find-pixi-filter.d.ts +5 -0
- package/x/driver/utils/find-pixi-filter.js +13 -0
- package/x/driver/utils/find-pixi-filter.js.map +1 -0
- 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/bg-remover/bg-remover.d.ts +5 -0
- package/x/features/bg-remover/bg-remover.js +18 -0
- package/x/features/bg-remover/bg-remover.js.map +1 -0
- package/x/features/bg-remover/default-spec.d.ts +2 -0
- package/x/features/bg-remover/default-spec.js +6 -0
- package/x/features/bg-remover/default-spec.js.map +1 -0
- package/x/features/bg-remover/types.d.ts +20 -0
- package/x/features/bg-remover/types.js +2 -0
- package/x/features/bg-remover/types.js.map +1 -0
- package/x/features/bg-remover/worker.bundle.js +39 -0
- package/x/features/bg-remover/worker.bundle.js.map +1 -0
- package/x/features/bg-remover/worker.bundle.min.js +2916 -0
- package/x/features/bg-remover/worker.bundle.min.js.map +7 -0
- package/x/features/parts/expose-errors.d.ts +3 -0
- package/x/features/parts/expose-errors.js +32 -0
- package/x/features/parts/expose-errors.js.map +1 -0
- package/x/features/parts/load-pipe.d.ts +2 -0
- package/x/features/parts/load-pipe.js +13 -0
- package/x/features/parts/load-pipe.js.map +1 -0
- package/x/features/parts/types.d.ts +15 -0
- package/x/features/parts/types.js +2 -0
- package/x/features/parts/types.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/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 +59 -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.js +35 -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 +1 -0
- package/x/index.html +349 -30
- package/x/index.html.js +103 -19
- package/x/index.html.js.map +1 -1
- package/x/index.js +1 -0
- package/x/index.js.map +1 -1
- package/x/tests.bundle.d.ts +1 -0
- package/x/tests.bundle.js +8 -0
- package/x/tests.bundle.js.map +1 -0
- package/x/tests.bundle.min.js +7374 -0
- package/x/tests.bundle.min.js.map +7 -0
- package/x/tests.html +316 -0
- package/x/tests.html.d.ts +2 -0
- package/x/tests.html.js +22 -0
- package/x/tests.html.js.map +1 -0
- package/x/timeline/index.d.ts +16 -0
- package/x/timeline/index.js +16 -0
- package/x/timeline/index.js.map +1 -1
- package/x/timeline/parts/animations/make.d.ts +3 -0
- package/x/timeline/parts/animations/make.js +29 -0
- package/x/timeline/parts/animations/make.js.map +1 -0
- package/x/timeline/parts/animations/presets.d.ts +170 -0
- package/x/timeline/parts/animations/presets.js +135 -0
- package/x/timeline/parts/animations/presets.js.map +1 -0
- package/x/timeline/parts/animations/properties.d.ts +84 -0
- package/x/timeline/parts/animations/properties.js +25 -0
- package/x/timeline/parts/animations/properties.js.map +1 -0
- package/x/timeline/parts/animations/registry.d.ts +218 -0
- package/x/timeline/parts/animations/registry.js +11 -0
- package/x/timeline/parts/animations/registry.js.map +1 -0
- package/x/timeline/parts/animations/types.d.ts +60 -0
- package/x/timeline/parts/animations/types.js +2 -0
- package/x/timeline/parts/animations/types.js.map +1 -0
- package/x/timeline/parts/basics.d.ts +1 -1
- package/x/timeline/parts/captions.d.ts +41 -0
- package/x/timeline/parts/captions.js +55 -0
- package/x/timeline/parts/captions.js.map +1 -0
- package/x/timeline/parts/filmstrip.d.ts +4 -3
- package/x/timeline/parts/filmstrip.js +29 -10
- package/x/timeline/parts/filmstrip.js.map +1 -1
- package/x/timeline/parts/filters.d.ts +108 -0
- package/x/timeline/parts/filters.js +340 -0
- package/x/timeline/parts/filters.js.map +1 -0
- package/x/timeline/parts/item.d.ts +106 -12
- package/x/timeline/parts/item.js +11 -7
- package/x/timeline/parts/item.js.map +1 -1
- package/x/timeline/parts/media.d.ts +6 -0
- package/x/timeline/parts/media.js +35 -1
- package/x/timeline/parts/media.js.map +1 -1
- package/x/timeline/parts/resource-pool.d.ts +3 -0
- package/x/timeline/parts/resource-pool.js +7 -4
- package/x/timeline/parts/resource-pool.js.map +1 -1
- package/x/timeline/parts/resource.d.ts +3 -0
- package/x/timeline/parts/transitions.d.ts +15 -0
- package/x/timeline/parts/transitions.js +81 -0
- package/x/timeline/parts/transitions.js.map +1 -0
- package/x/timeline/parts/waveform/parts/collect.d.ts +11 -0
- package/x/timeline/parts/waveform/parts/collect.js +56 -0
- package/x/timeline/parts/waveform/parts/collect.js.map +1 -0
- package/x/timeline/parts/waveform/parts/render.d.ts +5 -0
- package/x/timeline/parts/waveform/parts/render.js +29 -0
- package/x/timeline/parts/waveform/parts/render.js.map +1 -0
- package/x/timeline/parts/waveform/parts/types.d.ts +21 -0
- package/x/timeline/parts/waveform/parts/types.js +2 -0
- package/x/timeline/parts/waveform/parts/types.js.map +1 -0
- package/x/timeline/parts/waveform/waveform.d.ts +19 -0
- package/x/timeline/parts/waveform/waveform.js +133 -0
- package/x/timeline/parts/waveform/waveform.js.map +1 -0
- package/x/timeline/renderers/export/parts/audio-gain.d.ts +1 -0
- package/x/timeline/renderers/export/parts/audio-gain.js +13 -0
- package/x/timeline/renderers/export/parts/audio-gain.js.map +1 -0
- package/x/timeline/renderers/export/parts/audio-mix.d.ts +21 -0
- package/x/timeline/renderers/export/parts/audio-mix.js +89 -0
- package/x/timeline/renderers/export/parts/audio-mix.js.map +1 -0
- package/x/timeline/renderers/export/parts/cursor.d.ts +35 -0
- package/x/timeline/renderers/export/parts/cursor.js +236 -0
- package/x/timeline/renderers/export/parts/cursor.js.map +1 -0
- package/x/timeline/renderers/export/parts/produce-audio.d.ts +6 -0
- package/x/timeline/renderers/export/parts/produce-audio.js +41 -0
- package/x/timeline/renderers/export/parts/produce-audio.js.map +1 -0
- package/x/timeline/renderers/export/parts/produce-video.d.ts +10 -0
- package/x/timeline/renderers/export/parts/produce-video.js +26 -0
- package/x/timeline/renderers/export/parts/produce-video.js.map +1 -0
- package/x/timeline/renderers/export/parts/resamplers.d.ts +12 -0
- package/x/timeline/renderers/export/parts/resamplers.js +29 -0
- package/x/timeline/renderers/export/parts/resamplers.js.map +1 -0
- package/x/timeline/renderers/export/produce.d.ts +13 -0
- package/x/timeline/renderers/export/produce.js +15 -0
- package/x/timeline/renderers/export/produce.js.map +1 -0
- package/x/timeline/renderers/parts/handy.d.ts +38 -0
- package/x/timeline/renderers/parts/handy.js +263 -0
- package/x/timeline/renderers/parts/handy.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/find.d.ts +6 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/find.js +15 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/find.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/init.d.ts +5 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/init.js +40 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/init.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/sink.d.ts +8 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/sink.js +24 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/sink.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/types.d.ts +14 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/types.js +2 -0
- package/x/timeline/renderers/parts/samplers/audio/parts/types.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/audio/sampler.d.ts +11 -0
- package/x/timeline/renderers/parts/samplers/audio/sampler.js +22 -0
- package/x/timeline/renderers/parts/samplers/audio/sampler.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/defaults.d.ts +8 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/defaults.js +14 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/defaults.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/image-sink.d.ts +11 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/image-sink.js +36 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/image-sink.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.d.ts +9 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.js +70 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sequence.d.ts +6 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sequence.js +63 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sequence.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/transition.d.ts +3 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/transition.js +18 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/transition.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/types.d.ts +9 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/types.js +2 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/types.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/video-sink.d.ts +8 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/video-sink.js +24 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/video-sink.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/sampler.d.ts +7 -0
- package/x/timeline/renderers/parts/samplers/visual/sampler.js +20 -0
- package/x/timeline/renderers/parts/samplers/visual/sampler.js.map +1 -0
- package/x/timeline/renderers/parts/schedulers.d.ts +17 -0
- package/x/timeline/renderers/parts/schedulers.js +64 -0
- package/x/timeline/renderers/parts/schedulers.js.map +1 -0
- package/x/timeline/renderers/player/parts/playback.d.ts +39 -0
- package/x/timeline/renderers/player/parts/playback.js +160 -0
- package/x/timeline/renderers/player/parts/playback.js.map +1 -0
- package/x/timeline/renderers/player/player.d.ts +27 -0
- package/x/timeline/renderers/player/player.js +64 -0
- package/x/timeline/renderers/player/player.js.map +1 -0
- package/x/timeline/renderers/renderers.test.d.ts +33 -0
- package/x/timeline/renderers/renderers.test.js +321 -0
- package/x/timeline/renderers/renderers.test.js.map +1 -0
- package/x/timeline/sugar/helpers.d.ts +72 -0
- package/x/timeline/sugar/helpers.js +122 -0
- package/x/timeline/sugar/helpers.js.map +1 -0
- package/x/timeline/sugar/o.d.ts +59 -8
- package/x/timeline/sugar/o.js +326 -40
- package/x/timeline/sugar/o.js.map +1 -1
- package/x/timeline/sugar/omni.d.ts +11 -2
- package/x/timeline/sugar/omni.js +30 -9
- package/x/timeline/sugar/omni.js.map +1 -1
- package/x/timeline/sugar/omni.test.d.ts +27 -0
- package/x/timeline/sugar/omni.test.js +128 -0
- package/x/timeline/sugar/omni.test.js.map +1 -0
- package/x/timeline/types.d.ts +37 -0
- package/x/timeline/types.js +2 -0
- package/x/timeline/types.js.map +1 -0
- package/x/timeline/utils/anim.d.ts +3 -0
- package/x/timeline/utils/anim.js +40 -0
- package/x/timeline/utils/anim.js.map +1 -0
- package/x/timeline/utils/checksum.d.ts +3 -2
- package/x/timeline/utils/checksum.js +2 -1
- package/x/timeline/utils/checksum.js.map +1 -1
- package/x/timeline/utils/datafile.d.ts +5 -3
- package/x/timeline/utils/datafile.js +18 -5
- package/x/timeline/utils/datafile.js.map +1 -1
- package/x/timeline/utils/dummy-data.d.ts +1 -2
- package/x/timeline/utils/dummy-data.js +4 -2
- package/x/timeline/utils/dummy-data.js.map +1 -1
- package/x/timeline/utils/matrix.d.ts +17 -0
- package/x/timeline/utils/matrix.js +36 -0
- package/x/timeline/utils/matrix.js.map +1 -0
- package/x/timeline/utils/terps.d.ts +11 -0
- package/x/timeline/utils/terps.js +57 -0
- package/x/timeline/utils/terps.js.map +1 -0
- package/x/units/fps.d.ts +6 -0
- package/x/units/fps.js +2 -0
- package/x/units/fps.js.map +1 -0
- package/x/units/ms.d.ts +6 -0
- package/x/units/ms.js +2 -0
- package/x/units/ms.js.map +1 -0
- package/x/units/seconds.d.ts +6 -0
- package/x/units/seconds.js +2 -0
- package/x/units/seconds.js.map +1 -0
- package/x/webworkerAll-RLCTMSDD.js +2 -0
- package/x/webworkerAll-RLCTMSDD.js.map +7 -0
- package/s/tests.test.ts +0 -8
- package/s/timeline/parts/waveform.ts +0 -62
- package/s/timeline/sugar/omni-test.ts +0 -38
- package/x/tests.test.js +0 -6
- package/x/tests.test.js.map +0 -1
- package/x/timeline/parts/waveform.d.ts +0 -8
- package/x/timeline/parts/waveform.js +0 -51
- package/x/timeline/parts/waveform.js.map +0 -1
- package/x/timeline/sugar/omni-test.js +0 -22
- package/x/timeline/sugar/omni-test.js.map +0 -1
- /package/x/{tests.test.d.ts → features/bg-remover/worker.bundle.d.ts} +0 -0
- /package/x/{timeline/sugar/omni-test.d.ts → features/speech/transcribe/worker.bundle.d.ts} +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { renderTile } from "./parts/render.js";
|
|
2
|
+
import { collectPeakLevels } from "./parts/collect.js";
|
|
3
|
+
const MAX_TILE_WIDTH = 4096;
|
|
4
|
+
export class Waveform {
|
|
5
|
+
#tiles = new Map();
|
|
6
|
+
#activeRange = [0, 0];
|
|
7
|
+
#visibleRange = [0, 0];
|
|
8
|
+
#zoom;
|
|
9
|
+
#levels;
|
|
10
|
+
#onChange;
|
|
11
|
+
#updateQueued = false;
|
|
12
|
+
color;
|
|
13
|
+
duration;
|
|
14
|
+
tileSize;
|
|
15
|
+
tileHeight;
|
|
16
|
+
preloadMargin;
|
|
17
|
+
constructor(levels, duration, options) {
|
|
18
|
+
this.#levels = levels;
|
|
19
|
+
this.duration = duration;
|
|
20
|
+
this.tileSize = options.tileSize ?? 1;
|
|
21
|
+
this.#zoom = options.zoom ?? ((options.tileWidth ?? 256) / this.tileSize);
|
|
22
|
+
this.tileHeight = options.tileHeight ?? 96;
|
|
23
|
+
this.preloadMargin = options.preloadMargin ?? 2;
|
|
24
|
+
this.color = options.color ?? "rgb(3, 148, 129)";
|
|
25
|
+
this.#onChange = options.onChange;
|
|
26
|
+
}
|
|
27
|
+
static async init(driver, source, options = {}) {
|
|
28
|
+
const { duration, levels } = await collectPeakLevels(driver, source);
|
|
29
|
+
return new Waveform(levels, duration, options);
|
|
30
|
+
}
|
|
31
|
+
/** Waveform render density in pixels per second. */
|
|
32
|
+
set zoom(pixelsPerSecond) {
|
|
33
|
+
const next = Math.max(1, pixelsPerSecond);
|
|
34
|
+
if (next === this.#zoom)
|
|
35
|
+
return;
|
|
36
|
+
this.#zoom = next;
|
|
37
|
+
this.#tiles.clear();
|
|
38
|
+
this.#queueUpdate();
|
|
39
|
+
}
|
|
40
|
+
get zoom() {
|
|
41
|
+
return this.#zoom;
|
|
42
|
+
}
|
|
43
|
+
get range() {
|
|
44
|
+
return this.#visibleRange;
|
|
45
|
+
}
|
|
46
|
+
#computeActiveRange([start, end], margin = 1) {
|
|
47
|
+
const visibleSize = end - start;
|
|
48
|
+
return [
|
|
49
|
+
Math.max(0, start - visibleSize * margin),
|
|
50
|
+
Math.min(this.duration, end + visibleSize * margin),
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
set range(visibleRange) {
|
|
54
|
+
this.#visibleRange = visibleRange;
|
|
55
|
+
const [visibleStart, visibleEnd] = visibleRange;
|
|
56
|
+
const visibleSize = visibleEnd - visibleStart;
|
|
57
|
+
const [activeStart, activeEnd] = this.#activeRange;
|
|
58
|
+
const leftBuffered = activeStart > 0;
|
|
59
|
+
const rightBuffered = activeEnd < this.duration;
|
|
60
|
+
const leftSettled = !leftBuffered || visibleStart >= activeStart + visibleSize;
|
|
61
|
+
const rightSettled = !rightBuffered || visibleEnd <= activeEnd - visibleSize;
|
|
62
|
+
if (leftSettled && rightSettled)
|
|
63
|
+
return;
|
|
64
|
+
this.#activeRange = this.#computeActiveRange(visibleRange, this.preloadMargin);
|
|
65
|
+
this.#queueUpdate();
|
|
66
|
+
}
|
|
67
|
+
#queueUpdate() {
|
|
68
|
+
if (this.#updateQueued)
|
|
69
|
+
return;
|
|
70
|
+
this.#updateQueued = true;
|
|
71
|
+
queueMicrotask(() => {
|
|
72
|
+
this.#updateQueued = false;
|
|
73
|
+
this.#generateTiles();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
#generateTiles() {
|
|
77
|
+
const [rangeStart, rangeEnd] = this.#activeRange;
|
|
78
|
+
const neededStarts = new Set();
|
|
79
|
+
const level = this.#levelForZoom();
|
|
80
|
+
const firstStart = Math.max(0, Math.floor(rangeStart / this.tileSize) * this.tileSize);
|
|
81
|
+
const lastStart = Math.min(this.duration, rangeEnd);
|
|
82
|
+
for (let startTime = firstStart; startTime <= lastStart; startTime += this.tileSize) {
|
|
83
|
+
neededStarts.add(startTime);
|
|
84
|
+
}
|
|
85
|
+
for (const startTime of neededStarts) {
|
|
86
|
+
if (!this.#tiles.has(startTime)) {
|
|
87
|
+
const endTime = Math.min(startTime + this.tileSize, this.duration);
|
|
88
|
+
this.#tiles.set(startTime, this.#buildTileData(startTime, endTime, level));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const startTime of this.#tiles.keys()) {
|
|
92
|
+
if (!neededStarts.has(startTime))
|
|
93
|
+
this.#tiles.delete(startTime);
|
|
94
|
+
}
|
|
95
|
+
this.#emit();
|
|
96
|
+
}
|
|
97
|
+
#buildTileData(startTime, endTime, level) {
|
|
98
|
+
const peaks = this.#slicePeaks(level, startTime, endTime);
|
|
99
|
+
return {
|
|
100
|
+
startTime,
|
|
101
|
+
endTime,
|
|
102
|
+
peaks,
|
|
103
|
+
canvas: renderTile(peaks, {
|
|
104
|
+
width: this.#tilePixelWidth(startTime, endTime),
|
|
105
|
+
height: this.tileHeight,
|
|
106
|
+
color: this.color,
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
#levelForZoom() {
|
|
111
|
+
return this.#levels.find(level => level.peaksPerSecond >= this.#zoom)
|
|
112
|
+
?? this.#levels[this.#levels.length - 1];
|
|
113
|
+
}
|
|
114
|
+
#slicePeaks(level, startTime, endTime) {
|
|
115
|
+
if (!level.peaksPerSecond)
|
|
116
|
+
return new Float32Array();
|
|
117
|
+
const from = Math.max(0, Math.floor(startTime * level.peaksPerSecond));
|
|
118
|
+
const to = Math.max(from + 1, Math.min(level.peaks.length, Math.ceil(endTime * level.peaksPerSecond)));
|
|
119
|
+
return level.peaks.slice(from, to);
|
|
120
|
+
}
|
|
121
|
+
#tilePixelWidth(startTime, endTime) {
|
|
122
|
+
return Math.min(MAX_TILE_WIDTH, Math.max(1, Math.ceil((endTime - startTime) * this.#zoom)));
|
|
123
|
+
}
|
|
124
|
+
#emit() {
|
|
125
|
+
if (!this.#onChange)
|
|
126
|
+
return;
|
|
127
|
+
this.#onChange([...this.#tiles.values()].sort((a, b) => a.startTime - b.startTime));
|
|
128
|
+
}
|
|
129
|
+
getTiles() {
|
|
130
|
+
return this.#tiles;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=waveform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveform.js","sourceRoot":"","sources":["../../../../s/timeline/parts/waveform/waveform.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAA;AAIpD,MAAM,cAAc,GAAG,IAAI,CAAA;AAE3B,MAAM,OAAO,QAAQ;IACpB,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAA;IAC5C,YAAY,GAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACxC,aAAa,GAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAEzC,KAAK,CAAA;IACL,OAAO,CAAA;IACP,SAAS,CAAA;IACT,aAAa,GAAG,KAAK,CAAA;IAEZ,KAAK,CAAA;IACL,QAAQ,CAAA;IACR,QAAQ,CAAA;IACR,UAAU,CAAA;IACV,aAAa,CAAA;IAEtB,YAAoB,MAA2B,EAAE,QAAgB,EAAE,OAAwB;QAC1F,IAAI,CAAC,OAAO,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AAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACnC,CAAC;IAED,eAAe,CAAC,SAAiB,EAAE,OAAe;QACjD,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5F,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAM;QAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACpF,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACnB,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const applyGainToPlanar: (planes: Float32Array[], gain: number) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// this is mutating fn
|
|
2
|
+
export const applyGainToPlanar = (planes, gain) => {
|
|
3
|
+
if (gain === 1)
|
|
4
|
+
return;
|
|
5
|
+
// planes
|
|
6
|
+
for (const plane of planes) {
|
|
7
|
+
for (let i = 0; i < plane.length; i++) {
|
|
8
|
+
plane[i] *= gain;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// return planes
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=audio-gain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-gain.js","sourceRoot":"","sources":["../../../../../s/timeline/renderers/export/parts/audio-gain.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAChC,MAAsB,EACtB,IAAY,EACX,EAAE;IACH,IAAI,IAAI,KAAK,CAAC;QACb,OAAM;IACP,SAAS;IAET,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;QACjB,CAAC;IACF,CAAC;IAED,gBAAgB;AACjB,CAAC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type AudioPlanesInput = {
|
|
2
|
+
planes: Float32Array[];
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
export type MixedChunk = {
|
|
7
|
+
planar: Float32Array;
|
|
8
|
+
sampleRate: number;
|
|
9
|
+
channels: number;
|
|
10
|
+
frames: number;
|
|
11
|
+
startFrame: number;
|
|
12
|
+
};
|
|
13
|
+
export type AudioMixOptions = {
|
|
14
|
+
chunkFrames?: number;
|
|
15
|
+
clamp?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare class AudioMix {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(options?: AudioMixOptions);
|
|
20
|
+
mix(samples: AsyncIterable<AudioPlanesInput>): AsyncGenerator<MixedChunk>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export class AudioMix {
|
|
2
|
+
#chunkFrames;
|
|
3
|
+
#clamp;
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
this.#chunkFrames = options.chunkFrames ?? 1024;
|
|
6
|
+
this.#clamp = options.clamp ?? true;
|
|
7
|
+
}
|
|
8
|
+
async *mix(samples) {
|
|
9
|
+
const chunkFrames = this.#chunkFrames;
|
|
10
|
+
let sampleRate = null;
|
|
11
|
+
let channels = null;
|
|
12
|
+
const active = [];
|
|
13
|
+
let nextFrame = 0;
|
|
14
|
+
let maxEnd = 0;
|
|
15
|
+
for await (const input of samples) {
|
|
16
|
+
if (channels === null) {
|
|
17
|
+
channels = input.planes.length;
|
|
18
|
+
sampleRate = input.sampleRate;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
if (input.planes.length !== channels)
|
|
22
|
+
throw new Error(`Channel count changed`);
|
|
23
|
+
if (input.sampleRate !== sampleRate)
|
|
24
|
+
throw new Error(`Sample rate changed`);
|
|
25
|
+
}
|
|
26
|
+
const inputStart = Math.round(input.timestamp * sampleRate);
|
|
27
|
+
const frames = input.planes[0]?.length ?? 0;
|
|
28
|
+
while (nextFrame + chunkFrames <= inputStart) {
|
|
29
|
+
yield this.#processChunk(active, nextFrame, channels, sampleRate);
|
|
30
|
+
nextFrame += chunkFrames;
|
|
31
|
+
}
|
|
32
|
+
active.push({
|
|
33
|
+
startFrame: inputStart,
|
|
34
|
+
endFrame: inputStart + frames,
|
|
35
|
+
data: input.planes
|
|
36
|
+
});
|
|
37
|
+
maxEnd = Math.max(maxEnd, inputStart + frames);
|
|
38
|
+
}
|
|
39
|
+
if (channels !== null && sampleRate !== null) {
|
|
40
|
+
while (nextFrame < maxEnd) {
|
|
41
|
+
yield this.#processChunk(active, nextFrame, channels, sampleRate);
|
|
42
|
+
nextFrame += chunkFrames;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
#processChunk(active, currentStartFrame, channels, sampleRate) {
|
|
47
|
+
const chunkFrames = this.#chunkFrames;
|
|
48
|
+
const outputBuffer = new Float32Array(channels * chunkFrames);
|
|
49
|
+
const chunkEnd = currentStartFrame + chunkFrames;
|
|
50
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
51
|
+
const channelOffset = ch * chunkFrames;
|
|
52
|
+
const outChannelView = outputBuffer.subarray(channelOffset, channelOffset + chunkFrames);
|
|
53
|
+
for (const sample of active) {
|
|
54
|
+
const data = sample.data[ch];
|
|
55
|
+
if (!data)
|
|
56
|
+
continue;
|
|
57
|
+
const start = Math.max(currentStartFrame, sample.startFrame);
|
|
58
|
+
const end = Math.min(chunkEnd, sample.endFrame);
|
|
59
|
+
if (start >= end)
|
|
60
|
+
continue;
|
|
61
|
+
const dstIdx = start - currentStartFrame;
|
|
62
|
+
const srcIdx = start - sample.startFrame;
|
|
63
|
+
const len = end - start;
|
|
64
|
+
for (let i = 0; i < len; i++) {
|
|
65
|
+
outChannelView[dstIdx + i] += data[srcIdx + i];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (this.#clamp) {
|
|
69
|
+
for (let i = 0; i < chunkFrames; i++) {
|
|
70
|
+
const v = outChannelView[i];
|
|
71
|
+
outChannelView[i] = v < -1.0 ? -1.0 : (v > 1.0 ? 1.0 : v);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (let i = active.length - 1; i >= 0; i--) {
|
|
76
|
+
if (active[i].endFrame <= chunkEnd) {
|
|
77
|
+
active.splice(i, 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
planar: outputBuffer,
|
|
82
|
+
sampleRate,
|
|
83
|
+
channels,
|
|
84
|
+
frames: chunkFrames,
|
|
85
|
+
startFrame: currentStartFrame
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=audio-mix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-mix.js","sourceRoot":"","sources":["../../../../../s/timeline/renderers/export/parts/audio-mix.ts"],"names":[],"mappings":"AA0BA,MAAM,OAAO,QAAQ;IACX,YAAY,CAAQ;IACpB,MAAM,CAAS;IAExB,YAAY,UAA2B,EAAE;QACxC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAA;QAC/C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,CAAC,GAAG,CAAC,OAAw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ms.js";
|
|
2
|
+
import { Driver } from "../../../../driver/driver.js";
|
|
3
|
+
import { TimelineFile } from "../../../parts/basics.js";
|
|
4
|
+
import { DecoderSource } from "../../../../driver/fns/schematic.js";
|
|
5
|
+
type StreamCursor<T> = {
|
|
6
|
+
next(target: number): Promise<T | undefined>;
|
|
7
|
+
cancel(): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
type VideoFrameCursor = StreamCursor<VideoFrame>;
|
|
10
|
+
declare abstract class BaseVisualSampler {
|
|
11
|
+
#private;
|
|
12
|
+
protected driver: Driver;
|
|
13
|
+
protected resolveMedia: (hash: string) => DecoderSource;
|
|
14
|
+
protected timeline: TimelineFile;
|
|
15
|
+
constructor(driver: Driver, resolveMedia: (hash: string) => DecoderSource, timeline: TimelineFile);
|
|
16
|
+
protected abstract createCursor(source: DecoderSource, startUs: number, endUs: number): VideoFrameCursor;
|
|
17
|
+
protected sample(timecode: Ms): Promise<import("../../../../driver/fns/schematic.js").Layer[]>;
|
|
18
|
+
cancel(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* forward-only frame cursor optimized for export purposes.
|
|
22
|
+
* it uses mediabunny internally so the support for non-clients
|
|
23
|
+
* should be done from mediabunny custom decoder/encoder
|
|
24
|
+
*/
|
|
25
|
+
export declare class CursorVisualSampler extends BaseVisualSampler {
|
|
26
|
+
#private;
|
|
27
|
+
next(timecode: Ms): Promise<import("../../../../driver/fns/schematic.js").Layer[]>;
|
|
28
|
+
protected createCursor(source: DecoderSource, startUs: number, endUs: number): VideoFrameCursor;
|
|
29
|
+
}
|
|
30
|
+
export declare class ReverseCursorVisualSampler extends BaseVisualSampler {
|
|
31
|
+
#private;
|
|
32
|
+
next(timecode: Ms): Promise<import("../../../../driver/fns/schematic.js").Layer[]>;
|
|
33
|
+
protected createCursor(source: DecoderSource, startUs: number, endUs: number): VideoFrameCursor;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { ALL_FORMATS, Input, VideoSampleSink } from "mediabunny";
|
|
2
|
+
import { ms } from "../../../../units/ms.js";
|
|
3
|
+
import { loadDecoderSource } from "../../../../driver/utils/load-decoder-source.js";
|
|
4
|
+
import { createVisualSampler } from "../../parts/samplers/visual/sampler.js";
|
|
5
|
+
class BaseVisualSampler {
|
|
6
|
+
driver;
|
|
7
|
+
resolveMedia;
|
|
8
|
+
timeline;
|
|
9
|
+
#videoCursors = new Map();
|
|
10
|
+
#sampler;
|
|
11
|
+
constructor(driver, resolveMedia, timeline) {
|
|
12
|
+
this.driver = driver;
|
|
13
|
+
this.resolveMedia = resolveMedia;
|
|
14
|
+
this.timeline = timeline;
|
|
15
|
+
this.#sampler = createVisualSampler(this.resolveMedia, (item, time) => {
|
|
16
|
+
const targetUs = toUs(ms(item.start + time));
|
|
17
|
+
let cursor = this.#videoCursors.get(item.id);
|
|
18
|
+
if (!cursor) {
|
|
19
|
+
const source = this.resolveMedia(item.mediaHash);
|
|
20
|
+
const endUs = toUs(ms(item.start + item.duration));
|
|
21
|
+
cursor = this.createCursor(source, targetUs, endUs);
|
|
22
|
+
this.#videoCursors.set(item.id, cursor);
|
|
23
|
+
}
|
|
24
|
+
return cursor.next(targetUs);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
sample(timecode) {
|
|
28
|
+
return this.#sampler.sample(this.timeline, timecode);
|
|
29
|
+
}
|
|
30
|
+
async cancel() {
|
|
31
|
+
await Promise.all([...this.#videoCursors.values()].map(c => c.cancel()));
|
|
32
|
+
this.#videoCursors.clear();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* forward-only frame cursor optimized for export purposes.
|
|
37
|
+
* it uses mediabunny internally so the support for non-clients
|
|
38
|
+
* should be done from mediabunny custom decoder/encoder
|
|
39
|
+
*/
|
|
40
|
+
export class CursorVisualSampler extends BaseVisualSampler {
|
|
41
|
+
#lastTimecode = -Infinity;
|
|
42
|
+
next(timecode) {
|
|
43
|
+
if (timecode < this.#lastTimecode)
|
|
44
|
+
throw new Error(`Forward-only cursor regression: ${timecode}ms < ${this.#lastTimecode}ms`);
|
|
45
|
+
this.#lastTimecode = timecode;
|
|
46
|
+
return this.sample(timecode);
|
|
47
|
+
}
|
|
48
|
+
createCursor(source, startUs, endUs) {
|
|
49
|
+
const video = this.driver.decodeVideo({ source, start: startUs / 1_000_000, end: endUs / 1_000_000 });
|
|
50
|
+
const reader = video.readable.getReader();
|
|
51
|
+
let current = null;
|
|
52
|
+
let nextPromise = null;
|
|
53
|
+
let ended = false;
|
|
54
|
+
const readNext = async () => {
|
|
55
|
+
if (ended)
|
|
56
|
+
return null;
|
|
57
|
+
const { done, value } = await reader.read();
|
|
58
|
+
if (done)
|
|
59
|
+
return (ended = true, null);
|
|
60
|
+
const frame = new VideoFrame(value);
|
|
61
|
+
value.close();
|
|
62
|
+
return frame;
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
async next(targetUs) {
|
|
66
|
+
current ??= await readNext();
|
|
67
|
+
if (!current)
|
|
68
|
+
return undefined;
|
|
69
|
+
while (true) {
|
|
70
|
+
nextPromise ??= readNext();
|
|
71
|
+
const nextFrame = await nextPromise;
|
|
72
|
+
if (!nextFrame)
|
|
73
|
+
return new VideoFrame(current);
|
|
74
|
+
const currentUs = current.timestamp ?? -Infinity;
|
|
75
|
+
const nextUs = nextFrame.timestamp ?? currentUs;
|
|
76
|
+
if (nextUs < targetUs) {
|
|
77
|
+
current.close();
|
|
78
|
+
current = nextFrame;
|
|
79
|
+
nextPromise = null;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const useNext = Math.abs(nextUs - targetUs) < Math.abs(currentUs - targetUs);
|
|
83
|
+
if (useNext) {
|
|
84
|
+
current.close();
|
|
85
|
+
current = nextFrame;
|
|
86
|
+
nextPromise = null;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
return new VideoFrame(current);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
async cancel() {
|
|
93
|
+
const pending = nextPromise;
|
|
94
|
+
nextPromise = null;
|
|
95
|
+
ended = true;
|
|
96
|
+
const buffered = await pending?.catch(() => null);
|
|
97
|
+
buffered?.close();
|
|
98
|
+
current?.close();
|
|
99
|
+
current = null;
|
|
100
|
+
video.cancel();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export class ReverseCursorVisualSampler extends BaseVisualSampler {
|
|
106
|
+
#lastTimecode = Infinity;
|
|
107
|
+
next(timecode) {
|
|
108
|
+
if (timecode > this.#lastTimecode)
|
|
109
|
+
throw new Error(`Reverse-only cursor regression: ${timecode}ms > ${this.#lastTimecode}ms`);
|
|
110
|
+
this.#lastTimecode = timecode;
|
|
111
|
+
return this.sample(timecode);
|
|
112
|
+
}
|
|
113
|
+
createCursor(source, startUs, endUs) {
|
|
114
|
+
const windowUs = 1_000_000;
|
|
115
|
+
const prefetchThreshold = windowUs * 0.5;
|
|
116
|
+
let frames = [];
|
|
117
|
+
let windowStart = Infinity;
|
|
118
|
+
let windowEnd = -Infinity;
|
|
119
|
+
let input = null;
|
|
120
|
+
let sink = null;
|
|
121
|
+
let prefetchPromise = null;
|
|
122
|
+
let activeFetches = 0;
|
|
123
|
+
let idle = Promise.resolve();
|
|
124
|
+
let resolveIdle = null;
|
|
125
|
+
let canceled = false;
|
|
126
|
+
const clear = () => {
|
|
127
|
+
for (const frame of frames)
|
|
128
|
+
frame.close();
|
|
129
|
+
frames = [];
|
|
130
|
+
};
|
|
131
|
+
const startFetch = () => {
|
|
132
|
+
if (activeFetches++ === 0)
|
|
133
|
+
idle = new Promise(resolve => resolveIdle = resolve);
|
|
134
|
+
};
|
|
135
|
+
const endFetch = () => {
|
|
136
|
+
if (--activeFetches === 0) {
|
|
137
|
+
resolveIdle?.();
|
|
138
|
+
resolveIdle = null;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const getSink = async () => {
|
|
142
|
+
if (sink)
|
|
143
|
+
return sink;
|
|
144
|
+
input = new Input({
|
|
145
|
+
source: await loadDecoderSource(source),
|
|
146
|
+
formats: ALL_FORMATS,
|
|
147
|
+
});
|
|
148
|
+
const track = await input.getPrimaryVideoTrack();
|
|
149
|
+
sink = track && await track.canDecode()
|
|
150
|
+
? new VideoSampleSink(track)
|
|
151
|
+
: null;
|
|
152
|
+
return sink;
|
|
153
|
+
};
|
|
154
|
+
const fetchFrames = async (targetUs) => {
|
|
155
|
+
startFetch();
|
|
156
|
+
const wEnd = Math.min(endUs, targetUs + 1);
|
|
157
|
+
const wStart = Math.max(startUs, wEnd - windowUs);
|
|
158
|
+
const newFrames = [];
|
|
159
|
+
const videoSink = await getSink();
|
|
160
|
+
if (videoSink) {
|
|
161
|
+
for await (const sample of videoSink.samples(wStart / 1_000_000, wEnd / 1_000_000)) {
|
|
162
|
+
newFrames.push(sample.toVideoFrame());
|
|
163
|
+
sample.close();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
endFetch();
|
|
167
|
+
return { frames: newFrames, windowStart: wStart, windowEnd: wEnd };
|
|
168
|
+
};
|
|
169
|
+
const loadWindow = async (targetUs) => {
|
|
170
|
+
clear();
|
|
171
|
+
const result = await fetchFrames(targetUs);
|
|
172
|
+
frames = result.frames;
|
|
173
|
+
windowStart = result.windowStart;
|
|
174
|
+
windowEnd = result.windowEnd;
|
|
175
|
+
};
|
|
176
|
+
return {
|
|
177
|
+
async next(targetUs) {
|
|
178
|
+
if (canceled)
|
|
179
|
+
return undefined;
|
|
180
|
+
if (targetUs < windowStart || targetUs > windowEnd) {
|
|
181
|
+
if (prefetchPromise) {
|
|
182
|
+
const prefetched = await prefetchPromise;
|
|
183
|
+
prefetchPromise = null;
|
|
184
|
+
if (canceled) {
|
|
185
|
+
for (const f of prefetched.frames)
|
|
186
|
+
f.close();
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
if (targetUs >= prefetched.windowStart && targetUs <= prefetched.windowEnd) {
|
|
190
|
+
clear();
|
|
191
|
+
frames = prefetched.frames;
|
|
192
|
+
windowStart = prefetched.windowStart;
|
|
193
|
+
windowEnd = prefetched.windowEnd;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
for (const f of prefetched.frames)
|
|
197
|
+
f.close();
|
|
198
|
+
await loadWindow(targetUs);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
await loadWindow(targetUs);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (!prefetchPromise && targetUs < windowStart + prefetchThreshold && windowStart > startUs)
|
|
206
|
+
prefetchPromise = fetchFrames(windowStart - 1);
|
|
207
|
+
let best;
|
|
208
|
+
let bestDistance = Infinity;
|
|
209
|
+
for (const frame of frames) {
|
|
210
|
+
const distance = Math.abs((frame.timestamp ?? targetUs) - targetUs);
|
|
211
|
+
if (distance < bestDistance) {
|
|
212
|
+
best = frame;
|
|
213
|
+
bestDistance = distance;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return best ? new VideoFrame(best) : undefined;
|
|
217
|
+
},
|
|
218
|
+
async cancel() {
|
|
219
|
+
canceled = true;
|
|
220
|
+
const pending = prefetchPromise;
|
|
221
|
+
prefetchPromise = null;
|
|
222
|
+
const prefetched = await pending?.catch(() => null);
|
|
223
|
+
if (prefetched)
|
|
224
|
+
for (const f of prefetched.frames)
|
|
225
|
+
f.close();
|
|
226
|
+
await idle;
|
|
227
|
+
clear();
|
|
228
|
+
input?.dispose();
|
|
229
|
+
input = null;
|
|
230
|
+
sink = null;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const toUs = (ms) => Math.round(ms * 1_000);
|
|
236
|
+
//# sourceMappingURL=cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../../../s/timeline/renderers/export/parts/cursor.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IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YAC/C,CAAC;YAED,KAAK,CAAC,MAAM;gBACX,QAAQ,GAAG,IAAI,CAAA;gBACf,MAAM,OAAO,GAAG,eAAe,CAAA;gBAC/B,eAAe,GAAG,IAAI,CAAA;gBAEtB,MAAM,UAAU,GAAG,MAAM,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;gBACnD,IAAI,UAAU;oBACb,KAAK,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM;wBAAE,CAAC,CAAC,KAAK,EAAE,CAAA;gBAE7C,MAAM,IAAI,CAAA;gBACV,KAAK,EAAE,CAAA;gBACP,KAAK,EAAE,OAAO,EAAE,CAAA;gBAChB,KAAK,GAAG,IAAI,CAAA;gBACZ,IAAI,GAAG,IAAI,CAAA;YACZ,CAAC;SACD,CAAA;IACF,CAAC;CACD;AAED,MAAM,IAAI,GAAG,CAAC,EAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TimelineFile } from "../../../parts/basics.js";
|
|
2
|
+
import { DecoderSource } from "../../../../driver/fns/schematic.js";
|
|
3
|
+
export declare function produceAudio({ timeline, resolveMedia }: {
|
|
4
|
+
timeline: TimelineFile;
|
|
5
|
+
resolveMedia: (hash: string) => DecoderSource;
|
|
6
|
+
}): ReadableStream<AudioData>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AudioMix } from "./audio-mix.js";
|
|
2
|
+
import { ms } from "../../../../units/ms.js";
|
|
3
|
+
import { resampleToPlanar } from "./resamplers.js";
|
|
4
|
+
import { applyGainToPlanar } from "./audio-gain.js";
|
|
5
|
+
import { createAudioSampler } from "../../parts/samplers/audio/sampler.js";
|
|
6
|
+
export function produceAudio({ timeline, resolveMedia }) {
|
|
7
|
+
const mixer = new AudioMix();
|
|
8
|
+
const audio = streamAudio(timeline, resolveMedia);
|
|
9
|
+
const stream = new TransformStream();
|
|
10
|
+
const writer = stream.writable.getWriter();
|
|
11
|
+
async function produce() {
|
|
12
|
+
for await (const chunk of mixer.mix(audio)) {
|
|
13
|
+
const data = new AudioData({
|
|
14
|
+
format: 'f32-planar',
|
|
15
|
+
sampleRate: chunk.sampleRate,
|
|
16
|
+
numberOfFrames: chunk.frames,
|
|
17
|
+
numberOfChannels: chunk.channels,
|
|
18
|
+
timestamp: Math.round((chunk.startFrame / chunk.sampleRate) * 1_000_000),
|
|
19
|
+
data: new Float32Array(chunk.planar)
|
|
20
|
+
});
|
|
21
|
+
await writer.write(data);
|
|
22
|
+
}
|
|
23
|
+
await writer.close();
|
|
24
|
+
}
|
|
25
|
+
produce();
|
|
26
|
+
return stream.readable;
|
|
27
|
+
}
|
|
28
|
+
async function* streamAudio(timeline, resolveMedia) {
|
|
29
|
+
const audioSampler = createAudioSampler(resolveMedia);
|
|
30
|
+
for await (const { sample, timestamp, gain } of audioSampler.sampleAudio(timeline, ms(0))) {
|
|
31
|
+
const { data } = resampleToPlanar(sample, 48000);
|
|
32
|
+
applyGainToPlanar(data, gain);
|
|
33
|
+
yield {
|
|
34
|
+
planes: data,
|
|
35
|
+
sampleRate: 48000,
|
|
36
|
+
timestamp
|
|
37
|
+
};
|
|
38
|
+
sample.close();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=produce-audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"produce-audio.js","sourceRoot":"","sources":["../../../../../s/timeline/renderers/export/parts/produce-audio.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,EAAE,EAAC,MAAM,yBAAyB,CAAA;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAA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AC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAC,IACtC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAE/C,MAAM,EAAC,IAAI,EAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QAC9C,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAE7B,MAAM;YACL,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,KAAK;YACjB,SAAS;SACT,CAAA;QAED,MAAM,CAAC,KAAK,EAAE,CAAA;IACf,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fps } from "../../../../units/fps.js";
|
|
2
|
+
import { Driver } from "../../../../driver/driver.js";
|
|
3
|
+
import { TimelineFile } from "../../../parts/basics.js";
|
|
4
|
+
import { DecoderSource } from "../../../../driver/fns/schematic.js";
|
|
5
|
+
export declare function produceVideo({ timeline, fps, driver, resolveMedia, }: {
|
|
6
|
+
driver: Driver;
|
|
7
|
+
resolveMedia: (hash: string) => DecoderSource;
|
|
8
|
+
timeline: TimelineFile;
|
|
9
|
+
fps: Fps;
|
|
10
|
+
}): ReadableStream<VideoFrame>;
|