@omnimedia/omnitool 1.1.0-5 → 1.1.0-51
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 +143 -80
- package/package.json +18 -16
- package/s/context.ts +0 -7
- package/s/demo/demo.bundle.ts +102 -43
- package/s/demo/demo.css +246 -11
- package/s/demo/routines/export-test.ts +16 -0
- package/s/demo/routines/filmstrip-test.ts +22 -18
- package/s/demo/routines/load-video.ts +2 -3
- package/s/demo/routines/playback-test.ts +76 -0
- package/s/demo/routines/timeline-setup.ts +24 -0
- package/s/demo/routines/transcode-test.ts +21 -5
- package/s/demo/routines/transitions-test.ts +2 -2
- package/s/demo/routines/waveform-test.ts +8 -6
- package/s/driver/driver-worker.ts +9 -0
- package/s/driver/driver.test.ts +1 -1
- package/s/driver/driver.ts +32 -44
- package/s/driver/fns/schematic.ts +52 -25
- package/s/driver/fns/work.ts +71 -200
- package/s/driver/parts/compositor.ts +178 -0
- package/s/driver/parts/machina.ts +19 -20
- package/s/index.html.ts +103 -19
- 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 +3 -0
- package/s/timeline/parts/basics.ts +1 -1
- package/s/timeline/parts/filmstrip.ts +43 -16
- package/s/timeline/parts/item.ts +59 -6
- package/s/timeline/parts/media.ts +32 -1
- package/s/timeline/parts/resource-pool.ts +8 -5
- package/s/timeline/parts/resource.ts +2 -0
- package/s/timeline/parts/waveform.ts +3 -4
- 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 +109 -0
- package/s/timeline/renderers/export/parts/produce-audio.ts +64 -0
- package/s/timeline/renderers/export/parts/produce-video.ts +50 -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 +360 -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 +16 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/sample.ts +59 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/sequence.ts +111 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/sink.ts +38 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/transition.ts +28 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/types.ts +10 -0
- package/s/timeline/renderers/parts/samplers/visual/sampler.ts +28 -0
- package/s/timeline/renderers/parts/schedulers.ts +96 -0
- package/s/timeline/renderers/player/parts/playback.ts +125 -0
- package/s/timeline/renderers/player/player.ts +71 -0
- package/s/timeline/renderers/renderers.test.ts +387 -0
- package/s/timeline/sugar/helpers.ts +85 -0
- package/s/timeline/sugar/o.ts +178 -38
- package/s/timeline/sugar/omni.test.ts +210 -0
- package/s/timeline/sugar/omni.ts +38 -12
- package/s/timeline/types.ts +29 -0
- package/s/timeline/utils/checksum.ts +3 -1
- package/s/timeline/utils/datafile.ts +15 -4
- package/s/timeline/utils/dummy-data.ts +3 -3
- package/s/timeline/utils/matrix.ts +33 -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-7X274AYV.js +2 -0
- package/x/WebGLRenderer-7X274AYV.js.map +7 -0
- package/x/WebGPURenderer-XMCMEXAO.js +2 -0
- package/x/WebGPURenderer-XMCMEXAO.js.map +7 -0
- package/x/browserAll-6TVTCHHE.js +2 -0
- package/x/browserAll-6TVTCHHE.js.map +7 -0
- package/x/chunk-4ONWQOPX.js +157 -0
- package/x/chunk-4ONWQOPX.js.map +7 -0
- package/x/chunk-63NSCXPX.js +2 -0
- package/x/chunk-63NSCXPX.js.map +7 -0
- package/x/chunk-A45M2HJC.js +2 -0
- package/x/chunk-A45M2HJC.js.map +7 -0
- package/x/chunk-OTQK6FAJ.js +15 -0
- package/x/chunk-OTQK6FAJ.js.map +7 -0
- package/x/chunk-Q7JBQNE4.js +42 -0
- package/x/chunk-Q7JBQNE4.js.map +7 -0
- package/x/chunk-W33LM336.js +393 -0
- package/x/chunk-W33LM336.js.map +7 -0
- package/x/chunk-W5CN46AR.js +327 -0
- package/x/chunk-W5CN46AR.js.map +7 -0
- package/x/chunk-WFT3KTZG.js +269 -0
- package/x/chunk-WFT3KTZG.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-NLGJGAXK.js +2 -0
- package/x/demo/WebGLRenderer-NLGJGAXK.js.map +7 -0
- package/x/demo/WebGPURenderer-RBOFXPL5.js +2 -0
- package/x/demo/WebGPURenderer-RBOFXPL5.js.map +7 -0
- package/x/demo/browserAll-5AZHDDG6.js +2 -0
- package/x/demo/browserAll-5AZHDDG6.js.map +7 -0
- package/x/demo/chunk-5ZZYIILO.js +393 -0
- package/x/demo/chunk-5ZZYIILO.js.map +7 -0
- package/x/demo/chunk-P3PTHHFE.js +42 -0
- package/x/demo/chunk-P3PTHHFE.js.map +7 -0
- package/x/demo/chunk-PYG4RZZ2.js +269 -0
- package/x/demo/chunk-PYG4RZZ2.js.map +7 -0
- package/x/demo/chunk-Q4MWBZHL.js +157 -0
- package/x/demo/chunk-Q4MWBZHL.js.map +7 -0
- package/x/demo/chunk-T3METYEY.js +15 -0
- package/x/demo/chunk-T3METYEY.js.map +7 -0
- package/x/demo/chunk-USLRKDKD.js +2 -0
- package/x/demo/chunk-USLRKDKD.js.map +7 -0
- package/x/demo/chunk-YISSXWBT.js +327 -0
- package/x/demo/chunk-YISSXWBT.js.map +7 -0
- package/x/demo/chunk-YJQWVIHX.js +2 -0
- package/x/demo/chunk-YJQWVIHX.js.map +7 -0
- package/x/demo/demo.bundle.js +92 -40
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +2450 -35
- 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 +20 -17
- 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 +65 -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 +13 -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/transitions-test.js +2 -2
- package/x/demo/routines/transitions-test.js.map +1 -1
- package/x/demo/routines/waveform-test.d.ts +2 -1
- package/x/demo/routines/waveform-test.js +7 -6
- package/x/demo/routines/waveform-test.js.map +1 -1
- package/x/demo/webworkerAll-QKIC5O27.js +2 -0
- package/x/demo/webworkerAll-QKIC5O27.js.map +7 -0
- package/x/driver/WebGLRenderer-OMRWYQIV.js +2 -0
- package/x/driver/WebGLRenderer-OMRWYQIV.js.map +7 -0
- package/x/driver/WebGPURenderer-KQJB2OJJ.js +2 -0
- package/x/driver/WebGPURenderer-KQJB2OJJ.js.map +7 -0
- package/x/driver/browserAll-YBZEJCN3.js +2 -0
- package/x/driver/browserAll-YBZEJCN3.js.map +7 -0
- package/x/driver/chunk-3L3MB5NY.js +393 -0
- package/x/driver/chunk-3L3MB5NY.js.map +7 -0
- package/x/driver/chunk-42BQ4XKE.js +269 -0
- package/x/driver/chunk-42BQ4XKE.js.map +7 -0
- package/x/driver/chunk-4HAYG3N5.js +327 -0
- package/x/driver/chunk-4HAYG3N5.js.map +7 -0
- package/x/driver/chunk-BFBY7VYB.js +42 -0
- package/x/driver/chunk-BFBY7VYB.js.map +7 -0
- package/x/driver/chunk-KM6O72WE.js +157 -0
- package/x/driver/chunk-KM6O72WE.js.map +7 -0
- package/x/driver/chunk-N6HD4WYJ.js +2 -0
- package/x/driver/chunk-N6HD4WYJ.js.map +7 -0
- package/x/driver/chunk-WCZ2O3UN.js +15 -0
- package/x/driver/chunk-WCZ2O3UN.js.map +7 -0
- package/x/driver/chunk-XWNSF3WJ.js +2 -0
- package/x/driver/chunk-XWNSF3WJ.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 +12 -9
- package/x/driver/driver.js +31 -41
- 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 +139 -1135
- package/x/driver/driver.worker.bundle.min.js.map +4 -4
- package/x/driver/fns/host.d.ts +10 -4
- package/x/driver/fns/schematic.d.ts +47 -24
- package/x/driver/fns/work.d.ts +12 -7
- package/x/driver/fns/work.js +68 -170
- package/x/driver/fns/work.js.map +1 -1
- package/x/driver/parts/compositor.d.ts +15 -0
- package/x/driver/parts/compositor.js +152 -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/webworkerAll-BKJQW6P7.js +2 -0
- package/x/driver/webworkerAll-BKJQW6P7.js.map +7 -0
- package/x/features/speech/transcribe/parts/prep-audio.d.ts +1 -1
- package/x/features/speech/transcribe/worker.bundle.min.js +703 -703
- package/x/features/speech/transcribe/worker.bundle.min.js.map +4 -4
- 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.js +8 -0
- package/x/tests.bundle.js.map +1 -0
- package/x/tests.bundle.min.js +2464 -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 +3 -0
- package/x/timeline/index.js +3 -0
- package/x/timeline/index.js.map +1 -1
- package/x/timeline/parts/basics.d.ts +1 -1
- 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/item.d.ts +51 -8
- package/x/timeline/parts/item.js +7 -3
- package/x/timeline/parts/item.js.map +1 -1
- package/x/timeline/parts/media.d.ts +5 -0
- package/x/timeline/parts/media.js +27 -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 +2 -0
- package/x/timeline/parts/waveform.d.ts +2 -1
- package/x/timeline/parts/waveform.js +2 -4
- package/x/timeline/parts/waveform.js.map +1 -1
- 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 +19 -0
- package/x/timeline/renderers/export/parts/cursor.js +80 -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 +27 -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 +30 -0
- package/x/timeline/renderers/parts/handy.js +219 -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.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 +5 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/defaults.js +10 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/defaults.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.d.ts +5 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.js +38 -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 +5 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sequence.js +75 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sequence.js.map +1 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sink.d.ts +8 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sink.js +24 -0
- package/x/timeline/renderers/parts/samplers/visual/parts/sink.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 +8 -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/sampler.d.ts +7 -0
- package/x/timeline/renderers/parts/samplers/visual/sampler.js +17 -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 +31 -0
- package/x/timeline/renderers/player/parts/playback.js +91 -0
- package/x/timeline/renderers/player/parts/playback.js.map +1 -0
- package/x/timeline/renderers/player/player.d.ts +23 -0
- package/x/timeline/renderers/player/player.js +50 -0
- package/x/timeline/renderers/player/player.js.map +1 -0
- package/x/timeline/renderers/renderers.test.d.ts +32 -0
- package/x/timeline/renderers/renderers.test.js +306 -0
- package/x/timeline/renderers/renderers.test.js.map +1 -0
- package/x/timeline/sugar/helpers.d.ts +30 -0
- package/x/timeline/sugar/helpers.js +46 -0
- package/x/timeline/sugar/helpers.js.map +1 -0
- package/x/timeline/sugar/o.d.ts +31 -4
- package/x/timeline/sugar/o.js +144 -38
- 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 +24 -0
- package/x/timeline/types.js +2 -0
- package/x/timeline/types.js.map +1 -0
- package/x/timeline/utils/checksum.d.ts +3 -2
- 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 +8 -0
- package/x/timeline/utils/matrix.js +26 -0
- package/x/timeline/utils/matrix.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-VVIU3M54.js +2 -0
- package/x/webworkerAll-VVIU3M54.js.map +7 -0
- package/s/tests.test.ts +0 -8
- package/s/timeline/sugar/omni-test.ts +0 -38
- package/s/tools/common/loader.ts +0 -26
- package/s/tools/common/transformer-pipeline.ts +0 -26
- package/s/tools/speech-recognition/common/model.ts +0 -26
- package/s/tools/speech-recognition/whisper/fns/host.ts +0 -25
- package/s/tools/speech-recognition/whisper/fns/schematic.ts +0 -23
- package/s/tools/speech-recognition/whisper/fns/work.ts +0 -91
- package/s/tools/speech-recognition/whisper/parts/types.ts +0 -38
- package/s/tools/speech-recognition/whisper/parts/worker.bundle.ts +0 -7
- package/s/tools/speech-recognition/whisper/tool.ts +0 -70
- package/x/tests.test.js +0 -6
- package/x/tests.test.js.map +0 -1
- package/x/timeline/sugar/omni-test.d.ts +0 -1
- package/x/timeline/sugar/omni-test.js +0 -22
- package/x/timeline/sugar/omni-test.js.map +0 -1
- package/x/tools/common/loader.d.ts +0 -19
- package/x/tools/common/loader.js +0 -18
- package/x/tools/common/loader.js.map +0 -1
- package/x/tools/common/transformer-pipeline.d.ts +0 -8
- package/x/tools/common/transformer-pipeline.js +0 -24
- package/x/tools/common/transformer-pipeline.js.map +0 -1
- package/x/tools/speech-recognition/common/model.d.ts +0 -14
- package/x/tools/speech-recognition/common/model.js +0 -16
- package/x/tools/speech-recognition/common/model.js.map +0 -1
- package/x/tools/speech-recognition/whisper/fns/host.d.ts +0 -13
- package/x/tools/speech-recognition/whisper/fns/host.js +0 -19
- package/x/tools/speech-recognition/whisper/fns/host.js.map +0 -1
- package/x/tools/speech-recognition/whisper/fns/schematic.d.ts +0 -19
- package/x/tools/speech-recognition/whisper/fns/schematic.js +0 -2
- package/x/tools/speech-recognition/whisper/fns/schematic.js.map +0 -1
- package/x/tools/speech-recognition/whisper/fns/work.d.ts +0 -12
- package/x/tools/speech-recognition/whisper/fns/work.js +0 -74
- package/x/tools/speech-recognition/whisper/fns/work.js.map +0 -1
- package/x/tools/speech-recognition/whisper/parts/types.d.ts +0 -31
- package/x/tools/speech-recognition/whisper/parts/types.js.map +0 -1
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.d.ts +0 -1
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js +0 -4
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js.map +0 -1
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js +0 -8
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js.map +0 -7
- package/x/tools/speech-recognition/whisper/tool.d.ts +0 -12
- package/x/tools/speech-recognition/whisper/tool.js +0 -63
- package/x/tools/speech-recognition/whisper/tool.js.map +0 -1
- /package/x/{tests.test.d.ts → tests.bundle.d.ts} +0 -0
- /package/x/{tools/speech-recognition/whisper → timeline/renderers/parts/samplers/audio}/parts/types.js +0 -0
|
@@ -1,14 +1,45 @@
|
|
|
1
1
|
|
|
2
|
+
import {ALL_FORMATS, Input} from "mediabunny"
|
|
3
|
+
|
|
2
4
|
import {Datafile} from "../utils/datafile.js"
|
|
5
|
+
import {DecoderSource} from "../../driver/fns/schematic.js"
|
|
6
|
+
import {loadDecoderSource} from "../../driver/utils/load-decoder-source.js"
|
|
3
7
|
|
|
4
8
|
export class Media {
|
|
5
9
|
duration = 0
|
|
10
|
+
hasVideo = false
|
|
11
|
+
hasAudio = false
|
|
12
|
+
|
|
6
13
|
constructor(public datafile: Datafile) {}
|
|
7
14
|
|
|
8
15
|
static async analyze(datafile: Datafile) {
|
|
9
16
|
const media = new this(datafile)
|
|
10
|
-
|
|
17
|
+
const duration = (await this.duration(datafile.url)) * 1000
|
|
18
|
+
media.duration = duration
|
|
19
|
+
const {video, audio} = await this.#has(datafile.url)
|
|
20
|
+
media.hasAudio = audio
|
|
21
|
+
media.hasVideo = video
|
|
11
22
|
return media
|
|
12
23
|
}
|
|
24
|
+
|
|
25
|
+
static async duration(source: DecoderSource) {
|
|
26
|
+
const input = new Input({
|
|
27
|
+
formats: ALL_FORMATS,
|
|
28
|
+
source: await loadDecoderSource(source)
|
|
29
|
+
})
|
|
30
|
+
const duration = await input.computeDuration()
|
|
31
|
+
return Number(duration.toFixed(5)) // fix weird floating points
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static async #has(source: DecoderSource) {
|
|
35
|
+
const input = new Input({
|
|
36
|
+
formats: ALL_FORMATS,
|
|
37
|
+
source: await loadDecoderSource(source)
|
|
38
|
+
})
|
|
39
|
+
return {
|
|
40
|
+
audio: !!(await input.getPrimaryAudioTrack()),
|
|
41
|
+
video: !!(await input.getPrimaryVideoTrack())
|
|
42
|
+
}
|
|
43
|
+
}
|
|
13
44
|
}
|
|
14
45
|
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import {GMap} from "@e280/stz"
|
|
3
3
|
import {Hash} from "./basics.js"
|
|
4
4
|
import {Media} from "./media.js"
|
|
5
5
|
import {Resource} from "./resource.js"
|
|
6
6
|
import {Datafile} from "../utils/datafile.js"
|
|
7
7
|
|
|
8
8
|
export class ResourcePool {
|
|
9
|
-
#map = new
|
|
9
|
+
#map = new GMap<Hash, Resource.Any>
|
|
10
10
|
|
|
11
11
|
/** store a media file (avoids duplicates via hash) */
|
|
12
12
|
async store(datafile: Datafile) {
|
|
13
13
|
const media = await Media.analyze(datafile)
|
|
14
14
|
const {hash} = media.datafile.checksum
|
|
15
|
-
const {filename, bytes} = media.datafile
|
|
15
|
+
const {filename, bytes, url, blob} = media.datafile
|
|
16
16
|
|
|
17
17
|
if (this.#map.has(hash)) {
|
|
18
18
|
const alreadyExists = this.#map.require(hash)
|
|
19
19
|
alreadyExists.filename = filename
|
|
20
20
|
}
|
|
21
21
|
else
|
|
22
|
-
this.#map.set(hash, {kind: "media", filename, bytes})
|
|
22
|
+
this.#map.set(hash, {kind: "media", filename, bytes, url, blob})
|
|
23
23
|
|
|
24
24
|
return media
|
|
25
25
|
}
|
|
26
|
-
}
|
|
27
26
|
|
|
27
|
+
require(hash: Hash) {
|
|
28
|
+
return this.#map.require(hash)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WaveSurfer from "wavesurfer.js"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {Driver} from "../../driver/driver.js"
|
|
4
4
|
import {DecoderSource} from "../../driver/fns/schematic.js"
|
|
5
5
|
|
|
6
6
|
export class Waveform {
|
|
@@ -19,9 +19,8 @@ export class Waveform {
|
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
static async init(source: DecoderSource, container: HTMLElement) {
|
|
23
|
-
const
|
|
24
|
-
const reader = driver.decode({ source }).audio.getReader()
|
|
22
|
+
static async init(driver: Driver, source: DecoderSource, container: HTMLElement) {
|
|
23
|
+
const reader = driver.decodeAudio({source}).getReader()
|
|
25
24
|
|
|
26
25
|
const peaks: number[] = []
|
|
27
26
|
let buffer: number[] = []
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// this is mutating fn
|
|
2
|
+
export const applyGainToPlanar = (
|
|
3
|
+
planes: Float32Array[],
|
|
4
|
+
gain: number
|
|
5
|
+
) => {
|
|
6
|
+
if (gain === 1)
|
|
7
|
+
return
|
|
8
|
+
// planes
|
|
9
|
+
|
|
10
|
+
for (const plane of planes) {
|
|
11
|
+
for (let i = 0; i < plane.length; i++) {
|
|
12
|
+
plane[i] *= gain
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// return planes
|
|
17
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
export type AudioPlanesInput = {
|
|
3
|
+
planes: Float32Array[]
|
|
4
|
+
sampleRate: number
|
|
5
|
+
timestamp: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type MixedChunk = {
|
|
9
|
+
planar: Float32Array
|
|
10
|
+
sampleRate: number
|
|
11
|
+
channels: number
|
|
12
|
+
frames: number
|
|
13
|
+
startFrame: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ActiveSample = {
|
|
17
|
+
startFrame: number
|
|
18
|
+
endFrame: number
|
|
19
|
+
data: Float32Array[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AudioMixOptions = {
|
|
23
|
+
chunkFrames?: number
|
|
24
|
+
clamp?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class AudioMix {
|
|
28
|
+
readonly #chunkFrames: number
|
|
29
|
+
readonly #clamp: boolean
|
|
30
|
+
|
|
31
|
+
constructor(options: AudioMixOptions = {}) {
|
|
32
|
+
this.#chunkFrames = options.chunkFrames ?? 1024
|
|
33
|
+
this.#clamp = options.clamp ?? true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async *mix(samples: AsyncIterable<AudioPlanesInput>): AsyncGenerator<MixedChunk> {
|
|
37
|
+
const chunkFrames = this.#chunkFrames
|
|
38
|
+
let sampleRate: number | null = null
|
|
39
|
+
let channels: number | null = null
|
|
40
|
+
const active: ActiveSample[] = []
|
|
41
|
+
let nextFrame = 0
|
|
42
|
+
let maxEnd = 0
|
|
43
|
+
|
|
44
|
+
for await (const input of samples) {
|
|
45
|
+
if (channels === null) {
|
|
46
|
+
channels = input.planes.length
|
|
47
|
+
sampleRate = input.sampleRate
|
|
48
|
+
} else {
|
|
49
|
+
if (input.planes.length !== channels) throw new Error(`Channel count changed`)
|
|
50
|
+
if (input.sampleRate !== sampleRate) throw new Error(`Sample rate changed`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const inputStart = Math.round(input.timestamp * sampleRate)
|
|
54
|
+
const frames = input.planes[0]?.length ?? 0
|
|
55
|
+
|
|
56
|
+
while (nextFrame + chunkFrames <= inputStart) {
|
|
57
|
+
yield this.#processChunk(active, nextFrame, channels, sampleRate)
|
|
58
|
+
nextFrame += chunkFrames
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
active.push({
|
|
62
|
+
startFrame: inputStart,
|
|
63
|
+
endFrame: inputStart + frames,
|
|
64
|
+
data: input.planes
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
maxEnd = Math.max(maxEnd, inputStart + frames)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (channels !== null && sampleRate !== null) {
|
|
71
|
+
while (nextFrame < maxEnd) {
|
|
72
|
+
yield this.#processChunk(active, nextFrame, channels, sampleRate)
|
|
73
|
+
nextFrame += chunkFrames
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#processChunk(
|
|
79
|
+
active: ActiveSample[],
|
|
80
|
+
currentStartFrame: number,
|
|
81
|
+
channels: number,
|
|
82
|
+
sampleRate: number
|
|
83
|
+
): MixedChunk {
|
|
84
|
+
const chunkFrames = this.#chunkFrames
|
|
85
|
+
const outputBuffer = new Float32Array(channels * chunkFrames)
|
|
86
|
+
const chunkEnd = currentStartFrame + chunkFrames
|
|
87
|
+
|
|
88
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
89
|
+
const channelOffset = ch * chunkFrames
|
|
90
|
+
const outChannelView = outputBuffer.subarray(channelOffset, channelOffset + chunkFrames)
|
|
91
|
+
|
|
92
|
+
for (const sample of active) {
|
|
93
|
+
const data = sample.data[ch]
|
|
94
|
+
if (!data) continue
|
|
95
|
+
|
|
96
|
+
const start = Math.max(currentStartFrame, sample.startFrame)
|
|
97
|
+
const end = Math.min(chunkEnd, sample.endFrame)
|
|
98
|
+
|
|
99
|
+
if (start >= end) continue
|
|
100
|
+
|
|
101
|
+
const dstIdx = start - currentStartFrame
|
|
102
|
+
const srcIdx = start - sample.startFrame
|
|
103
|
+
const len = end - start
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < len; i++) {
|
|
106
|
+
outChannelView[dstIdx + i] += data[srcIdx + i]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.#clamp) {
|
|
111
|
+
for (let i = 0; i < chunkFrames; i++) {
|
|
112
|
+
const v = outChannelView[i]
|
|
113
|
+
outChannelView[i] = v < -1.0 ? -1.0 : (v > 1.0 ? 1.0 : v)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for (let i = active.length - 1; i >= 0; i--) {
|
|
119
|
+
if (active[i].endFrame <= chunkEnd) {
|
|
120
|
+
active.splice(i, 1)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
planar: outputBuffer,
|
|
126
|
+
sampleRate,
|
|
127
|
+
channels,
|
|
128
|
+
frames: chunkFrames,
|
|
129
|
+
startFrame: currentStartFrame
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
import {ms, Ms} from "../../../../units/ms.js"
|
|
3
|
+
import {Item} from "../../../parts/item.js"
|
|
4
|
+
import {Driver} from "../../../../driver/driver.js"
|
|
5
|
+
import {TimelineFile} from "../../../parts/basics.js"
|
|
6
|
+
import {DecoderSource} from "../../../../driver/fns/schematic.js"
|
|
7
|
+
import {createVisualSampler} from "../../parts/samplers/visual/sampler.js"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* forward-only frame cursor optimized for export purposes.
|
|
11
|
+
* it uses mediabunny internally so the support for non-clients
|
|
12
|
+
* should be done from mediabunny custom decoder/encoder
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export class CursorVisualSampler {
|
|
16
|
+
#sampler
|
|
17
|
+
#videoCursors = new Map<number, VideoFrameCursor>()
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
private driver: Driver,
|
|
21
|
+
private resolveMedia: (hash: string) => DecoderSource
|
|
22
|
+
) {
|
|
23
|
+
this.#sampler = createVisualSampler(resolveMedia, (item, time) => {
|
|
24
|
+
const mediaTime = toUs(ms(item.start + time))
|
|
25
|
+
const cursor = this.#getCursorForVideo(item)
|
|
26
|
+
return cursor.next(mediaTime)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
cursor(timeline: TimelineFile) {
|
|
31
|
+
let lastTimecode = Number.NEGATIVE_INFINITY
|
|
32
|
+
return {
|
|
33
|
+
next: (timecode: Ms) => {
|
|
34
|
+
if (timecode < lastTimecode)
|
|
35
|
+
throw new Error(`CursorVisualSampler is forward-only: requested ${timecode}ms after ${lastTimecode}ms`)
|
|
36
|
+
lastTimecode = timecode
|
|
37
|
+
return this.#sampler.sample(timeline, timecode)
|
|
38
|
+
},
|
|
39
|
+
cancel: () => this.#cancel(),
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#getCursorForVideo(videoItem: Item.Video) {
|
|
44
|
+
const existing = this.#videoCursors.get(videoItem.id)
|
|
45
|
+
if (existing)
|
|
46
|
+
return existing
|
|
47
|
+
|
|
48
|
+
const source = this.resolveMedia(videoItem.mediaHash)
|
|
49
|
+
const video = this.driver.decodeVideo({ source })
|
|
50
|
+
const cursor = this.#cursor(video.getReader())
|
|
51
|
+
|
|
52
|
+
this.#videoCursors.set(videoItem.id, cursor)
|
|
53
|
+
return cursor
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async #cancel() {
|
|
57
|
+
await Promise.all(
|
|
58
|
+
[...this.#videoCursors.values()].map(cursor => cursor.cancel())
|
|
59
|
+
)
|
|
60
|
+
this.#videoCursors.clear()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// forward only
|
|
64
|
+
#cursor(reader: ReadableStreamDefaultReader<VideoFrame>) {
|
|
65
|
+
return {
|
|
66
|
+
async next(targetUs: number): Promise<VideoFrame | undefined> {
|
|
67
|
+
let prev: VideoFrame | null = null
|
|
68
|
+
while (true) {
|
|
69
|
+
const { done, value: hit } = await reader.read()
|
|
70
|
+
|
|
71
|
+
if (done) {
|
|
72
|
+
const out = prev ? new VideoFrame(prev) : undefined
|
|
73
|
+
prev?.close()
|
|
74
|
+
return out
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const hitUs = hit.timestamp ?? 0
|
|
78
|
+
if (hitUs >= targetUs) {
|
|
79
|
+
const prevUs = prev?.timestamp ?? Number.NEGATIVE_INFINITY
|
|
80
|
+
const usePrev = !!prev && Math.abs(prevUs - targetUs) < Math.abs(hitUs - targetUs)
|
|
81
|
+
|
|
82
|
+
const chosen = usePrev ? prev! : hit
|
|
83
|
+
const other = usePrev ? hit : prev
|
|
84
|
+
|
|
85
|
+
const copy = new VideoFrame(chosen)
|
|
86
|
+
chosen.close()
|
|
87
|
+
other?.close()
|
|
88
|
+
return copy
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
prev?.close()
|
|
92
|
+
prev = hit
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
cancel: async () => await reader.cancel()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const toUs = (ms: Ms) => Math.round(ms * 1_000)
|
|
102
|
+
|
|
103
|
+
type StreamCursor<T> = {
|
|
104
|
+
next(target: number): Promise<T | undefined>
|
|
105
|
+
cancel(): Promise<void>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type VideoFrameCursor = StreamCursor<VideoFrame>
|
|
109
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
import {AudioMix} from "./audio-mix.js"
|
|
3
|
+
import {ms} from "../../../../units/ms.js"
|
|
4
|
+
import {resampleToPlanar} from "./resamplers.js"
|
|
5
|
+
import {applyGainToPlanar} from "./audio-gain.js"
|
|
6
|
+
import {TimelineFile} from "../../../parts/basics.js"
|
|
7
|
+
import {DecoderSource} from "../../../../driver/fns/schematic.js"
|
|
8
|
+
import {createAudioSampler} from "../../parts/samplers/audio/sampler.js"
|
|
9
|
+
|
|
10
|
+
export function produceAudio({
|
|
11
|
+
timeline,
|
|
12
|
+
resolveMedia
|
|
13
|
+
}: {
|
|
14
|
+
timeline: TimelineFile,
|
|
15
|
+
resolveMedia: (hash: string) => DecoderSource
|
|
16
|
+
}) {
|
|
17
|
+
const mixer = new AudioMix()
|
|
18
|
+
const audio = streamAudio(timeline, resolveMedia)
|
|
19
|
+
const stream = new TransformStream<AudioData, AudioData>()
|
|
20
|
+
const writer = stream.writable.getWriter()
|
|
21
|
+
|
|
22
|
+
async function produce() {
|
|
23
|
+
for await (const chunk of mixer.mix(audio)) {
|
|
24
|
+
const data = new AudioData({
|
|
25
|
+
format: 'f32-planar',
|
|
26
|
+
sampleRate: chunk.sampleRate,
|
|
27
|
+
numberOfFrames: chunk.frames,
|
|
28
|
+
numberOfChannels: chunk.channels,
|
|
29
|
+
timestamp: Math.round(
|
|
30
|
+
(chunk.startFrame / chunk.sampleRate) * 1_000_000
|
|
31
|
+
),
|
|
32
|
+
data: new Float32Array(chunk.planar)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
await writer.write(data)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await writer.close()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
produce()
|
|
42
|
+
|
|
43
|
+
return stream.readable
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function *streamAudio(timeline: TimelineFile, resolveMedia: (hash: string) => DecoderSource) {
|
|
47
|
+
const audioSampler = createAudioSampler(resolveMedia)
|
|
48
|
+
|
|
49
|
+
for await (const {sample, timestamp, gain}
|
|
50
|
+
of audioSampler.sampleAudio(timeline, ms(0))) {
|
|
51
|
+
|
|
52
|
+
const {data} = resampleToPlanar(sample, 48000)
|
|
53
|
+
applyGainToPlanar(data, gain)
|
|
54
|
+
|
|
55
|
+
yield {
|
|
56
|
+
planes: data,
|
|
57
|
+
sampleRate: 48000,
|
|
58
|
+
timestamp
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
sample.close()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import {Fps} from "../../../../units/fps.js"
|
|
3
|
+
import {CursorVisualSampler} from "./cursor.js"
|
|
4
|
+
import {Driver} from "../../../../driver/driver.js"
|
|
5
|
+
import {fixedStep} from "../../parts/schedulers.js"
|
|
6
|
+
import {TimelineFile} from "../../../parts/basics.js"
|
|
7
|
+
import {computeItemDuration} from "../../parts/handy.js"
|
|
8
|
+
import {DecoderSource} from "../../../../driver/fns/schematic.js"
|
|
9
|
+
|
|
10
|
+
export function produceVideo({
|
|
11
|
+
timeline,
|
|
12
|
+
fps,
|
|
13
|
+
driver,
|
|
14
|
+
resolveMedia,
|
|
15
|
+
}: {
|
|
16
|
+
driver: Driver
|
|
17
|
+
resolveMedia: (hash: string) => DecoderSource
|
|
18
|
+
timeline: TimelineFile
|
|
19
|
+
fps: Fps
|
|
20
|
+
}) {
|
|
21
|
+
|
|
22
|
+
const stream = new TransformStream<VideoFrame, VideoFrame>()
|
|
23
|
+
const writer = stream.writable.getWriter()
|
|
24
|
+
const sampler = new CursorVisualSampler(driver, resolveMedia)
|
|
25
|
+
const cursor = sampler.cursor(timeline)
|
|
26
|
+
const dt = 1 / fps
|
|
27
|
+
const duration = computeItemDuration(timeline.rootId, timeline)
|
|
28
|
+
|
|
29
|
+
async function produce() {
|
|
30
|
+
await fixedStep({fps, duration}, async (timecode, i) => {
|
|
31
|
+
const layers = await cursor.next(timecode)
|
|
32
|
+
const composed = await driver.composite(layers)
|
|
33
|
+
|
|
34
|
+
const frame = new VideoFrame(composed, {
|
|
35
|
+
timestamp: Math.round(i * dt * 1_000_000),
|
|
36
|
+
duration: Math.round(dt * 1_000_000)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
await writer.write(frame)
|
|
40
|
+
composed.close()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
await writer.close()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
produce()
|
|
47
|
+
|
|
48
|
+
return stream.readable
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
const resampleLinear = (
|
|
3
|
+
src: Float32Array,
|
|
4
|
+
fromRate: number,
|
|
5
|
+
targetRate: number
|
|
6
|
+
) => {
|
|
7
|
+
if (fromRate === targetRate)
|
|
8
|
+
return src
|
|
9
|
+
|
|
10
|
+
const ratio = targetRate / fromRate
|
|
11
|
+
const outFrames = Math.max(1, Math.round(src.length * ratio))
|
|
12
|
+
const out = new Float32Array(outFrames)
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < outFrames; i++) {
|
|
15
|
+
const t = i / ratio
|
|
16
|
+
const i0 = Math.floor(t)
|
|
17
|
+
const i1 = Math.min(i0 + 1, src.length - 1)
|
|
18
|
+
const frac = t - i0
|
|
19
|
+
out[i] = src[i0] * (1 - frac) + src[i1] * frac
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return out
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const resampleToPlanar = (
|
|
26
|
+
sample: {
|
|
27
|
+
numberOfFrames: number
|
|
28
|
+
numberOfChannels: number
|
|
29
|
+
sampleRate: number
|
|
30
|
+
copyTo: (dest: Float32Array, options: {planeIndex: number; format: 'f32-planar'}) => void
|
|
31
|
+
},
|
|
32
|
+
targetRate: number
|
|
33
|
+
): {data: Float32Array[]; frames: number} => {
|
|
34
|
+
const channels = sample.numberOfChannels
|
|
35
|
+
const data = new Array<Float32Array>(channels)
|
|
36
|
+
let frames = 0
|
|
37
|
+
|
|
38
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
39
|
+
const plane = new Float32Array(sample.numberOfFrames)
|
|
40
|
+
sample.copyTo(plane, {planeIndex: ch, format: 'f32-planar'})
|
|
41
|
+
const resampled = resampleLinear(plane, sample.sampleRate, targetRate)
|
|
42
|
+
data[ch] = resampled
|
|
43
|
+
frames = resampled.length
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {data, frames}
|
|
47
|
+
}
|
|
48
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import {Fps} from "../../../units/fps.js"
|
|
3
|
+
import {Driver} from "../../../driver/driver.js"
|
|
4
|
+
import {TimelineFile} from "../../parts/basics.js"
|
|
5
|
+
import {produceAudio} from "./parts/produce-audio.js"
|
|
6
|
+
import {produceVideo} from "./parts/produce-video.js"
|
|
7
|
+
import {DecoderSource} from "../../../driver/fns/schematic.js"
|
|
8
|
+
|
|
9
|
+
export function produce(opts: {
|
|
10
|
+
timeline: TimelineFile
|
|
11
|
+
fps: Fps
|
|
12
|
+
driver: Driver
|
|
13
|
+
resolveMedia: (hash: string) => DecoderSource
|
|
14
|
+
}) {
|
|
15
|
+
|
|
16
|
+
const audio = produceAudio({...opts})
|
|
17
|
+
const video = produceVideo({...opts})
|
|
18
|
+
|
|
19
|
+
return opts.driver.encode({
|
|
20
|
+
video,
|
|
21
|
+
audio,
|
|
22
|
+
config: {
|
|
23
|
+
audio: {codec: 'opus', bitrate: 128000},
|
|
24
|
+
video: {codec: 'vp9', bitrate: 1000000}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|