@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,99 @@
|
|
|
1
|
+
|
|
2
|
+
import {SampleContext} from "./types.js"
|
|
3
|
+
import {sampleSequence} from "./sequence.js"
|
|
4
|
+
import {Ms} from "../../../../../../units/ms.js"
|
|
5
|
+
import {Item, Kind} from "../../../../../parts/item.js"
|
|
6
|
+
import {segmentTranscript} from "../../../../../parts/captions.js"
|
|
7
|
+
import {FilterSpec, Layer} from "../../../../../../driver/fns/schematic.js"
|
|
8
|
+
import {AncestorAt, computeOpacity, computeWorldMatrix} from "../../../handy.js"
|
|
9
|
+
|
|
10
|
+
export async function sampleVisual(
|
|
11
|
+
ctx: SampleContext,
|
|
12
|
+
item: Item.Any,
|
|
13
|
+
time: Ms,
|
|
14
|
+
ancestors: AncestorAt[],
|
|
15
|
+
options: {
|
|
16
|
+
/** Allow sampling trimmed media handles. */
|
|
17
|
+
allowHandles?: boolean
|
|
18
|
+
} = {}
|
|
19
|
+
): Promise<Layer[]> {
|
|
20
|
+
const matrix = computeWorldMatrix(ctx.items, ancestors, item, time)
|
|
21
|
+
const alpha = computeOpacity(ctx, item, time)
|
|
22
|
+
const crop = "spatialId" in item && item.spatialId
|
|
23
|
+
? (ctx.items.get(item.spatialId) as Item.Spatial | undefined)?.crop
|
|
24
|
+
: undefined
|
|
25
|
+
const filters = "filterIds" in item && item.filterIds
|
|
26
|
+
? item.filterIds
|
|
27
|
+
.map(id => ctx.items.get(id) as Item.Filter | undefined)
|
|
28
|
+
.filter((filter): filter is Item.Filter => !!filter?.enabled)
|
|
29
|
+
.map(filter => ({type: filter.type, params: filter.params}) as FilterSpec)
|
|
30
|
+
: undefined
|
|
31
|
+
|
|
32
|
+
switch (item.kind) {
|
|
33
|
+
case Kind.Stack: {
|
|
34
|
+
const nextAnc = [...ancestors, {item, localTime: time}]
|
|
35
|
+
|
|
36
|
+
const layers = await Promise.all(
|
|
37
|
+
item.childrenIds
|
|
38
|
+
.map(id => ctx.items.get(id))
|
|
39
|
+
.filter((child): child is Item.Any => !!child)
|
|
40
|
+
.map(child => sampleVisual(ctx, child, time, nextAnc, options))
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return layers.flat()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
case Kind.Sequence:
|
|
47
|
+
return sampleSequence(ctx, item, time, ancestors)
|
|
48
|
+
|
|
49
|
+
case Kind.Video: {
|
|
50
|
+
if (!options.allowHandles && (time < 0 || time >= item.duration)) return []
|
|
51
|
+
|
|
52
|
+
const frame = await ctx.videoSampler(item, time)
|
|
53
|
+
return frame ? [{kind: "image", frame, matrix, alpha, crop, filters, id: item.id}] : []
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
case Kind.Image: {
|
|
57
|
+
if (!options.allowHandles && (time < 0 || time >= item.duration)) return []
|
|
58
|
+
|
|
59
|
+
const frame = await ctx.imageSampler(item, time)
|
|
60
|
+
return frame ? [{kind: "image", frame, matrix, alpha, crop, filters, id: item.id}] : []
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
case Kind.Text: {
|
|
64
|
+
if (!options.allowHandles && (time < 0 || time >= item.duration)) return []
|
|
65
|
+
|
|
66
|
+
const style = item.styleId
|
|
67
|
+
? (ctx.items.get(item.styleId) as Item.TextStyle)?.style
|
|
68
|
+
: undefined
|
|
69
|
+
|
|
70
|
+
return [{id: item.id, kind: "text", content: item.content, style, matrix, alpha, crop, filters}]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case Kind.Caption: {
|
|
74
|
+
if (!options.allowHandles && (time < 0 || time >= item.duration)) return []
|
|
75
|
+
|
|
76
|
+
const transcriptTime = item.start + time
|
|
77
|
+
const segment = segmentTranscript(item.transcript, item).find(segment => {
|
|
78
|
+
const [start, end] = segment.timestamp
|
|
79
|
+
return transcriptTime >= start && transcriptTime < end
|
|
80
|
+
})
|
|
81
|
+
if (!segment)
|
|
82
|
+
return []
|
|
83
|
+
|
|
84
|
+
const style = item.styleId
|
|
85
|
+
? (ctx.items.get(item.styleId) as Item.TextStyle)?.style
|
|
86
|
+
: undefined
|
|
87
|
+
|
|
88
|
+
return [{id: item.id, kind: "text", content: segment.text, style, matrix, alpha, crop, filters}]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
case Kind.Gap: {
|
|
92
|
+
return [{id: item.id, kind: "gap"}]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
default:
|
|
96
|
+
return []
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
import {sampleVisual} from "./sample.js"
|
|
3
|
+
import {SampleContext} from "./types.js"
|
|
4
|
+
import {sampleTransition} from "./transition.js"
|
|
5
|
+
import {ms, Ms} from "../../../../../../units/ms.js"
|
|
6
|
+
import {Item, Kind} from "../../../../../parts/item.js"
|
|
7
|
+
import {Layer} from "../../../../../../driver/fns/schematic.js"
|
|
8
|
+
import {AncestorAt, computeItemDuration} from "../../../handy.js"
|
|
9
|
+
|
|
10
|
+
export async function sampleSequence(
|
|
11
|
+
ctx: SampleContext,
|
|
12
|
+
seq: Item.Sequence,
|
|
13
|
+
time: Ms,
|
|
14
|
+
ancestors: AncestorAt[]
|
|
15
|
+
): Promise<Layer[]> {
|
|
16
|
+
const state = sampleSequenceAt(ctx, seq, time)
|
|
17
|
+
if (!state) return []
|
|
18
|
+
|
|
19
|
+
const nextAnc = [...ancestors, {item: seq, localTime: time}]
|
|
20
|
+
|
|
21
|
+
if (!state.isTransitioning)
|
|
22
|
+
return sampleVisual(ctx, state.item, state.localTime, nextAnc)
|
|
23
|
+
|
|
24
|
+
return sampleTransition(
|
|
25
|
+
state.transition,
|
|
26
|
+
state.progress,
|
|
27
|
+
sampleTransitionHandle(ctx, state.outgoing, state.outgoingTime, nextAnc),
|
|
28
|
+
sampleTransitionHandle(ctx, state.incoming, state.incomingTime, nextAnc)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function sampleSequenceAt(ctx: SampleContext, seq: Item.Sequence, time: Ms) {
|
|
33
|
+
const children = seq.childrenIds
|
|
34
|
+
.map(id => ctx.items.get(id))
|
|
35
|
+
.filter((i): i is Item.Any => !!i)
|
|
36
|
+
|
|
37
|
+
let cursor = ms(0)
|
|
38
|
+
|
|
39
|
+
for (let index = 0; index < children.length; index++) {
|
|
40
|
+
const child = children[index]
|
|
41
|
+
const duration = computeItemDuration(child.id, ctx.timeline)
|
|
42
|
+
const end = ms(cursor + duration)
|
|
43
|
+
|
|
44
|
+
if (duration <= 0) {
|
|
45
|
+
cursor = end
|
|
46
|
+
continue
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (time < cursor || time >= end) {
|
|
50
|
+
cursor = end
|
|
51
|
+
continue
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const localTime = ms(time - cursor)
|
|
55
|
+
|
|
56
|
+
if (child.kind !== Kind.Transition)
|
|
57
|
+
return {isTransitioning: false, item: child, localTime} as const
|
|
58
|
+
|
|
59
|
+
const outgoing = children[index - 1]
|
|
60
|
+
const incoming = children[index + 1]
|
|
61
|
+
const isValidTransition =
|
|
62
|
+
outgoing && incoming &&
|
|
63
|
+
outgoing.kind !== Kind.Transition &&
|
|
64
|
+
incoming.kind !== Kind.Transition
|
|
65
|
+
|
|
66
|
+
if (!isValidTransition) return null
|
|
67
|
+
|
|
68
|
+
const outgoingDuration = computeItemDuration(outgoing.id, ctx.timeline)
|
|
69
|
+
return {
|
|
70
|
+
isTransitioning: true,
|
|
71
|
+
incoming,
|
|
72
|
+
outgoing,
|
|
73
|
+
outgoingTime: ms(outgoingDuration + localTime),
|
|
74
|
+
incomingTime: ms(localTime - duration),
|
|
75
|
+
progress: localTime / duration,
|
|
76
|
+
transition: child
|
|
77
|
+
} as const
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function sampleTransitionHandle(
|
|
84
|
+
ctx: SampleContext,
|
|
85
|
+
item: Item.Any,
|
|
86
|
+
time: Ms,
|
|
87
|
+
ancestors: AncestorAt[]
|
|
88
|
+
) {
|
|
89
|
+
const handleLayers = await sampleVisual(ctx, item, time, ancestors, {allowHandles: true})
|
|
90
|
+
if (handleLayers.some(layer => layer.kind === "image"))
|
|
91
|
+
return handleLayers
|
|
92
|
+
|
|
93
|
+
const duration = computeItemDuration(item.id, ctx.timeline)
|
|
94
|
+
const clampedTime = ms(Math.max(0, Math.min(time, duration > 0 ? duration - 1 : 0)))
|
|
95
|
+
return sampleVisual(ctx, item, clampedTime, ancestors)
|
|
96
|
+
}
|
|
97
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import {Item} from "../../../../../parts/item.js"
|
|
3
|
+
import {Layer} from "../../../../../../driver/fns/schematic.js"
|
|
4
|
+
|
|
5
|
+
export async function sampleTransition(
|
|
6
|
+
item: Item.Transition,
|
|
7
|
+
progress: number,
|
|
8
|
+
p1: Promise<Layer[]>,
|
|
9
|
+
p2: Promise<Layer[]>
|
|
10
|
+
): Promise<Layer[]> {
|
|
11
|
+
const [l1, l2] = await Promise.all([p1, p2])
|
|
12
|
+
const f1 = l1.find(l => l.kind === "image")?.frame
|
|
13
|
+
const f2 = l2.find(l => l.kind === "image")?.frame
|
|
14
|
+
|
|
15
|
+
const rest = [
|
|
16
|
+
...l1.filter(l => l.kind !== "image"),
|
|
17
|
+
...l2.filter(l => l.kind !== "image")
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
return f1 && f2 ? [{
|
|
21
|
+
id: item.id,
|
|
22
|
+
kind: "transition",
|
|
23
|
+
name: item.name,
|
|
24
|
+
progress,
|
|
25
|
+
from: f1,
|
|
26
|
+
to: f2
|
|
27
|
+
}, ...rest] : rest
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
import {ImageSampler, VideoSampler} from "./defaults.js"
|
|
3
|
+
import {Item} from "../../../../../parts/item.js"
|
|
4
|
+
import {TimelineFile} from "../../../../../parts/basics.js"
|
|
5
|
+
|
|
6
|
+
export type SampleContext = {
|
|
7
|
+
imageSampler: ImageSampler
|
|
8
|
+
videoSampler: VideoSampler
|
|
9
|
+
timeline: TimelineFile
|
|
10
|
+
items: Map<number, Item.Any>
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import {ALL_FORMATS, Input, VideoSampleSink} from "mediabunny"
|
|
3
|
+
|
|
4
|
+
import {DecoderSource} from "../../../../../../driver/fns/schematic.js"
|
|
5
|
+
import {loadDecoderSource} from "../../../../../../driver/utils/load-decoder-source.js"
|
|
6
|
+
|
|
7
|
+
type SinkState = {
|
|
8
|
+
input: Input
|
|
9
|
+
sink: VideoSampleSink | null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class VideoSink {
|
|
13
|
+
readonly #sinks = new Map<string, SinkState>()
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
private resolveMedia: (hash: string) => DecoderSource
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
async getSink(hash: string) {
|
|
20
|
+
const existing = this.#sinks.get(hash)
|
|
21
|
+
|
|
22
|
+
if (existing)
|
|
23
|
+
return existing.sink
|
|
24
|
+
|
|
25
|
+
const input = new Input({
|
|
26
|
+
formats: ALL_FORMATS,
|
|
27
|
+
source: await loadDecoderSource(this.resolveMedia(hash)),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const videoTrack = await input.getPrimaryVideoTrack()
|
|
31
|
+
const canDecodeVideo = !!videoTrack && await videoTrack.canDecode()
|
|
32
|
+
const sink = canDecodeVideo && videoTrack ? new VideoSampleSink(videoTrack) : null
|
|
33
|
+
|
|
34
|
+
this.#sinks.set(hash, {input, sink})
|
|
35
|
+
|
|
36
|
+
return sink
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import {VideoSink} from "./parts/video-sink.js"
|
|
3
|
+
import {ImageSink} from "./parts/image-sink.js"
|
|
4
|
+
import {sampleVisual} from "./parts/sample.js"
|
|
5
|
+
import {Ms} from "../../../../../units/ms.js"
|
|
6
|
+
import {TimelineFile} from "../../../../parts/basics.js"
|
|
7
|
+
import {DecoderSource} from "../../../../../driver/fns/schematic.js"
|
|
8
|
+
import {createDefaultImageSampler, createDefaultVideoSampler, VideoSampler} from "./parts/defaults.js"
|
|
9
|
+
|
|
10
|
+
export function createVisualSampler(
|
|
11
|
+
resolveMedia: (hash: string) => DecoderSource,
|
|
12
|
+
sampleVideo?: VideoSampler
|
|
13
|
+
) {
|
|
14
|
+
const imageSink = new ImageSink(resolveMedia)
|
|
15
|
+
const videoSink = new VideoSink(resolveMedia)
|
|
16
|
+
const imageSampler = createDefaultImageSampler(imageSink)
|
|
17
|
+
const videoSampler = sampleVideo ?? createDefaultVideoSampler(videoSink)
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
async sample(timeline: TimelineFile, timecode: Ms) {
|
|
21
|
+
const items = new Map(timeline.items.map(item => [item.id, item]))
|
|
22
|
+
const root = items.get(timeline.rootId)
|
|
23
|
+
|
|
24
|
+
if (!root)
|
|
25
|
+
return []
|
|
26
|
+
|
|
27
|
+
return sampleVisual({imageSampler, videoSampler, timeline, items}, root, timecode, [])
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
import {Pub, pub} from "@e280/stz"
|
|
3
|
+
|
|
4
|
+
import {ms, Ms} from "../../../units/ms.js"
|
|
5
|
+
import {fps, Fps} from "../../../units/fps.js"
|
|
6
|
+
|
|
7
|
+
export type RealtimeGenerator = {
|
|
8
|
+
play(): void
|
|
9
|
+
pause(): void
|
|
10
|
+
setFPS(v: Fps): void
|
|
11
|
+
isPlaying(): boolean
|
|
12
|
+
ticks(): AsyncGenerator<void>
|
|
13
|
+
onTick: Pub<[]>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const realtime = (): RealtimeGenerator => {
|
|
17
|
+
|
|
18
|
+
let playing = false
|
|
19
|
+
let frameRate = fps(60)
|
|
20
|
+
let frameDuration = 1000 / frameRate
|
|
21
|
+
|
|
22
|
+
let lastNow = 0
|
|
23
|
+
let lastComposite = 0
|
|
24
|
+
|
|
25
|
+
const onTick = pub()
|
|
26
|
+
let resolveTick: (() => void) | null = null
|
|
27
|
+
|
|
28
|
+
const loop = (now: number) => {
|
|
29
|
+
requestAnimationFrame(loop)
|
|
30
|
+
|
|
31
|
+
if (!playing) return
|
|
32
|
+
|
|
33
|
+
lastNow = now
|
|
34
|
+
|
|
35
|
+
while (now - lastComposite >= frameDuration) {
|
|
36
|
+
lastComposite += frameDuration
|
|
37
|
+
|
|
38
|
+
resolveTick?.()
|
|
39
|
+
resolveTick = null
|
|
40
|
+
onTick()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function* ticks(): AsyncGenerator<void> {
|
|
45
|
+
lastNow = performance.now()
|
|
46
|
+
lastComposite = lastNow
|
|
47
|
+
requestAnimationFrame(loop)
|
|
48
|
+
|
|
49
|
+
while (true) {
|
|
50
|
+
await new Promise<void>(r => resolveTick = r)
|
|
51
|
+
yield
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
play() {
|
|
58
|
+
if (playing) return
|
|
59
|
+
playing = true
|
|
60
|
+
lastNow = performance.now()
|
|
61
|
+
lastComposite = lastNow
|
|
62
|
+
},
|
|
63
|
+
pause() {
|
|
64
|
+
playing = false
|
|
65
|
+
},
|
|
66
|
+
setFPS(v: Fps) {
|
|
67
|
+
frameRate = v
|
|
68
|
+
frameDuration = 1000 / frameRate
|
|
69
|
+
},
|
|
70
|
+
isPlaying() {
|
|
71
|
+
return playing
|
|
72
|
+
},
|
|
73
|
+
ticks,
|
|
74
|
+
onTick
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type FixedStepOptions = {
|
|
79
|
+
fps: Fps
|
|
80
|
+
duration: Ms
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const fixedStep = async (
|
|
84
|
+
opts: FixedStepOptions,
|
|
85
|
+
onFrame: (t: Ms, index: number) => Promise<void> | void
|
|
86
|
+
) => {
|
|
87
|
+
const dt = ms(1000 / opts.fps)
|
|
88
|
+
const durationInSeconds = opts.duration / 1000
|
|
89
|
+
const total = Math.ceil(durationInSeconds * opts.fps)
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < total; i++) {
|
|
92
|
+
const t = ms(i * dt)
|
|
93
|
+
await onFrame(t, i)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
|
|
2
|
+
import {Fps} from '../../../../units/fps.js'
|
|
3
|
+
import {ms, Ms} from '../../../../units/ms.js'
|
|
4
|
+
import {Driver} from '../../../../driver/driver.js'
|
|
5
|
+
import {realtime} from '../../parts/schedulers.js'
|
|
6
|
+
import {seconds} from '../../../../units/seconds.js'
|
|
7
|
+
import {TimelineFile} from '../../../parts/basics.js'
|
|
8
|
+
import {computeItemDuration} from '../../parts/handy.js'
|
|
9
|
+
import {CursorVisualSampler, ReverseCursorVisualSampler} from '../../export/parts/cursor.js'
|
|
10
|
+
import {DecoderSource} from '../../../../driver/fns/schematic.js'
|
|
11
|
+
import {createAudioSampler} from '../../parts/samplers/audio/sampler.js'
|
|
12
|
+
import {createVisualSampler} from '../../parts/samplers/visual/sampler.js'
|
|
13
|
+
|
|
14
|
+
export class Playback {
|
|
15
|
+
audioSampler
|
|
16
|
+
seekVisualSampler
|
|
17
|
+
playVisualSampler: CursorVisualSampler | null = null
|
|
18
|
+
reversePlayVisualSampler: ReverseCursorVisualSampler | null = null
|
|
19
|
+
|
|
20
|
+
#playbackStart = ms(0)
|
|
21
|
+
#audioStartSec: number | null = null
|
|
22
|
+
#playbackRate = 1
|
|
23
|
+
|
|
24
|
+
#controller = realtime()
|
|
25
|
+
onTick = this.#controller.onTick
|
|
26
|
+
|
|
27
|
+
audioContext = new AudioContext({sampleRate: 48000})
|
|
28
|
+
audioGain = this.audioContext.createGain()
|
|
29
|
+
audioNodes = new Set<AudioBufferSourceNode>()
|
|
30
|
+
#audioAbort: AbortController | null = null
|
|
31
|
+
|
|
32
|
+
constructor(
|
|
33
|
+
private driver: Driver,
|
|
34
|
+
private timeline: TimelineFile,
|
|
35
|
+
private resolveMedia: (hash: string) => DecoderSource
|
|
36
|
+
) {
|
|
37
|
+
this.audioGain.connect(this.audioContext.destination)
|
|
38
|
+
this.audioGain.gain.value = 0.7 ** 2
|
|
39
|
+
this.seekVisualSampler = createVisualSampler(this.resolveMedia)
|
|
40
|
+
this.audioSampler = createAudioSampler(this.resolveMedia)
|
|
41
|
+
this.#samples()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
update(timeline: TimelineFile) {
|
|
45
|
+
this.timeline = timeline
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get isPlaying() {
|
|
49
|
+
return this.#controller.isPlaying()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async #samples() {
|
|
53
|
+
for await (const _ of this.#controller.ticks()) {
|
|
54
|
+
const time = this.currentTime
|
|
55
|
+
const layers = this.#playbackRate >= 0
|
|
56
|
+
? await this.playVisualSampler?.next(time) ?? []
|
|
57
|
+
: await this.reversePlayVisualSampler?.next(time) ?? []
|
|
58
|
+
|
|
59
|
+
const frame = await this.driver.composite(layers)
|
|
60
|
+
frame.close()
|
|
61
|
+
|
|
62
|
+
const hasEnded = this.#playbackRate >= 0
|
|
63
|
+
? time >= this.duration
|
|
64
|
+
: time <= 0
|
|
65
|
+
|
|
66
|
+
if (hasEnded)
|
|
67
|
+
this.pause()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async seek(time: Ms) {
|
|
72
|
+
this.pause()
|
|
73
|
+
this.#playbackStart = time
|
|
74
|
+
return await this.seekVisualSampler.sample(this.timeline, time)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async start() {
|
|
78
|
+
if(this.#controller.isPlaying())
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
await this.audioContext.resume()
|
|
82
|
+
|
|
83
|
+
this.#playbackStart = this.currentTime
|
|
84
|
+
this.#audioStartSec = this.audioContext.currentTime
|
|
85
|
+
|
|
86
|
+
this.#stopAudio()
|
|
87
|
+
this.playVisualSampler = new CursorVisualSampler(this.driver, this.resolveMedia, this.timeline)
|
|
88
|
+
this.reversePlayVisualSampler = new ReverseCursorVisualSampler(this.driver, this.resolveMedia, this.timeline)
|
|
89
|
+
|
|
90
|
+
this.#controller.play()
|
|
91
|
+
this.#startAudio()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
pause() {
|
|
95
|
+
this.#playbackStart = this.currentTime
|
|
96
|
+
this.#controller.pause()
|
|
97
|
+
this.#stopAudio()
|
|
98
|
+
|
|
99
|
+
if (this.playVisualSampler) {
|
|
100
|
+
this.playVisualSampler.cancel()
|
|
101
|
+
this.playVisualSampler = null
|
|
102
|
+
}
|
|
103
|
+
if (this.reversePlayVisualSampler) {
|
|
104
|
+
this.reversePlayVisualSampler.cancel()
|
|
105
|
+
this.reversePlayVisualSampler = null
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get duration() {
|
|
111
|
+
return computeItemDuration(
|
|
112
|
+
this.timeline.rootId,
|
|
113
|
+
this.timeline
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get currentTime() {
|
|
118
|
+
if (!this.#controller.isPlaying() || this.#audioStartSec === null)
|
|
119
|
+
return this.#playbackStart
|
|
120
|
+
|
|
121
|
+
const elapsedMs = (this.audioContext.currentTime - this.#audioStartSec) * 1000
|
|
122
|
+
const current = this.#playbackStart + elapsedMs * this.#playbackRate
|
|
123
|
+
return ms(Math.max(0, Math.min(this.duration, current)))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get playbackRate() {
|
|
127
|
+
return this.#playbackRate
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
set playbackRate(rate: number) {
|
|
131
|
+
if (!Number.isFinite(rate) || rate === 0)
|
|
132
|
+
throw new Error(`Invalid playback rate "${rate}".`)
|
|
133
|
+
|
|
134
|
+
this.#playbackStart = this.currentTime
|
|
135
|
+
this.#audioStartSec = this.#controller.isPlaying()
|
|
136
|
+
? this.audioContext.currentTime
|
|
137
|
+
: null
|
|
138
|
+
const wasReversed = this.#playbackRate < 0
|
|
139
|
+
this.#playbackRate = rate
|
|
140
|
+
|
|
141
|
+
if (this.#controller.isPlaying()) {
|
|
142
|
+
if (wasReversed && rate > 0) {
|
|
143
|
+
this.playVisualSampler?.cancel()
|
|
144
|
+
this.playVisualSampler = new CursorVisualSampler(this.driver, this.resolveMedia, this.timeline)
|
|
145
|
+
}
|
|
146
|
+
else if (!wasReversed && rate < 0) {
|
|
147
|
+
this.reversePlayVisualSampler?.cancel()
|
|
148
|
+
this.reversePlayVisualSampler = new ReverseCursorVisualSampler(this.driver, this.resolveMedia, this.timeline)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.#syncAudio()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
setFps(fps: Fps) {
|
|
156
|
+
this.#controller.setFPS(fps)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#syncAudio() {
|
|
160
|
+
this.#stopAudio()
|
|
161
|
+
this.#startAudio()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#stopAudio() {
|
|
165
|
+
this.#audioAbort?.abort()
|
|
166
|
+
this.#audioAbort = null
|
|
167
|
+
|
|
168
|
+
for (const node of this.audioNodes)
|
|
169
|
+
node.stop()
|
|
170
|
+
|
|
171
|
+
this.audioNodes.clear()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async #startAudio() {
|
|
175
|
+
if (this.#playbackRate !== 1)
|
|
176
|
+
return
|
|
177
|
+
|
|
178
|
+
const from = seconds(this.#playbackStart / 1000)
|
|
179
|
+
this.#audioAbort = new AbortController()
|
|
180
|
+
const signal = this.#audioAbort.signal
|
|
181
|
+
|
|
182
|
+
const ctx = this.audioContext
|
|
183
|
+
|
|
184
|
+
if (this.#audioStartSec === null)
|
|
185
|
+
return
|
|
186
|
+
|
|
187
|
+
for await (const {sample, timestamp} of this.audioSampler.sampleAudio(
|
|
188
|
+
this.timeline,
|
|
189
|
+
ms(from * 1000)
|
|
190
|
+
)) {
|
|
191
|
+
|
|
192
|
+
if (signal.aborted || !this.#controller.isPlaying())
|
|
193
|
+
return
|
|
194
|
+
|
|
195
|
+
while (timestamp - (ctx.currentTime - this.#audioStartSec + from) > 0.75)
|
|
196
|
+
await new Promise(r => setTimeout(r, 25))
|
|
197
|
+
|
|
198
|
+
const node = ctx.createBufferSource()
|
|
199
|
+
node.buffer = sample.toAudioBuffer()
|
|
200
|
+
node.connect(this.audioGain)
|
|
201
|
+
node.onended = () => this.audioNodes.delete(node)
|
|
202
|
+
this.audioNodes.add(node)
|
|
203
|
+
|
|
204
|
+
const startAt = this.#audioStartSec + timestamp - from
|
|
205
|
+
|
|
206
|
+
startAt >= ctx.currentTime
|
|
207
|
+
? node.start(startAt)
|
|
208
|
+
: node.start(ctx.currentTime, ctx.currentTime - startAt)
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
import {ms} from "../../../units/ms.js"
|
|
3
|
+
import {fps} from "../../../units/fps.js"
|
|
4
|
+
import {Playback} from "./parts/playback.js"
|
|
5
|
+
import {Driver} from "../../../driver/driver.js"
|
|
6
|
+
import {TimelineFile} from "../../parts/basics.js"
|
|
7
|
+
import {DecoderSource} from "../../../driver/fns/schematic.js"
|
|
8
|
+
|
|
9
|
+
type ResolveMedia = (hash: string) => DecoderSource
|
|
10
|
+
|
|
11
|
+
export class VideoPlayer {
|
|
12
|
+
canvas: HTMLCanvasElement
|
|
13
|
+
playback: Playback
|
|
14
|
+
|
|
15
|
+
#pendingSeek: number | null = null
|
|
16
|
+
#flushTask: Promise<void> | null = null
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
private driver: Driver,
|
|
20
|
+
resolveMedia: ResolveMedia,
|
|
21
|
+
timeline: TimelineFile
|
|
22
|
+
) {
|
|
23
|
+
this.playback = new Playback(driver, timeline, resolveMedia)
|
|
24
|
+
this.canvas = driver.compositor.pixi.renderer.canvas
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async play() {
|
|
28
|
+
await this.playback.start()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
pause() {
|
|
32
|
+
this.playback.pause()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
seek(timeMs: number) {
|
|
36
|
+
this.#pendingSeek = timeMs
|
|
37
|
+
return this.#flushTask ??= this.#flushSeeks().finally(() => this.#flushTask = null)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setFPS(value: number) {
|
|
41
|
+
this.playback.setFps(fps(value))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get isSeeking() {
|
|
45
|
+
return this.#flushTask !== null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get isPlaying() {
|
|
49
|
+
return this.playback.isPlaying
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get duration() {
|
|
53
|
+
return this.playback.duration
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get currentTime() {
|
|
57
|
+
return this.playback.currentTime
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get playbackRate() {
|
|
61
|
+
return this.playback.playbackRate
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
set playbackRate(rate: number) {
|
|
65
|
+
this.playback.playbackRate = rate
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
call this whenever your timeline state changes
|
|
70
|
+
*/
|
|
71
|
+
async update(timeline: TimelineFile) {
|
|
72
|
+
this.playback.update(timeline)
|
|
73
|
+
if (!this.isPlaying)
|
|
74
|
+
await this.seek(this.currentTime)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async #flushSeeks() {
|
|
78
|
+
while (this.#pendingSeek !== null) {
|
|
79
|
+
const next = this.#pendingSeek
|
|
80
|
+
this.#pendingSeek = null
|
|
81
|
+
const layers = await this.playback.seek(ms(next))
|
|
82
|
+
const frame = await this.driver.composite(layers)
|
|
83
|
+
frame.close()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|