@kolkrabbi/design-editor 0.1.0 → 0.2.0
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 +3 -1
- package/dist/BufferResource-CKQMSOM4.js +265 -0
- package/dist/CanvasPool-ilDNHrRx.js +30 -0
- package/dist/CanvasRenderer-CDbc3nH9.js +3396 -0
- package/dist/Geometry-D3fkwmax.js +3724 -0
- package/dist/{OrbitControls-BAhLQ5d8.js → OrbitControls-CE3qSrHQ.js} +10260 -9043
- package/dist/RenderTargetSystem-umK0aqrs.js +2394 -0
- package/dist/WebGLRenderer-DVKPZbKc.js +2145 -0
- package/dist/WebGPURenderer-DHSBocAL.js +1656 -0
- package/dist/browserAll-CJ593myQ.js +983 -0
- package/dist/canvasUtils-CXoNqK7T.js +168 -0
- package/dist/defaultFilter.vert-C9efGgir.js +888 -0
- package/dist/design-editor.css +2 -2
- package/dist/design-editor.js +40809 -26749
- package/dist/getTextureBatchBindGroup-ChWkOJ3t.js +19 -0
- package/dist/{host-IfZgcJFg.js → host-6EhdLf5-.js} +506 -559
- package/dist/{host-Cidlc8xP.js → host-DPFYZP9I.js} +134 -88
- package/dist/init-4Y6mtayI.js +441 -0
- package/dist/phase-D3rwI6OO.js +1719 -0
- package/dist/pipeline-DfTD40M-.js +4825 -0
- package/dist/rolldown-runtime-B0aSnxlc.js +20 -0
- package/dist/src-zDOFeQWX.js +4314 -0
- package/dist/webworkerAll-wTH3MKcZ.js +2 -0
- package/package.json +26 -21
- package/dist/favicon/favicon.svg +0 -12
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Black.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-BlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Bold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-BoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactBlack.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactBlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactDark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactDarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactFine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactFineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactRegular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-CompactRegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Dark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-DarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Fine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-FineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Light.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-LightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Medium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-MediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowBlack.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowBlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowDark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowDarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowFine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowFineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowRegular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-NarrowRegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-Regular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-RegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialBlack.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialBlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialDark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialDarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialFine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialFineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialRegular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-SpatialRegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallBlack.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallBlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallDark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallDarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallFine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallFineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallRegular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TallRegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightBlack.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightBlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightDark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightDarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightFine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightFineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightRegular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-TightRegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideBlack.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideBlackItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideDark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideDarkItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideFine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideFineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideRegular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk/PPRightGrotesk-WideRegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-Bold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-BoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-Dark.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-Fine.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-FineItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-Light.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-Medium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-Regular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Mono/PPRightGroteskMono-RegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-CompactLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-CompactLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-CompactMedium.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-CompactMediumItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-Regular.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-RegularItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-SpatialBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-SpatialBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-SpatialLight.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-SpatialLightItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-WideBold.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-Text/PPRightGroteskText-WideBoldItalic.woff2 +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Black.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-BlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Bold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-BoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactBlack.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactBlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactBold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactBoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactDark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactDarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactFine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactFineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactLight.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactLightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactMedium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactMediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactRegular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-CompactRegularItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Dark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-DarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Fine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-FineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Light.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-LightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Medium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-MediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowBlack.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowBlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowBold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowBoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowDark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowDarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowFine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowFineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowLight.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowLightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowMedium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowMediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowRegular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-NarrowRegularItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-Regular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-RegularItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialBlack.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialBlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialBold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialBoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialDark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialDarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialFine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialFineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialLight.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialLightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialMedium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialMediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialRegular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-SpatialRegularItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallBlack.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallBlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallBold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallBoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallDark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallDarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallFine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallFineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallLight.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallLightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallMedium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallMediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallRegular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TallRegularItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightBlack.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightBlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightBold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightBoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightDark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightDarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightFine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightFineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightLight.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightLightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightMedium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightMediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightRegular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-TightRegularItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideBlack.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideBlackItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideBold.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideBoldItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideDark.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideDarkItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideFine.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideFineItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideLight.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideLightItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideMedium.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideMediumItalic.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideRegular.ttf +0 -0
- package/dist/fonts/Right-Grotesk-ttf/PPRightGrotesk-WideRegularItalic.ttf +0 -0
- package/dist/fonts/TG/TGGullhamrarVF.ttf +0 -0
- package/dist/fonts/TG/TGMalromurRomanVF.ttf +0 -0
- package/dist/fonts/TG/TGRotVF.ttf +0 -0
- package/dist/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2 +0 -0
- package/dist/fonts/jetbrains-mono/JetBrainsMono-MediumItalic.woff2 +0 -0
- package/dist/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2 +0 -0
- package/dist/meshPalettes-BJODHYrY.js +0 -892
|
@@ -0,0 +1,4314 @@
|
|
|
1
|
+
import "./rolldown-runtime-B0aSnxlc.js";
|
|
2
|
+
import { t as e } from "./design-editor.js";
|
|
3
|
+
//#region node_modules/.pnpm/mediabunny@1.54.0/node_modules/mediabunny/dist/modules/src/misc.js
|
|
4
|
+
function t(e) {
|
|
5
|
+
if (!e) throw Error("Assertion failed.");
|
|
6
|
+
}
|
|
7
|
+
var n = (e) => {
|
|
8
|
+
let t = (e % 360 + 360) % 360;
|
|
9
|
+
if (t === 0 || t === 90 || t === 180 || t === 270) return t;
|
|
10
|
+
throw Error(`Invalid rotation ${e}.`);
|
|
11
|
+
}, r = (e) => e && e[e.length - 1], i = (e) => {
|
|
12
|
+
let t = 0;
|
|
13
|
+
for (; e.readBits(1) === 0 && t < 32;) t++;
|
|
14
|
+
if (t >= 32) throw Error("Invalid exponential-Golomb code.");
|
|
15
|
+
return (1 << t) - 1 + e.readBits(t);
|
|
16
|
+
}, a = (e, t, n, r) => {
|
|
17
|
+
for (let i = t; i < n; i++) {
|
|
18
|
+
let t = Math.floor(i / 8), a = e[t], o = 7 - (i & 7);
|
|
19
|
+
a &= ~(1 << o), a |= (r & 1 << n - i - 1) >> n - i - 1 << o, e[t] = a;
|
|
20
|
+
}
|
|
21
|
+
}, o = (e) => e.constructor === Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e), s = (e) => e.constructor === DataView ? e : ArrayBuffer.isView(e) ? new DataView(e.buffer, e.byteOffset, e.byteLength) : new DataView(e), c = /* #__PURE__ */ new TextEncoder(), l = {
|
|
22
|
+
bt709: 1,
|
|
23
|
+
bt470bg: 5,
|
|
24
|
+
smpte170m: 6,
|
|
25
|
+
bt2020: 9,
|
|
26
|
+
smpte432: 12
|
|
27
|
+
}, u = {
|
|
28
|
+
bt709: 1,
|
|
29
|
+
smpte170m: 6,
|
|
30
|
+
linear: 8,
|
|
31
|
+
"iec61966-2-1": 13,
|
|
32
|
+
pq: 16,
|
|
33
|
+
hlg: 18
|
|
34
|
+
}, d = {
|
|
35
|
+
rgb: 0,
|
|
36
|
+
bt709: 1,
|
|
37
|
+
bt470bg: 5,
|
|
38
|
+
smpte170m: 6,
|
|
39
|
+
"bt2020-ncl": 9
|
|
40
|
+
}, f = (e) => !!e && !!e.primaries && !!e.transfer && !!e.matrix && e.fullRange !== void 0, p = (e) => e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || ArrayBuffer.isView(e), m = class {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.currentPromise = Promise.resolve(), this.pending = 0;
|
|
43
|
+
}
|
|
44
|
+
async acquire() {
|
|
45
|
+
let e, t = new Promise((t) => {
|
|
46
|
+
let n = !1;
|
|
47
|
+
e = () => {
|
|
48
|
+
n ||= (t(), this.pending--, !0);
|
|
49
|
+
};
|
|
50
|
+
}), n = this.currentPromise;
|
|
51
|
+
return this.currentPromise = t, this.pending++, await n, e;
|
|
52
|
+
}
|
|
53
|
+
}, h = (e, t, n) => {
|
|
54
|
+
let r = 0, i = e.length - 1, a = -1;
|
|
55
|
+
for (; r <= i;) {
|
|
56
|
+
let o = r + (i - r + 1) / 2 | 0;
|
|
57
|
+
n(e[o]) <= t ? (a = o, r = o + 1) : i = o - 1;
|
|
58
|
+
}
|
|
59
|
+
return a;
|
|
60
|
+
}, g = () => {
|
|
61
|
+
let e, t;
|
|
62
|
+
return {
|
|
63
|
+
promise: new Promise((n, r) => {
|
|
64
|
+
e = n, t = r;
|
|
65
|
+
}),
|
|
66
|
+
resolve: e,
|
|
67
|
+
reject: t
|
|
68
|
+
};
|
|
69
|
+
}, _ = (e) => {
|
|
70
|
+
throw Error(`Unexpected value: ${e}`);
|
|
71
|
+
}, ee = (e, t, n) => {
|
|
72
|
+
let r = e.getUint8(t), i = e.getUint8(t + 1), a = e.getUint8(t + 2);
|
|
73
|
+
return n ? r | i << 8 | a << 16 : r << 16 | i << 8 | a;
|
|
74
|
+
}, v = (e, t, n) => Math.max(t, Math.min(n, e)), y = (e, t, n) => e + (t - e) * n, b = (e, t) => Math.round(e / t) * t, x = (e, t) => Math.round(e * t) / t, S = (e, t) => Math.floor(e * t) / t, te = /^[a-z]{3}$/, ne = (e) => te.test(e), C = 1e6 * (1 + 2 ** -52), re = class {
|
|
75
|
+
constructor() {
|
|
76
|
+
this.currentPromise = Promise.resolve();
|
|
77
|
+
}
|
|
78
|
+
call(e) {
|
|
79
|
+
return this.currentPromise = this.currentPromise.then(e);
|
|
80
|
+
}
|
|
81
|
+
}, w = null, ie = () => w === null ? w = typeof navigator < "u" && navigator.userAgent?.includes("Firefox") : w, T = null, ae = () => T === null ? T = !!(typeof navigator < "u" && (navigator.vendor?.includes("Google Inc") || /Chrome/.test(navigator.userAgent))) : T, E = null, oe = () => {
|
|
82
|
+
if (E !== null) return E;
|
|
83
|
+
if (typeof navigator > "u") return null;
|
|
84
|
+
let e = /\bChrome\/(\d+)/.exec(navigator.userAgent);
|
|
85
|
+
return e ? E = Number(e[1]) : null;
|
|
86
|
+
}, se = function* (e) {
|
|
87
|
+
for (let t in e) {
|
|
88
|
+
let n = e[t];
|
|
89
|
+
n !== void 0 && (yield {
|
|
90
|
+
key: t,
|
|
91
|
+
value: n
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, ce = (e) => {
|
|
95
|
+
switch (e.toLowerCase()) {
|
|
96
|
+
case "image/jpeg":
|
|
97
|
+
case "image/jpg": return ".jpg";
|
|
98
|
+
case "image/png": return ".png";
|
|
99
|
+
case "image/gif": return ".gif";
|
|
100
|
+
case "image/webp": return ".webp";
|
|
101
|
+
case "image/bmp": return ".bmp";
|
|
102
|
+
case "image/svg+xml": return ".svg";
|
|
103
|
+
case "image/tiff": return ".tiff";
|
|
104
|
+
case "image/avif": return ".avif";
|
|
105
|
+
case "image/x-icon":
|
|
106
|
+
case "image/vnd.microsoft.icon": return ".ico";
|
|
107
|
+
default: return null;
|
|
108
|
+
}
|
|
109
|
+
}, le = (e, t) => {
|
|
110
|
+
if (e.length !== t.length) return !1;
|
|
111
|
+
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
112
|
+
return !0;
|
|
113
|
+
}, ue = () => {
|
|
114
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
115
|
+
}, de = (e, t) => {
|
|
116
|
+
let n = -1, r = Infinity;
|
|
117
|
+
for (let i = 0; i < e.length; i++) {
|
|
118
|
+
let a = t(e[i]);
|
|
119
|
+
a < r && (r = a, n = i);
|
|
120
|
+
}
|
|
121
|
+
return n;
|
|
122
|
+
}, fe = (e) => {
|
|
123
|
+
t(Number.isInteger(e.num)), t(Number.isInteger(e.den)), t(e.den !== 0);
|
|
124
|
+
let n = Math.abs(e.num), r = Math.abs(e.den);
|
|
125
|
+
for (; r !== 0;) {
|
|
126
|
+
let e = n % r;
|
|
127
|
+
n = r, r = e;
|
|
128
|
+
}
|
|
129
|
+
let i = n || 1;
|
|
130
|
+
return {
|
|
131
|
+
num: e.num / i,
|
|
132
|
+
den: e.den / i
|
|
133
|
+
};
|
|
134
|
+
}, D = (e, t) => {
|
|
135
|
+
if (typeof e != "object" || !e) throw TypeError(`${t} must be an object.`);
|
|
136
|
+
if (!Number.isInteger(e.left) || e.left < 0) throw TypeError(`${t}.left must be a non-negative integer.`);
|
|
137
|
+
if (!Number.isInteger(e.top) || e.top < 0) throw TypeError(`${t}.top must be a non-negative integer.`);
|
|
138
|
+
if (!Number.isInteger(e.width) || e.width < 0) throw TypeError(`${t}.width must be a non-negative integer.`);
|
|
139
|
+
if (!Number.isInteger(e.height) || e.height < 0) throw TypeError(`${t}.height must be a non-negative integer.`);
|
|
140
|
+
}, pe = (e) => new Promise((t) => setTimeout(t, e)), me = (e) => Array.isArray(e) ? e : [e], O = class {
|
|
141
|
+
constructor() {
|
|
142
|
+
this._listeners = /* @__PURE__ */ new Map();
|
|
143
|
+
}
|
|
144
|
+
on(e, t, n) {
|
|
145
|
+
this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
|
|
146
|
+
let r = {
|
|
147
|
+
fn: t,
|
|
148
|
+
once: n?.once ?? !1
|
|
149
|
+
};
|
|
150
|
+
return this._listeners.get(e).add(r), () => {
|
|
151
|
+
this._listeners.get(e)?.delete(r);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
_emit(...e) {
|
|
155
|
+
let [t, n] = e, r = this._listeners.get(t);
|
|
156
|
+
if (r) for (let e of r) {
|
|
157
|
+
try {
|
|
158
|
+
e.fn(n);
|
|
159
|
+
} catch (e) {
|
|
160
|
+
console.error(e);
|
|
161
|
+
}
|
|
162
|
+
e.once && r.delete(e);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, he = (e) => typeof e == "object" && !!e && Object.getPrototypeOf(e) === Object.prototype && Object.values(e).every((e) => typeof e == "string"), k;
|
|
166
|
+
(function(e) {
|
|
167
|
+
e[e.Silent = 0] = "Silent", e[e.Errors = 1] = "Errors", e[e.Warnings = 2] = "Warnings", e[e.Info = 3] = "Info";
|
|
168
|
+
})(k ||= {});
|
|
169
|
+
var A = class e {
|
|
170
|
+
constructor() {}
|
|
171
|
+
static get level() {
|
|
172
|
+
return e._level;
|
|
173
|
+
}
|
|
174
|
+
static set level(t) {
|
|
175
|
+
if (t !== k.Silent && t !== k.Errors && t !== k.Warnings && t !== k.Info) throw TypeError("Invalid log level. Use one of the values of the LogLevel enum.");
|
|
176
|
+
e._level = t;
|
|
177
|
+
}
|
|
178
|
+
static get _emitter() {
|
|
179
|
+
return e._emitterInstance ??= new O();
|
|
180
|
+
}
|
|
181
|
+
static on(t, n, r) {
|
|
182
|
+
return e._emitter.on(t, n, r);
|
|
183
|
+
}
|
|
184
|
+
static _error(...t) {
|
|
185
|
+
e._emitter._emit("error", t), e._level >= k.Errors && console.error(...t);
|
|
186
|
+
}
|
|
187
|
+
static _warn(...t) {
|
|
188
|
+
e._emitter._emit("warn", t), e._level >= k.Warnings && console.warn(...t);
|
|
189
|
+
}
|
|
190
|
+
static _info(...t) {
|
|
191
|
+
e._emitter._emit("info", t), e._level >= k.Info && console.info(...t);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
A._level = k.Info, A._emitterInstance = null;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region node_modules/.pnpm/mediabunny@1.54.0/node_modules/mediabunny/dist/modules/src/metadata.js
|
|
197
|
+
var ge = class {
|
|
198
|
+
constructor(e, t) {
|
|
199
|
+
if (this.data = e, this.mimeType = t, !(e instanceof Uint8Array)) throw TypeError("data must be a Uint8Array.");
|
|
200
|
+
if (typeof t != "string") throw TypeError("mimeType must be a string.");
|
|
201
|
+
}
|
|
202
|
+
}, _e = class {
|
|
203
|
+
constructor(e, t, n, r) {
|
|
204
|
+
if (this.data = e, this.mimeType = t, this.name = n, this.description = r, !(e instanceof Uint8Array)) throw TypeError("data must be a Uint8Array.");
|
|
205
|
+
if (t !== void 0 && typeof t != "string") throw TypeError("mimeType, when provided, must be a string.");
|
|
206
|
+
if (n !== void 0 && typeof n != "string") throw TypeError("name, when provided, must be a string.");
|
|
207
|
+
if (r !== void 0 && typeof r != "string") throw TypeError("description, when provided, must be a string.");
|
|
208
|
+
}
|
|
209
|
+
}, ve = (e) => {
|
|
210
|
+
if (!e || typeof e != "object") throw TypeError("tags must be an object.");
|
|
211
|
+
if (e.title !== void 0 && typeof e.title != "string") throw TypeError("tags.title, when provided, must be a string.");
|
|
212
|
+
if (e.description !== void 0 && typeof e.description != "string") throw TypeError("tags.description, when provided, must be a string.");
|
|
213
|
+
if (e.artist !== void 0 && typeof e.artist != "string") throw TypeError("tags.artist, when provided, must be a string.");
|
|
214
|
+
if (e.album !== void 0 && typeof e.album != "string") throw TypeError("tags.album, when provided, must be a string.");
|
|
215
|
+
if (e.albumArtist !== void 0 && typeof e.albumArtist != "string") throw TypeError("tags.albumArtist, when provided, must be a string.");
|
|
216
|
+
if (e.trackNumber !== void 0 && (!Number.isInteger(e.trackNumber) || e.trackNumber <= 0)) throw TypeError("tags.trackNumber, when provided, must be a positive integer.");
|
|
217
|
+
if (e.tracksTotal !== void 0 && (!Number.isInteger(e.tracksTotal) || e.tracksTotal <= 0)) throw TypeError("tags.tracksTotal, when provided, must be a positive integer.");
|
|
218
|
+
if (e.discNumber !== void 0 && (!Number.isInteger(e.discNumber) || e.discNumber <= 0)) throw TypeError("tags.discNumber, when provided, must be a positive integer.");
|
|
219
|
+
if (e.discsTotal !== void 0 && (!Number.isInteger(e.discsTotal) || e.discsTotal <= 0)) throw TypeError("tags.discsTotal, when provided, must be a positive integer.");
|
|
220
|
+
if (e.genre !== void 0 && typeof e.genre != "string") throw TypeError("tags.genre, when provided, must be a string.");
|
|
221
|
+
if (e.date !== void 0 && (!(e.date instanceof Date) || Number.isNaN(e.date.getTime()))) throw TypeError("tags.date, when provided, must be a valid Date.");
|
|
222
|
+
if (e.lyrics !== void 0 && typeof e.lyrics != "string") throw TypeError("tags.lyrics, when provided, must be a string.");
|
|
223
|
+
if (e.images !== void 0) {
|
|
224
|
+
if (!Array.isArray(e.images)) throw TypeError("tags.images, when provided, must be an array.");
|
|
225
|
+
for (let t of e.images) {
|
|
226
|
+
if (!t || typeof t != "object") throw TypeError("Each image in tags.images must be an object.");
|
|
227
|
+
if (!(t.data instanceof Uint8Array)) throw TypeError("Each image.data must be a Uint8Array.");
|
|
228
|
+
if (typeof t.mimeType != "string") throw TypeError("Each image.mimeType must be a string.");
|
|
229
|
+
if (![
|
|
230
|
+
"coverFront",
|
|
231
|
+
"coverBack",
|
|
232
|
+
"unknown"
|
|
233
|
+
].includes(t.kind)) throw TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (e.comment !== void 0 && typeof e.comment != "string") throw TypeError("tags.comment, when provided, must be a string.");
|
|
237
|
+
if (e.raw !== void 0) {
|
|
238
|
+
if (!e.raw || typeof e.raw != "object") throw TypeError("tags.raw, when provided, must be an object.");
|
|
239
|
+
for (let t of Object.values(e.raw)) if (t !== null && typeof t != "string" && !(t instanceof Uint8Array) && !(t instanceof ge) && !(t instanceof _e) && !he(t)) throw TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, Record<string, string>, or null.");
|
|
240
|
+
}
|
|
241
|
+
}, ye = (e) => {
|
|
242
|
+
if (!e || typeof e != "object") throw TypeError("disposition must be an object.");
|
|
243
|
+
if (e.default !== void 0 && typeof e.default != "boolean") throw TypeError("disposition.default must be a boolean.");
|
|
244
|
+
if (e.primary !== void 0 && typeof e.primary != "boolean") throw TypeError("disposition.primary must be a boolean.");
|
|
245
|
+
if (e.forced !== void 0 && typeof e.forced != "boolean") throw TypeError("disposition.forced must be a boolean.");
|
|
246
|
+
if (e.original !== void 0 && typeof e.original != "boolean") throw TypeError("disposition.original must be a boolean.");
|
|
247
|
+
if (e.commentary !== void 0 && typeof e.commentary != "boolean") throw TypeError("disposition.commentary must be a boolean.");
|
|
248
|
+
if (e.hearingImpaired !== void 0 && typeof e.hearingImpaired != "boolean") throw TypeError("disposition.hearingImpaired must be a boolean.");
|
|
249
|
+
if (e.visuallyImpaired !== void 0 && typeof e.visuallyImpaired != "boolean") throw TypeError("disposition.visuallyImpaired must be a boolean.");
|
|
250
|
+
}, j = class e {
|
|
251
|
+
constructor(e) {
|
|
252
|
+
this.bytes = e, this.pos = 0;
|
|
253
|
+
}
|
|
254
|
+
seekToByte(e) {
|
|
255
|
+
this.pos = 8 * e;
|
|
256
|
+
}
|
|
257
|
+
readBit() {
|
|
258
|
+
let e = Math.floor(this.pos / 8), t = this.bytes[e] ?? 0, n = 7 - (this.pos & 7), r = (t & 1 << n) >> n;
|
|
259
|
+
return this.pos++, r;
|
|
260
|
+
}
|
|
261
|
+
readBits(e) {
|
|
262
|
+
if (e === 1) return this.readBit();
|
|
263
|
+
let t = 0;
|
|
264
|
+
for (let n = 0; n < e; n++) t <<= 1, t |= this.readBit();
|
|
265
|
+
return t;
|
|
266
|
+
}
|
|
267
|
+
writeBits(e, t) {
|
|
268
|
+
let n = this.pos + e;
|
|
269
|
+
for (let e = this.pos; e < n; e++) {
|
|
270
|
+
let r = Math.floor(e / 8), i = this.bytes[r], a = 7 - (e & 7);
|
|
271
|
+
i &= ~(1 << a), i |= (t & 1 << n - e - 1) >> n - e - 1 << a, this.bytes[r] = i;
|
|
272
|
+
}
|
|
273
|
+
this.pos = n;
|
|
274
|
+
}
|
|
275
|
+
readAlignedByte() {
|
|
276
|
+
if (this.pos % 8 != 0) throw Error("Bitstream is not byte-aligned.");
|
|
277
|
+
let e = this.pos / 8, t = this.bytes[e] ?? 0;
|
|
278
|
+
return this.pos += 8, t;
|
|
279
|
+
}
|
|
280
|
+
skipBits(e) {
|
|
281
|
+
this.pos += e;
|
|
282
|
+
}
|
|
283
|
+
getBitsLeft() {
|
|
284
|
+
return this.bytes.length * 8 - this.pos;
|
|
285
|
+
}
|
|
286
|
+
clone() {
|
|
287
|
+
let t = new e(this.bytes);
|
|
288
|
+
return t.pos = this.pos, t;
|
|
289
|
+
}
|
|
290
|
+
}, be = [
|
|
291
|
+
96e3,
|
|
292
|
+
88200,
|
|
293
|
+
64e3,
|
|
294
|
+
48e3,
|
|
295
|
+
44100,
|
|
296
|
+
32e3,
|
|
297
|
+
24e3,
|
|
298
|
+
22050,
|
|
299
|
+
16e3,
|
|
300
|
+
12e3,
|
|
301
|
+
11025,
|
|
302
|
+
8e3,
|
|
303
|
+
7350
|
|
304
|
+
], xe = [
|
|
305
|
+
-1,
|
|
306
|
+
1,
|
|
307
|
+
2,
|
|
308
|
+
3,
|
|
309
|
+
4,
|
|
310
|
+
5,
|
|
311
|
+
6,
|
|
312
|
+
8
|
|
313
|
+
], Se = (e) => {
|
|
314
|
+
let t = be.indexOf(e.sampleRate), n = null;
|
|
315
|
+
t === -1 && (t = 15, n = e.sampleRate);
|
|
316
|
+
let r = xe.indexOf(e.numberOfChannels);
|
|
317
|
+
if (r === -1) throw TypeError(`Unsupported number of channels: ${e.numberOfChannels}`);
|
|
318
|
+
let i = 13;
|
|
319
|
+
e.objectType >= 32 && (i += 6), t === 15 && (i += 24);
|
|
320
|
+
let a = Math.ceil(i / 8), o = new Uint8Array(a), s = new j(o);
|
|
321
|
+
return e.objectType < 32 ? s.writeBits(5, e.objectType) : (s.writeBits(5, 31), s.writeBits(6, e.objectType - 32)), s.writeBits(4, t), t === 15 && s.writeBits(24, n), s.writeBits(4, r), o;
|
|
322
|
+
}, M = [
|
|
323
|
+
"avc",
|
|
324
|
+
"hevc",
|
|
325
|
+
"vp9",
|
|
326
|
+
"av1",
|
|
327
|
+
"vp8",
|
|
328
|
+
"prores"
|
|
329
|
+
], N = [
|
|
330
|
+
"pcm-s16",
|
|
331
|
+
"pcm-s16be",
|
|
332
|
+
"pcm-s24",
|
|
333
|
+
"pcm-s24be",
|
|
334
|
+
"pcm-s32",
|
|
335
|
+
"pcm-s32be",
|
|
336
|
+
"pcm-f32",
|
|
337
|
+
"pcm-f32be",
|
|
338
|
+
"pcm-f64",
|
|
339
|
+
"pcm-f64be",
|
|
340
|
+
"pcm-u8",
|
|
341
|
+
"pcm-s8",
|
|
342
|
+
"ulaw",
|
|
343
|
+
"alaw"
|
|
344
|
+
], Ce = [
|
|
345
|
+
"aac",
|
|
346
|
+
"opus",
|
|
347
|
+
"mp3",
|
|
348
|
+
"vorbis",
|
|
349
|
+
"flac",
|
|
350
|
+
"ac3",
|
|
351
|
+
"eac3"
|
|
352
|
+
], P = [...Ce, ...N], F = ["webvtt"], we = [
|
|
353
|
+
{
|
|
354
|
+
maxMacroblocks: 99,
|
|
355
|
+
maxBitrate: 64e3,
|
|
356
|
+
maxDpbMbs: 396,
|
|
357
|
+
level: 10
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
maxMacroblocks: 396,
|
|
361
|
+
maxBitrate: 192e3,
|
|
362
|
+
maxDpbMbs: 900,
|
|
363
|
+
level: 11
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
maxMacroblocks: 396,
|
|
367
|
+
maxBitrate: 384e3,
|
|
368
|
+
maxDpbMbs: 2376,
|
|
369
|
+
level: 12
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
maxMacroblocks: 396,
|
|
373
|
+
maxBitrate: 768e3,
|
|
374
|
+
maxDpbMbs: 2376,
|
|
375
|
+
level: 13
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
maxMacroblocks: 396,
|
|
379
|
+
maxBitrate: 2e6,
|
|
380
|
+
maxDpbMbs: 2376,
|
|
381
|
+
level: 20
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
maxMacroblocks: 792,
|
|
385
|
+
maxBitrate: 4e6,
|
|
386
|
+
maxDpbMbs: 4752,
|
|
387
|
+
level: 21
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
maxMacroblocks: 1620,
|
|
391
|
+
maxBitrate: 4e6,
|
|
392
|
+
maxDpbMbs: 8100,
|
|
393
|
+
level: 22
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
maxMacroblocks: 1620,
|
|
397
|
+
maxBitrate: 1e7,
|
|
398
|
+
maxDpbMbs: 8100,
|
|
399
|
+
level: 30
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
maxMacroblocks: 3600,
|
|
403
|
+
maxBitrate: 14e6,
|
|
404
|
+
maxDpbMbs: 18e3,
|
|
405
|
+
level: 31
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
maxMacroblocks: 5120,
|
|
409
|
+
maxBitrate: 2e7,
|
|
410
|
+
maxDpbMbs: 20480,
|
|
411
|
+
level: 32
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
maxMacroblocks: 8192,
|
|
415
|
+
maxBitrate: 2e7,
|
|
416
|
+
maxDpbMbs: 32768,
|
|
417
|
+
level: 40
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
maxMacroblocks: 8192,
|
|
421
|
+
maxBitrate: 5e7,
|
|
422
|
+
maxDpbMbs: 32768,
|
|
423
|
+
level: 41
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
maxMacroblocks: 8704,
|
|
427
|
+
maxBitrate: 5e7,
|
|
428
|
+
maxDpbMbs: 34816,
|
|
429
|
+
level: 42
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
maxMacroblocks: 22080,
|
|
433
|
+
maxBitrate: 135e6,
|
|
434
|
+
maxDpbMbs: 110400,
|
|
435
|
+
level: 50
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
maxMacroblocks: 36864,
|
|
439
|
+
maxBitrate: 24e7,
|
|
440
|
+
maxDpbMbs: 184320,
|
|
441
|
+
level: 51
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
maxMacroblocks: 36864,
|
|
445
|
+
maxBitrate: 24e7,
|
|
446
|
+
maxDpbMbs: 184320,
|
|
447
|
+
level: 52
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
maxMacroblocks: 139264,
|
|
451
|
+
maxBitrate: 24e7,
|
|
452
|
+
maxDpbMbs: 696320,
|
|
453
|
+
level: 60
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
maxMacroblocks: 139264,
|
|
457
|
+
maxBitrate: 48e7,
|
|
458
|
+
maxDpbMbs: 696320,
|
|
459
|
+
level: 61
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
maxMacroblocks: 139264,
|
|
463
|
+
maxBitrate: 8e8,
|
|
464
|
+
maxDpbMbs: 696320,
|
|
465
|
+
level: 62
|
|
466
|
+
}
|
|
467
|
+
], Te = [
|
|
468
|
+
{
|
|
469
|
+
maxPictureSize: 36864,
|
|
470
|
+
maxBitrate: 128e3,
|
|
471
|
+
tier: "L",
|
|
472
|
+
level: 30
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
maxPictureSize: 122880,
|
|
476
|
+
maxBitrate: 15e5,
|
|
477
|
+
tier: "L",
|
|
478
|
+
level: 60
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
maxPictureSize: 245760,
|
|
482
|
+
maxBitrate: 3e6,
|
|
483
|
+
tier: "L",
|
|
484
|
+
level: 63
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
maxPictureSize: 552960,
|
|
488
|
+
maxBitrate: 6e6,
|
|
489
|
+
tier: "L",
|
|
490
|
+
level: 90
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
maxPictureSize: 983040,
|
|
494
|
+
maxBitrate: 1e7,
|
|
495
|
+
tier: "L",
|
|
496
|
+
level: 93
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
maxPictureSize: 2228224,
|
|
500
|
+
maxBitrate: 12e6,
|
|
501
|
+
tier: "L",
|
|
502
|
+
level: 120
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
maxPictureSize: 2228224,
|
|
506
|
+
maxBitrate: 3e7,
|
|
507
|
+
tier: "H",
|
|
508
|
+
level: 120
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
maxPictureSize: 2228224,
|
|
512
|
+
maxBitrate: 2e7,
|
|
513
|
+
tier: "L",
|
|
514
|
+
level: 123
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
maxPictureSize: 2228224,
|
|
518
|
+
maxBitrate: 5e7,
|
|
519
|
+
tier: "H",
|
|
520
|
+
level: 123
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
maxPictureSize: 8912896,
|
|
524
|
+
maxBitrate: 25e6,
|
|
525
|
+
tier: "L",
|
|
526
|
+
level: 150
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
maxPictureSize: 8912896,
|
|
530
|
+
maxBitrate: 1e8,
|
|
531
|
+
tier: "H",
|
|
532
|
+
level: 150
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
maxPictureSize: 8912896,
|
|
536
|
+
maxBitrate: 4e7,
|
|
537
|
+
tier: "L",
|
|
538
|
+
level: 153
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
maxPictureSize: 8912896,
|
|
542
|
+
maxBitrate: 16e7,
|
|
543
|
+
tier: "H",
|
|
544
|
+
level: 153
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
maxPictureSize: 8912896,
|
|
548
|
+
maxBitrate: 6e7,
|
|
549
|
+
tier: "L",
|
|
550
|
+
level: 156
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
maxPictureSize: 8912896,
|
|
554
|
+
maxBitrate: 24e7,
|
|
555
|
+
tier: "H",
|
|
556
|
+
level: 156
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
maxPictureSize: 35651584,
|
|
560
|
+
maxBitrate: 6e7,
|
|
561
|
+
tier: "L",
|
|
562
|
+
level: 180
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
maxPictureSize: 35651584,
|
|
566
|
+
maxBitrate: 24e7,
|
|
567
|
+
tier: "H",
|
|
568
|
+
level: 180
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
maxPictureSize: 35651584,
|
|
572
|
+
maxBitrate: 12e7,
|
|
573
|
+
tier: "L",
|
|
574
|
+
level: 183
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
maxPictureSize: 35651584,
|
|
578
|
+
maxBitrate: 48e7,
|
|
579
|
+
tier: "H",
|
|
580
|
+
level: 183
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
maxPictureSize: 35651584,
|
|
584
|
+
maxBitrate: 24e7,
|
|
585
|
+
tier: "L",
|
|
586
|
+
level: 186
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
maxPictureSize: 35651584,
|
|
590
|
+
maxBitrate: 8e8,
|
|
591
|
+
tier: "H",
|
|
592
|
+
level: 186
|
|
593
|
+
}
|
|
594
|
+
], Ee = [
|
|
595
|
+
{
|
|
596
|
+
maxPictureSize: 36864,
|
|
597
|
+
maxBitrate: 2e5,
|
|
598
|
+
level: 10
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
maxPictureSize: 73728,
|
|
602
|
+
maxBitrate: 8e5,
|
|
603
|
+
level: 11
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
maxPictureSize: 122880,
|
|
607
|
+
maxBitrate: 18e5,
|
|
608
|
+
level: 20
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
maxPictureSize: 245760,
|
|
612
|
+
maxBitrate: 36e5,
|
|
613
|
+
level: 21
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
maxPictureSize: 552960,
|
|
617
|
+
maxBitrate: 72e5,
|
|
618
|
+
level: 30
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
maxPictureSize: 983040,
|
|
622
|
+
maxBitrate: 12e6,
|
|
623
|
+
level: 31
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
maxPictureSize: 2228224,
|
|
627
|
+
maxBitrate: 18e6,
|
|
628
|
+
level: 40
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
maxPictureSize: 2228224,
|
|
632
|
+
maxBitrate: 3e7,
|
|
633
|
+
level: 41
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
maxPictureSize: 8912896,
|
|
637
|
+
maxBitrate: 6e7,
|
|
638
|
+
level: 50
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
maxPictureSize: 8912896,
|
|
642
|
+
maxBitrate: 12e7,
|
|
643
|
+
level: 51
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
maxPictureSize: 8912896,
|
|
647
|
+
maxBitrate: 18e7,
|
|
648
|
+
level: 52
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
maxPictureSize: 35651584,
|
|
652
|
+
maxBitrate: 18e7,
|
|
653
|
+
level: 60
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
maxPictureSize: 35651584,
|
|
657
|
+
maxBitrate: 24e7,
|
|
658
|
+
level: 61
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
maxPictureSize: 35651584,
|
|
662
|
+
maxBitrate: 48e7,
|
|
663
|
+
level: 62
|
|
664
|
+
}
|
|
665
|
+
], De = [
|
|
666
|
+
{
|
|
667
|
+
maxPictureSize: 147456,
|
|
668
|
+
maxBitrate: 15e5,
|
|
669
|
+
tier: "M",
|
|
670
|
+
level: 0
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
maxPictureSize: 278784,
|
|
674
|
+
maxBitrate: 3e6,
|
|
675
|
+
tier: "M",
|
|
676
|
+
level: 1
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
maxPictureSize: 665856,
|
|
680
|
+
maxBitrate: 6e6,
|
|
681
|
+
tier: "M",
|
|
682
|
+
level: 4
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
maxPictureSize: 1065024,
|
|
686
|
+
maxBitrate: 1e7,
|
|
687
|
+
tier: "M",
|
|
688
|
+
level: 5
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
maxPictureSize: 2359296,
|
|
692
|
+
maxBitrate: 12e6,
|
|
693
|
+
tier: "M",
|
|
694
|
+
level: 8
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
maxPictureSize: 2359296,
|
|
698
|
+
maxBitrate: 3e7,
|
|
699
|
+
tier: "H",
|
|
700
|
+
level: 8
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
maxPictureSize: 2359296,
|
|
704
|
+
maxBitrate: 2e7,
|
|
705
|
+
tier: "M",
|
|
706
|
+
level: 9
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
maxPictureSize: 2359296,
|
|
710
|
+
maxBitrate: 5e7,
|
|
711
|
+
tier: "H",
|
|
712
|
+
level: 9
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
maxPictureSize: 8912896,
|
|
716
|
+
maxBitrate: 3e7,
|
|
717
|
+
tier: "M",
|
|
718
|
+
level: 12
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
maxPictureSize: 8912896,
|
|
722
|
+
maxBitrate: 1e8,
|
|
723
|
+
tier: "H",
|
|
724
|
+
level: 12
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
maxPictureSize: 8912896,
|
|
728
|
+
maxBitrate: 4e7,
|
|
729
|
+
tier: "M",
|
|
730
|
+
level: 13
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
maxPictureSize: 8912896,
|
|
734
|
+
maxBitrate: 16e7,
|
|
735
|
+
tier: "H",
|
|
736
|
+
level: 13
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
maxPictureSize: 8912896,
|
|
740
|
+
maxBitrate: 6e7,
|
|
741
|
+
tier: "M",
|
|
742
|
+
level: 14
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
maxPictureSize: 8912896,
|
|
746
|
+
maxBitrate: 24e7,
|
|
747
|
+
tier: "H",
|
|
748
|
+
level: 14
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
maxPictureSize: 35651584,
|
|
752
|
+
maxBitrate: 6e7,
|
|
753
|
+
tier: "M",
|
|
754
|
+
level: 15
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
maxPictureSize: 35651584,
|
|
758
|
+
maxBitrate: 24e7,
|
|
759
|
+
tier: "H",
|
|
760
|
+
level: 15
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
maxPictureSize: 35651584,
|
|
764
|
+
maxBitrate: 6e7,
|
|
765
|
+
tier: "M",
|
|
766
|
+
level: 16
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
maxPictureSize: 35651584,
|
|
770
|
+
maxBitrate: 24e7,
|
|
771
|
+
tier: "H",
|
|
772
|
+
level: 16
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
maxPictureSize: 35651584,
|
|
776
|
+
maxBitrate: 1e8,
|
|
777
|
+
tier: "M",
|
|
778
|
+
level: 17
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
maxPictureSize: 35651584,
|
|
782
|
+
maxBitrate: 48e7,
|
|
783
|
+
tier: "H",
|
|
784
|
+
level: 17
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
maxPictureSize: 35651584,
|
|
788
|
+
maxBitrate: 16e7,
|
|
789
|
+
tier: "M",
|
|
790
|
+
level: 18
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
maxPictureSize: 35651584,
|
|
794
|
+
maxBitrate: 8e8,
|
|
795
|
+
tier: "H",
|
|
796
|
+
level: 18
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
maxPictureSize: 35651584,
|
|
800
|
+
maxBitrate: 16e7,
|
|
801
|
+
tier: "M",
|
|
802
|
+
level: 19
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
maxPictureSize: 35651584,
|
|
806
|
+
maxBitrate: 8e8,
|
|
807
|
+
tier: "H",
|
|
808
|
+
level: 19
|
|
809
|
+
}
|
|
810
|
+
], I = [
|
|
811
|
+
"ap4x",
|
|
812
|
+
"ap4h",
|
|
813
|
+
"apch",
|
|
814
|
+
"apcn",
|
|
815
|
+
"apcs",
|
|
816
|
+
"apco"
|
|
817
|
+
], Oe = [
|
|
818
|
+
{
|
|
819
|
+
fourCc: "apco",
|
|
820
|
+
bitrate: 45e6,
|
|
821
|
+
alpha: !1
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
fourCc: "apcs",
|
|
825
|
+
bitrate: 102e6,
|
|
826
|
+
alpha: !1
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
fourCc: "apcn",
|
|
830
|
+
bitrate: 147e6,
|
|
831
|
+
alpha: !1
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
fourCc: "apch",
|
|
835
|
+
bitrate: 22e7,
|
|
836
|
+
alpha: !1
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
fourCc: "ap4h",
|
|
840
|
+
bitrate: 33e7,
|
|
841
|
+
alpha: !0
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
fourCc: "ap4x",
|
|
845
|
+
bitrate: 5e8,
|
|
846
|
+
alpha: !0
|
|
847
|
+
}
|
|
848
|
+
], ke = (e, t, n, i, a) => {
|
|
849
|
+
if (e === "avc") {
|
|
850
|
+
let e = Math.ceil(t / 16) * Math.ceil(n / 16), a = we.find((t) => e <= t.maxMacroblocks && i <= t.maxBitrate) ?? r(we), o = a ? a.level : 0;
|
|
851
|
+
return `avc1.${"64".padStart(2, "0")}00${o.toString(16).padStart(2, "0")}`;
|
|
852
|
+
}
|
|
853
|
+
if (e === "hevc") {
|
|
854
|
+
let e = t * n, a = Te.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(Te);
|
|
855
|
+
return `hev1.1.6.${a.tier}${a.level}.B0`;
|
|
856
|
+
}
|
|
857
|
+
if (e === "vp8") return "vp8";
|
|
858
|
+
if (e === "vp9") {
|
|
859
|
+
let e = t * n;
|
|
860
|
+
return `vp09.00.${(Ee.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(Ee)).level.toString().padStart(2, "0")}.08`;
|
|
861
|
+
}
|
|
862
|
+
if (e === "av1") {
|
|
863
|
+
let e = t * n, a = De.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(De);
|
|
864
|
+
return `av01.0.${a.level.toString().padStart(2, "0")}${a.tier}.08`;
|
|
865
|
+
}
|
|
866
|
+
if (e === "prores") {
|
|
867
|
+
let e = (t * n / 2073600) ** .95, r = Oe.filter((e) => e.alpha === a), o = r[0].fourCc, s = Infinity;
|
|
868
|
+
for (let { fourCc: t, bitrate: n } of r) {
|
|
869
|
+
let r = Math.abs(n * e - i);
|
|
870
|
+
r < s && (s = r, o = t);
|
|
871
|
+
}
|
|
872
|
+
return o;
|
|
873
|
+
}
|
|
874
|
+
throw _(e), TypeError(`Unhandled codec '${String(e)}'.`);
|
|
875
|
+
}, Ae = (e) => {
|
|
876
|
+
let t = e.split(".");
|
|
877
|
+
return [
|
|
878
|
+
1,
|
|
879
|
+
1,
|
|
880
|
+
Number(t[1]),
|
|
881
|
+
2,
|
|
882
|
+
1,
|
|
883
|
+
Number(t[2]),
|
|
884
|
+
3,
|
|
885
|
+
1,
|
|
886
|
+
Number(t[3]),
|
|
887
|
+
4,
|
|
888
|
+
1,
|
|
889
|
+
t[4] ? Number(t[4]) : 1
|
|
890
|
+
];
|
|
891
|
+
}, je = (e) => {
|
|
892
|
+
let t = e.split("."), n = Number(t[1]), r = t[2], i = Number(r.slice(0, -1)), a = (n << 5) + i, o = +(r.slice(-1) === "H"), s = Number(t[3]) === 8 ? 0 : 1, c = t[4] ? Number(t[4]) : 0, l = t[5] ? Number(t[5][0]) : 1, u = t[5] ? Number(t[5][1]) : 1, d = t[5] ? Number(t[5][2]) : 0;
|
|
893
|
+
return [
|
|
894
|
+
129,
|
|
895
|
+
a,
|
|
896
|
+
(o << 7) + (s << 6) + 0 + (c << 4) + (l << 3) + (u << 2) + d,
|
|
897
|
+
0
|
|
898
|
+
];
|
|
899
|
+
}, Me = 48e3, Ne = /^pcm-([usf])(\d+)(be)?$/, Pe = (e) => {
|
|
900
|
+
if (t(N.includes(e)), e === "ulaw") return {
|
|
901
|
+
dataType: "ulaw",
|
|
902
|
+
sampleSize: 1,
|
|
903
|
+
littleEndian: !0,
|
|
904
|
+
silentValue: 255
|
|
905
|
+
};
|
|
906
|
+
if (e === "alaw") return {
|
|
907
|
+
dataType: "alaw",
|
|
908
|
+
sampleSize: 1,
|
|
909
|
+
littleEndian: !0,
|
|
910
|
+
silentValue: 213
|
|
911
|
+
};
|
|
912
|
+
let n = Ne.exec(e);
|
|
913
|
+
t(n);
|
|
914
|
+
let r;
|
|
915
|
+
r = n[1] === "u" ? "unsigned" : n[1] === "s" ? "signed" : "float";
|
|
916
|
+
let i = Number(n[2]) / 8, a = n[3] !== "be";
|
|
917
|
+
return {
|
|
918
|
+
dataType: r,
|
|
919
|
+
sampleSize: i,
|
|
920
|
+
littleEndian: a,
|
|
921
|
+
silentValue: e === "pcm-u8" ? 128 : 0
|
|
922
|
+
};
|
|
923
|
+
}, L = (e) => e.startsWith("avc1") || e.startsWith("avc3") ? "avc" : e.startsWith("hev1") || e.startsWith("hvc1") ? "hevc" : e === "vp8" ? "vp8" : e.startsWith("vp09") ? "vp9" : e.startsWith("av01") ? "av1" : I.includes(e) ? "prores" : e === "mp3" || e === "mp4a.69" || e === "mp4a.6B" || e === "mp4a.6b" || e === "mp4a.40.34" ? "mp3" : e.startsWith("mp4a.40.") || e === "mp4a.67" ? "aac" : e === "opus" ? "opus" : e === "vorbis" ? "vorbis" : e === "flac" ? "flac" : e === "ac-3" || e === "ac3" ? "ac3" : e === "ec-3" || e === "eac3" ? "eac3" : e === "ulaw" ? "ulaw" : e === "alaw" ? "alaw" : Ne.test(e) ? e : e === "webvtt" ? "webvtt" : null, Fe = (e) => e === "avc" ? { avc: { format: "avc" } } : e === "hevc" ? { hevc: { format: "hevc" } } : {}, Ie = [
|
|
924
|
+
"avc1",
|
|
925
|
+
"avc3",
|
|
926
|
+
"hev1",
|
|
927
|
+
"hvc1",
|
|
928
|
+
"vp8",
|
|
929
|
+
"vp09",
|
|
930
|
+
"av01",
|
|
931
|
+
...I
|
|
932
|
+
], Le = /^(avc1|avc3)\.[0-9a-fA-F]{6}$/, Re = /^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/, ze = /^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/, Be = /^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/, Ve = (e, t) => {
|
|
933
|
+
if (!e) throw TypeError("Video chunk metadata must be provided.");
|
|
934
|
+
if (typeof e != "object") throw TypeError("Video chunk metadata must be an object.");
|
|
935
|
+
if (!e.decoderConfig) throw TypeError("Video chunk metadata must include a decoder configuration.");
|
|
936
|
+
if (typeof e.decoderConfig != "object") throw TypeError("Video chunk metadata decoder configuration must be an object.");
|
|
937
|
+
if (typeof e.decoderConfig.codec != "string") throw TypeError("Video chunk metadata decoder configuration must specify a codec string.");
|
|
938
|
+
if (!Ie.some((t) => e.decoderConfig.codec.startsWith(t))) throw TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the Mediabunny Codec Registry.");
|
|
939
|
+
if (!Number.isInteger(e.decoderConfig.codedWidth) || e.decoderConfig.codedWidth <= 0) throw TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");
|
|
940
|
+
if (!Number.isInteger(e.decoderConfig.codedHeight) || e.decoderConfig.codedHeight <= 0) throw TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");
|
|
941
|
+
if (e.decoderConfig.displayAspectWidth !== void 0 && (!Number.isInteger(e.decoderConfig.displayAspectWidth) || e.decoderConfig.displayAspectWidth <= 0)) throw TypeError("Video chunk metadata decoder configuration displayAspectWidth, when defined, must be a positive integer.");
|
|
942
|
+
if (e.decoderConfig.displayAspectHeight !== void 0 && (!Number.isInteger(e.decoderConfig.displayAspectHeight) || e.decoderConfig.displayAspectHeight <= 0)) throw TypeError("Video chunk metadata decoder configuration displayAspectHeight, when defined, must be a positive integer.");
|
|
943
|
+
if (e.decoderConfig.displayAspectWidth !== void 0 != (e.decoderConfig.displayAspectHeight !== void 0)) throw TypeError("Video chunk metadata decoder configuration must specify both displayAspectWidth and displayAspectHeight, or neither.");
|
|
944
|
+
if (e.decoderConfig.description !== void 0 && !p(e.decoderConfig.description)) throw TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");
|
|
945
|
+
if (e.decoderConfig.colorSpace !== void 0) {
|
|
946
|
+
let { colorSpace: t } = e.decoderConfig;
|
|
947
|
+
if (typeof t != "object") throw TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");
|
|
948
|
+
let n = Object.keys(l);
|
|
949
|
+
if (t.primaries != null && !n.includes(t.primaries)) throw TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${n.join(", ")}.`);
|
|
950
|
+
let r = Object.keys(u);
|
|
951
|
+
if (t.transfer != null && !r.includes(t.transfer)) throw TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${r.join(", ")}.`);
|
|
952
|
+
let i = Object.keys(d);
|
|
953
|
+
if (t.matrix != null && !i.includes(t.matrix)) throw TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${i.join(", ")}.`);
|
|
954
|
+
if (t.fullRange != null && typeof t.fullRange != "boolean") throw TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.");
|
|
955
|
+
}
|
|
956
|
+
if (e.decoderConfig.codec.startsWith("avc1") || e.decoderConfig.codec.startsWith("avc3")) {
|
|
957
|
+
if (!Le.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.");
|
|
958
|
+
} else if (e.decoderConfig.codec.startsWith("hev1") || e.decoderConfig.codec.startsWith("hvc1")) {
|
|
959
|
+
if (!Re.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.");
|
|
960
|
+
} else if (e.decoderConfig.codec.startsWith("vp8")) {
|
|
961
|
+
if (e.decoderConfig.codec !== "vp8") throw TypeError("Video chunk metadata decoder configuration codec string for VP8 must be \"vp8\".");
|
|
962
|
+
} else if (e.decoderConfig.codec.startsWith("vp09")) {
|
|
963
|
+
if (!ze.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section \"Codecs Parameter String\" of https://www.webmproject.org/vp9/mp4/.");
|
|
964
|
+
} else if (e.decoderConfig.codec.startsWith("av01")) {
|
|
965
|
+
if (!Be.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section \"Codecs Parameter String\" of https://aomediacodec.github.io/av1-isobmff/.");
|
|
966
|
+
} else if (I.some((t) => e.decoderConfig.codec.startsWith(t)) && !I.some((t) => e.decoderConfig.codec === t)) throw TypeError(`Video chunk metadata decoder configuration codec string for ProRes must be one of the valid ProRes four-character codes: ${I.join(", ")}.`);
|
|
967
|
+
if (t !== null && L(e.decoderConfig.codec) !== t) throw TypeError(`Video chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`);
|
|
968
|
+
}, He = [
|
|
969
|
+
"mp4a",
|
|
970
|
+
"mp3",
|
|
971
|
+
"opus",
|
|
972
|
+
"vorbis",
|
|
973
|
+
"flac",
|
|
974
|
+
"ulaw",
|
|
975
|
+
"alaw",
|
|
976
|
+
"pcm",
|
|
977
|
+
"ac-3",
|
|
978
|
+
"ec-3"
|
|
979
|
+
], Ue = (e, t) => {
|
|
980
|
+
if (!e) throw TypeError("Audio chunk metadata must be provided.");
|
|
981
|
+
if (typeof e != "object") throw TypeError("Audio chunk metadata must be an object.");
|
|
982
|
+
if (!e.decoderConfig) throw TypeError("Audio chunk metadata must include a decoder configuration.");
|
|
983
|
+
if (typeof e.decoderConfig != "object") throw TypeError("Audio chunk metadata decoder configuration must be an object.");
|
|
984
|
+
if (typeof e.decoderConfig.codec != "string") throw TypeError("Audio chunk metadata decoder configuration must specify a codec string.");
|
|
985
|
+
if (!He.some((t) => e.decoderConfig.codec.startsWith(t))) throw TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the Mediabunny Codec Registry.");
|
|
986
|
+
if (!Number.isInteger(e.decoderConfig.sampleRate) || e.decoderConfig.sampleRate <= 0) throw TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");
|
|
987
|
+
if (!Number.isInteger(e.decoderConfig.numberOfChannels) || e.decoderConfig.numberOfChannels <= 0) throw TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");
|
|
988
|
+
if (e.decoderConfig.description !== void 0 && !p(e.decoderConfig.description)) throw TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");
|
|
989
|
+
if (e.decoderConfig.codec.startsWith("mp4a") && e.decoderConfig.codec !== "mp4a.69" && e.decoderConfig.codec !== "mp4a.6B" && e.decoderConfig.codec !== "mp4a.6b") {
|
|
990
|
+
if (![
|
|
991
|
+
"mp4a.40.2",
|
|
992
|
+
"mp4a.40.02",
|
|
993
|
+
"mp4a.40.5",
|
|
994
|
+
"mp4a.40.05",
|
|
995
|
+
"mp4a.40.29",
|
|
996
|
+
"mp4a.67"
|
|
997
|
+
].includes(e.decoderConfig.codec)) throw TypeError("Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.");
|
|
998
|
+
} else if (e.decoderConfig.codec.startsWith("mp3") || e.decoderConfig.codec.startsWith("mp4a")) {
|
|
999
|
+
if (e.decoderConfig.codec !== "mp3" && e.decoderConfig.codec !== "mp4a.69" && e.decoderConfig.codec !== "mp4a.6B" && e.decoderConfig.codec !== "mp4a.6b") throw TypeError("Audio chunk metadata decoder configuration codec string for MP3 must be \"mp3\", \"mp4a.69\" or \"mp4a.6B\".");
|
|
1000
|
+
} else if (e.decoderConfig.codec.startsWith("opus")) {
|
|
1001
|
+
if (e.decoderConfig.codec !== "opus") throw TypeError("Audio chunk metadata decoder configuration codec string for Opus must be \"opus\".");
|
|
1002
|
+
if (e.decoderConfig.description && e.decoderConfig.description.byteLength < 18) throw TypeError("Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.");
|
|
1003
|
+
} else if (e.decoderConfig.codec.startsWith("vorbis")) {
|
|
1004
|
+
if (e.decoderConfig.codec !== "vorbis") throw TypeError("Audio chunk metadata decoder configuration codec string for Vorbis must be \"vorbis\".");
|
|
1005
|
+
if (!e.decoderConfig.description) throw TypeError("Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.");
|
|
1006
|
+
} else if (e.decoderConfig.codec.startsWith("flac")) {
|
|
1007
|
+
if (e.decoderConfig.codec !== "flac") throw TypeError("Audio chunk metadata decoder configuration codec string for FLAC must be \"flac\".");
|
|
1008
|
+
if (!e.decoderConfig.description || e.decoderConfig.description.byteLength < 42) throw TypeError("Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.");
|
|
1009
|
+
} else if (e.decoderConfig.codec.startsWith("ac-3") || e.decoderConfig.codec.startsWith("ac3")) {
|
|
1010
|
+
if (e.decoderConfig.codec !== "ac-3") throw TypeError("Audio chunk metadata decoder configuration codec string for AC-3 must be \"ac-3\".");
|
|
1011
|
+
} else if (e.decoderConfig.codec.startsWith("ec-3") || e.decoderConfig.codec.startsWith("eac3")) {
|
|
1012
|
+
if (e.decoderConfig.codec !== "ec-3") throw TypeError("Audio chunk metadata decoder configuration codec string for EC-3 must be \"ec-3\".");
|
|
1013
|
+
} else if ((e.decoderConfig.codec.startsWith("pcm") || e.decoderConfig.codec.startsWith("ulaw") || e.decoderConfig.codec.startsWith("alaw")) && !N.includes(e.decoderConfig.codec)) throw TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${N.join(", ")}).`);
|
|
1014
|
+
if (t !== null && L(e.decoderConfig.codec) !== t) throw TypeError(`Audio chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`);
|
|
1015
|
+
}, We = (e) => {
|
|
1016
|
+
if (!e) throw TypeError("Subtitle metadata must be provided.");
|
|
1017
|
+
if (typeof e != "object") throw TypeError("Subtitle metadata must be an object.");
|
|
1018
|
+
if (!e.config) throw TypeError("Subtitle metadata must include a config object.");
|
|
1019
|
+
if (typeof e.config != "object") throw TypeError("Subtitle metadata config must be an object.");
|
|
1020
|
+
if (typeof e.config.description != "string") throw TypeError("Subtitle metadata config description must be a string.");
|
|
1021
|
+
}, R;
|
|
1022
|
+
(function(e) {
|
|
1023
|
+
e[e.NON_IDR_SLICE = 1] = "NON_IDR_SLICE", e[e.SLICE_DPA = 2] = "SLICE_DPA", e[e.SLICE_DPB = 3] = "SLICE_DPB", e[e.SLICE_DPC = 4] = "SLICE_DPC", e[e.IDR = 5] = "IDR", e[e.SEI = 6] = "SEI", e[e.SPS = 7] = "SPS", e[e.PPS = 8] = "PPS", e[e.AUD = 9] = "AUD", e[e.SPS_EXT = 13] = "SPS_EXT";
|
|
1024
|
+
})(R ||= {});
|
|
1025
|
+
var Ge;
|
|
1026
|
+
(function(e) {
|
|
1027
|
+
e[e.RASL_N = 8] = "RASL_N", e[e.RASL_R = 9] = "RASL_R", e[e.BLA_W_LP = 16] = "BLA_W_LP", e[e.RSV_IRAP_VCL23 = 23] = "RSV_IRAP_VCL23", e[e.VPS_NUT = 32] = "VPS_NUT", e[e.SPS_NUT = 33] = "SPS_NUT", e[e.PPS_NUT = 34] = "PPS_NUT", e[e.AUD_NUT = 35] = "AUD_NUT", e[e.PREFIX_SEI_NUT = 39] = "PREFIX_SEI_NUT", e[e.SUFFIX_SEI_NUT = 40] = "SUFFIX_SEI_NUT";
|
|
1028
|
+
})(Ge ||= {});
|
|
1029
|
+
var Ke = function* (e) {
|
|
1030
|
+
let t = 0, n = -1;
|
|
1031
|
+
for (; t < e.length - 2;) {
|
|
1032
|
+
let r = e.indexOf(0, t);
|
|
1033
|
+
if (r === -1 || r >= e.length - 2) break;
|
|
1034
|
+
t = r;
|
|
1035
|
+
let i = 0;
|
|
1036
|
+
if (t + 3 < e.length && e[t + 1] === 0 && e[t + 2] === 0 && e[t + 3] === 1 ? i = 4 : e[t + 1] === 0 && e[t + 2] === 1 && (i = 3), i === 0) {
|
|
1037
|
+
t++;
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
n !== -1 && t > n && (yield {
|
|
1041
|
+
offset: n,
|
|
1042
|
+
length: t - n
|
|
1043
|
+
}), n = t + i, t = n;
|
|
1044
|
+
}
|
|
1045
|
+
n !== -1 && n < e.length && (yield {
|
|
1046
|
+
offset: n,
|
|
1047
|
+
length: e.length - n
|
|
1048
|
+
});
|
|
1049
|
+
}, qe = function* (e, n) {
|
|
1050
|
+
let r = 0, i = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1051
|
+
for (; r + n <= e.length;) {
|
|
1052
|
+
let e;
|
|
1053
|
+
n === 1 ? e = i.getUint8(r) : n === 2 ? e = i.getUint16(r, !1) : n === 3 ? e = ee(i, r, !1) : (t(n === 4), e = i.getUint32(r, !1)), r += n, yield {
|
|
1054
|
+
offset: r,
|
|
1055
|
+
length: e
|
|
1056
|
+
}, r += e;
|
|
1057
|
+
}
|
|
1058
|
+
}, Je = (e, t) => t.description ? qe(e, (o(t.description)[4] & 3) + 1) : Ke(e), Ye = (e) => e & 31, Xe = (e) => {
|
|
1059
|
+
let t = [], n = e.length;
|
|
1060
|
+
for (let r = 0; r < n; r++) r + 2 < n && e[r] === 0 && e[r + 1] === 0 && e[r + 2] === 3 ? (t.push(0, 0), r += 2) : t.push(e[r]);
|
|
1061
|
+
return new Uint8Array(t);
|
|
1062
|
+
};
|
|
1063
|
+
new Uint8Array([
|
|
1064
|
+
0,
|
|
1065
|
+
0,
|
|
1066
|
+
0,
|
|
1067
|
+
1
|
|
1068
|
+
]);
|
|
1069
|
+
var Ze = (e, t) => t.description ? qe(e, (o(t.description)[21] & 3) + 1) : Ke(e), Qe = (e) => e >> 1 & 63, $e;
|
|
1070
|
+
(function(e) {
|
|
1071
|
+
e[e.audAllowed = 0] = "audAllowed", e[e.beforeFirstVcl = 1] = "beforeFirstVcl", e[e.afterFirstVcl = 2] = "afterFirstVcl", e[e.eoBitstreamAllowed = 3] = "eoBitstreamAllowed", e[e.noMoreDataAllowed = 4] = "noMoreDataAllowed";
|
|
1072
|
+
})($e ||= {});
|
|
1073
|
+
var et = function* (e) {
|
|
1074
|
+
let n = new j(e), r = () => {
|
|
1075
|
+
let e = 0;
|
|
1076
|
+
for (let t = 0; t < 8; t++) {
|
|
1077
|
+
let r = n.readAlignedByte();
|
|
1078
|
+
if (e |= (r & 127) << t * 7, !(r & 128)) break;
|
|
1079
|
+
if (t === 7 && r & 128) return null;
|
|
1080
|
+
}
|
|
1081
|
+
return e >= 2 ** 32 - 1 ? null : e;
|
|
1082
|
+
};
|
|
1083
|
+
for (; n.getBitsLeft() >= 8;) {
|
|
1084
|
+
n.skipBits(1);
|
|
1085
|
+
let i = n.readBits(4), a = n.readBits(1), o = n.readBits(1);
|
|
1086
|
+
n.skipBits(1), a && n.skipBits(8);
|
|
1087
|
+
let s;
|
|
1088
|
+
if (o) {
|
|
1089
|
+
let e = r();
|
|
1090
|
+
if (e === null) return;
|
|
1091
|
+
s = e;
|
|
1092
|
+
} else s = Math.floor(n.getBitsLeft() / 8);
|
|
1093
|
+
t(n.pos % 8 == 0), yield {
|
|
1094
|
+
type: i,
|
|
1095
|
+
data: e.subarray(n.pos / 8, n.pos / 8 + s)
|
|
1096
|
+
}, n.skipBits(s * 8);
|
|
1097
|
+
}
|
|
1098
|
+
}, tt = (e) => {
|
|
1099
|
+
let t = s(e), n = t.getUint8(9), r = t.getUint16(10, !0), i = t.getUint32(12, !0), a = t.getInt16(16, !0), o = t.getUint8(18), c = null;
|
|
1100
|
+
return o && (c = e.subarray(19, 21 + n)), {
|
|
1101
|
+
outputChannelCount: n,
|
|
1102
|
+
preSkip: r,
|
|
1103
|
+
inputSampleRate: i,
|
|
1104
|
+
outputGain: a,
|
|
1105
|
+
channelMappingFamily: o,
|
|
1106
|
+
channelMappingTable: c
|
|
1107
|
+
};
|
|
1108
|
+
}, nt = (e, n, r) => {
|
|
1109
|
+
switch (e) {
|
|
1110
|
+
case "avc":
|
|
1111
|
+
for (let e of Je(r, n)) {
|
|
1112
|
+
let t = r[e.offset], n = Ye(t);
|
|
1113
|
+
if (n >= R.NON_IDR_SLICE && n <= R.SLICE_DPC) return "delta";
|
|
1114
|
+
if (n === R.IDR) return "key";
|
|
1115
|
+
if (n === R.SEI && (!ae() || oe() >= 144)) {
|
|
1116
|
+
let t = Xe(r.subarray(e.offset, e.offset + e.length)), n = 1;
|
|
1117
|
+
do {
|
|
1118
|
+
let e = 0;
|
|
1119
|
+
for (;;) {
|
|
1120
|
+
let r = t[n++];
|
|
1121
|
+
if (r === void 0 || (e += r, r < 255)) break;
|
|
1122
|
+
}
|
|
1123
|
+
let r = 0;
|
|
1124
|
+
for (;;) {
|
|
1125
|
+
let e = t[n++];
|
|
1126
|
+
if (e === void 0 || (r += e, e < 255)) break;
|
|
1127
|
+
}
|
|
1128
|
+
if (e === 6) {
|
|
1129
|
+
let e = new j(t);
|
|
1130
|
+
e.pos = 8 * n;
|
|
1131
|
+
let r = i(e), a = e.readBits(1);
|
|
1132
|
+
if (r === 0 && a === 1) return "key";
|
|
1133
|
+
}
|
|
1134
|
+
n += r;
|
|
1135
|
+
} while (n < t.length - 1);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return "delta";
|
|
1139
|
+
case "hevc":
|
|
1140
|
+
for (let e of Ze(r, n)) {
|
|
1141
|
+
let t = Qe(r[e.offset]);
|
|
1142
|
+
if (t < Ge.BLA_W_LP) return "delta";
|
|
1143
|
+
if (t <= Ge.RSV_IRAP_VCL23) return "key";
|
|
1144
|
+
}
|
|
1145
|
+
return "delta";
|
|
1146
|
+
case "vp8": return r[0] & 1 ? "delta" : "key";
|
|
1147
|
+
case "vp9": {
|
|
1148
|
+
let e = new j(r);
|
|
1149
|
+
if (e.readBits(2) !== 2) return null;
|
|
1150
|
+
let t = e.readBits(1);
|
|
1151
|
+
return (e.readBits(1) << 1) + t === 3 && e.skipBits(1), e.readBits(1) ? null : e.readBits(1) === 0 ? "key" : "delta";
|
|
1152
|
+
}
|
|
1153
|
+
case "av1": {
|
|
1154
|
+
let e = !1;
|
|
1155
|
+
for (let { type: t, data: n } of et(r)) if (t === 1) {
|
|
1156
|
+
let t = new j(n);
|
|
1157
|
+
t.skipBits(4), e = !!t.readBits(1);
|
|
1158
|
+
} else if (t === 3 || t === 6 || t === 7) {
|
|
1159
|
+
if (e) return "key";
|
|
1160
|
+
let t = new j(n);
|
|
1161
|
+
return t.readBits(1) ? null : t.readBits(2) === 0 ? "key" : "delta";
|
|
1162
|
+
}
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
case "prores": return "key";
|
|
1166
|
+
default: _(e), t(!1);
|
|
1167
|
+
}
|
|
1168
|
+
}, rt;
|
|
1169
|
+
(function(e) {
|
|
1170
|
+
e[e.STREAMINFO = 0] = "STREAMINFO", e[e.VORBIS_COMMENT = 4] = "VORBIS_COMMENT", e[e.PICTURE = 6] = "PICTURE";
|
|
1171
|
+
})(rt ||= {}), new Uint8Array([
|
|
1172
|
+
5,
|
|
1173
|
+
4,
|
|
1174
|
+
65,
|
|
1175
|
+
67,
|
|
1176
|
+
45,
|
|
1177
|
+
51
|
|
1178
|
+
]), new Uint8Array([
|
|
1179
|
+
5,
|
|
1180
|
+
4,
|
|
1181
|
+
69,
|
|
1182
|
+
65,
|
|
1183
|
+
67,
|
|
1184
|
+
51
|
|
1185
|
+
]);
|
|
1186
|
+
//#endregion
|
|
1187
|
+
//#region node_modules/.pnpm/mediabunny@1.54.0/node_modules/mediabunny/dist/modules/src/packet.js
|
|
1188
|
+
var it = /* #__PURE__ */ new Uint8Array(), z = class e {
|
|
1189
|
+
constructor(e, t, n, r, i = -1, a, o) {
|
|
1190
|
+
if (this.data = e, this.type = t, this.timestamp = n, this.duration = r, this.sequenceNumber = i, e === it && a === void 0) throw Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");
|
|
1191
|
+
if (a === void 0 && (a = e.byteLength), !(e instanceof Uint8Array)) throw TypeError("data must be a Uint8Array.");
|
|
1192
|
+
if (t !== "key" && t !== "delta") throw TypeError("type must be either \"key\" or \"delta\".");
|
|
1193
|
+
if (!Number.isFinite(n)) throw TypeError("timestamp must be a number.");
|
|
1194
|
+
if (!Number.isFinite(r) || r < 0) throw TypeError("duration must be a non-negative number.");
|
|
1195
|
+
if (!Number.isFinite(i)) throw TypeError("sequenceNumber must be a number.");
|
|
1196
|
+
if (!Number.isInteger(a) || a < 0) throw TypeError("byteLength must be a non-negative integer.");
|
|
1197
|
+
if (o !== void 0 && (typeof o != "object" || !o)) throw TypeError("sideData, when provided, must be an object.");
|
|
1198
|
+
if (o?.alpha !== void 0 && !(o.alpha instanceof Uint8Array)) throw TypeError("sideData.alpha, when provided, must be a Uint8Array.");
|
|
1199
|
+
if (o?.alphaByteLength !== void 0 && (!Number.isInteger(o.alphaByteLength) || o.alphaByteLength < 0)) throw TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");
|
|
1200
|
+
this.byteLength = a, this.sideData = o ?? {}, this.sideData.alpha && this.sideData.alphaByteLength === void 0 && (this.sideData.alphaByteLength = this.sideData.alpha.byteLength);
|
|
1201
|
+
}
|
|
1202
|
+
get isMetadataOnly() {
|
|
1203
|
+
return this.data === it;
|
|
1204
|
+
}
|
|
1205
|
+
get microsecondTimestamp() {
|
|
1206
|
+
return Math.trunc(C * this.timestamp);
|
|
1207
|
+
}
|
|
1208
|
+
get microsecondDuration() {
|
|
1209
|
+
return Math.trunc(C * this.duration);
|
|
1210
|
+
}
|
|
1211
|
+
toEncodedVideoChunk() {
|
|
1212
|
+
if (this.isMetadataOnly) throw TypeError("Metadata-only packets cannot be converted to a video chunk.");
|
|
1213
|
+
if (typeof EncodedVideoChunk > "u") throw Error("Your browser does not support EncodedVideoChunk.");
|
|
1214
|
+
return new EncodedVideoChunk({
|
|
1215
|
+
data: this.data,
|
|
1216
|
+
type: this.type,
|
|
1217
|
+
timestamp: this.microsecondTimestamp,
|
|
1218
|
+
duration: this.microsecondDuration
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
alphaToEncodedVideoChunk(e = this.type) {
|
|
1222
|
+
if (!this.sideData.alpha) throw TypeError("This packet does not contain alpha side data.");
|
|
1223
|
+
if (this.isMetadataOnly) throw TypeError("Metadata-only packets cannot be converted to a video chunk.");
|
|
1224
|
+
if (typeof EncodedVideoChunk > "u") throw Error("Your browser does not support EncodedVideoChunk.");
|
|
1225
|
+
return new EncodedVideoChunk({
|
|
1226
|
+
data: this.sideData.alpha,
|
|
1227
|
+
type: e,
|
|
1228
|
+
timestamp: this.microsecondTimestamp,
|
|
1229
|
+
duration: this.microsecondDuration
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
toEncodedAudioChunk() {
|
|
1233
|
+
if (this.isMetadataOnly) throw TypeError("Metadata-only packets cannot be converted to an audio chunk.");
|
|
1234
|
+
if (typeof EncodedAudioChunk > "u") throw Error("Your browser does not support EncodedAudioChunk.");
|
|
1235
|
+
return new EncodedAudioChunk({
|
|
1236
|
+
data: this.data,
|
|
1237
|
+
type: this.type,
|
|
1238
|
+
timestamp: this.microsecondTimestamp,
|
|
1239
|
+
duration: this.microsecondDuration
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
static fromEncodedChunk(t, n) {
|
|
1243
|
+
if (!(t instanceof EncodedVideoChunk || t instanceof EncodedAudioChunk)) throw TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");
|
|
1244
|
+
let r = new Uint8Array(t.byteLength);
|
|
1245
|
+
return t.copyTo(r), new e(r, t.type, t.timestamp / 1e6, (t.duration ?? 0) / 1e6, void 0, void 0, n);
|
|
1246
|
+
}
|
|
1247
|
+
clone(t) {
|
|
1248
|
+
if (t !== void 0 && (typeof t != "object" || !t)) throw TypeError("options, when provided, must be an object.");
|
|
1249
|
+
if (t?.data !== void 0 && !(t.data instanceof Uint8Array)) throw TypeError("options.data, when provided, must be a Uint8Array.");
|
|
1250
|
+
if (t?.type !== void 0 && t.type !== "key" && t.type !== "delta") throw TypeError("options.type, when provided, must be either \"key\" or \"delta\".");
|
|
1251
|
+
if (t?.timestamp !== void 0 && !Number.isFinite(t.timestamp)) throw TypeError("options.timestamp, when provided, must be a number.");
|
|
1252
|
+
if (t?.duration !== void 0 && !Number.isFinite(t.duration)) throw TypeError("options.duration, when provided, must be a number.");
|
|
1253
|
+
if (t?.sequenceNumber !== void 0 && !Number.isFinite(t.sequenceNumber)) throw TypeError("options.sequenceNumber, when provided, must be a number.");
|
|
1254
|
+
if (t?.sideData !== void 0 && (typeof t.sideData != "object" || t.sideData === null)) throw TypeError("options.sideData, when provided, must be an object.");
|
|
1255
|
+
return new e(t?.data ?? this.data, t?.type ?? this.type, t?.timestamp ?? this.timestamp, t?.duration ?? this.duration, t?.sequenceNumber ?? this.sequenceNumber, this.byteLength, t?.sideData ?? this.sideData);
|
|
1256
|
+
}
|
|
1257
|
+
}, at = class {
|
|
1258
|
+
constructor(e) {
|
|
1259
|
+
this.value = e;
|
|
1260
|
+
}
|
|
1261
|
+
}, ot = class {
|
|
1262
|
+
constructor(e) {
|
|
1263
|
+
this.value = e;
|
|
1264
|
+
}
|
|
1265
|
+
}, st = class {
|
|
1266
|
+
constructor(e) {
|
|
1267
|
+
this.value = e;
|
|
1268
|
+
}
|
|
1269
|
+
}, B = class {
|
|
1270
|
+
constructor(e) {
|
|
1271
|
+
this.value = e;
|
|
1272
|
+
}
|
|
1273
|
+
}, V;
|
|
1274
|
+
(function(e) {
|
|
1275
|
+
e[e.EBML = 440786851] = "EBML", e[e.EBMLVersion = 17030] = "EBMLVersion", e[e.EBMLReadVersion = 17143] = "EBMLReadVersion", e[e.EBMLMaxIDLength = 17138] = "EBMLMaxIDLength", e[e.EBMLMaxSizeLength = 17139] = "EBMLMaxSizeLength", e[e.DocType = 17026] = "DocType", e[e.DocTypeVersion = 17031] = "DocTypeVersion", e[e.DocTypeReadVersion = 17029] = "DocTypeReadVersion", e[e.Void = 236] = "Void", e[e.Segment = 408125543] = "Segment", e[e.SeekHead = 290298740] = "SeekHead", e[e.Seek = 19899] = "Seek", e[e.SeekID = 21419] = "SeekID", e[e.SeekPosition = 21420] = "SeekPosition", e[e.Duration = 17545] = "Duration", e[e.Info = 357149030] = "Info", e[e.TimestampScale = 2807729] = "TimestampScale", e[e.MuxingApp = 19840] = "MuxingApp", e[e.WritingApp = 22337] = "WritingApp", e[e.Tracks = 374648427] = "Tracks", e[e.TrackEntry = 174] = "TrackEntry", e[e.TrackNumber = 215] = "TrackNumber", e[e.TrackUID = 29637] = "TrackUID", e[e.TrackType = 131] = "TrackType", e[e.FlagEnabled = 185] = "FlagEnabled", e[e.FlagDefault = 136] = "FlagDefault", e[e.FlagForced = 21930] = "FlagForced", e[e.FlagOriginal = 21934] = "FlagOriginal", e[e.FlagHearingImpaired = 21931] = "FlagHearingImpaired", e[e.FlagVisualImpaired = 21932] = "FlagVisualImpaired", e[e.FlagCommentary = 21935] = "FlagCommentary", e[e.FlagLacing = 156] = "FlagLacing", e[e.Name = 21358] = "Name", e[e.Language = 2274716] = "Language", e[e.LanguageBCP47 = 2274717] = "LanguageBCP47", e[e.CodecID = 134] = "CodecID", e[e.CodecPrivate = 25506] = "CodecPrivate", e[e.CodecDelay = 22186] = "CodecDelay", e[e.SeekPreRoll = 22203] = "SeekPreRoll", e[e.DefaultDuration = 2352003] = "DefaultDuration", e[e.Video = 224] = "Video", e[e.PixelWidth = 176] = "PixelWidth", e[e.PixelHeight = 186] = "PixelHeight", e[e.DisplayWidth = 21680] = "DisplayWidth", e[e.DisplayHeight = 21690] = "DisplayHeight", e[e.DisplayUnit = 21682] = "DisplayUnit", e[e.AlphaMode = 21440] = "AlphaMode", e[e.Audio = 225] = "Audio", e[e.SamplingFrequency = 181] = "SamplingFrequency", e[e.Channels = 159] = "Channels", e[e.BitDepth = 25188] = "BitDepth", e[e.SimpleBlock = 163] = "SimpleBlock", e[e.BlockGroup = 160] = "BlockGroup", e[e.Block = 161] = "Block", e[e.BlockAdditions = 30113] = "BlockAdditions", e[e.BlockMore = 166] = "BlockMore", e[e.BlockAdditional = 165] = "BlockAdditional", e[e.BlockAddID = 238] = "BlockAddID", e[e.BlockDuration = 155] = "BlockDuration", e[e.ReferenceBlock = 251] = "ReferenceBlock", e[e.Cluster = 524531317] = "Cluster", e[e.Timestamp = 231] = "Timestamp", e[e.Cues = 475249515] = "Cues", e[e.CuePoint = 187] = "CuePoint", e[e.CueTime = 179] = "CueTime", e[e.CueTrackPositions = 183] = "CueTrackPositions", e[e.CueTrack = 247] = "CueTrack", e[e.CueClusterPosition = 241] = "CueClusterPosition", e[e.Colour = 21936] = "Colour", e[e.MatrixCoefficients = 21937] = "MatrixCoefficients", e[e.TransferCharacteristics = 21946] = "TransferCharacteristics", e[e.Primaries = 21947] = "Primaries", e[e.Range = 21945] = "Range", e[e.Projection = 30320] = "Projection", e[e.ProjectionType = 30321] = "ProjectionType", e[e.ProjectionPoseRoll = 30325] = "ProjectionPoseRoll", e[e.Attachments = 423732329] = "Attachments", e[e.AttachedFile = 24999] = "AttachedFile", e[e.FileDescription = 18046] = "FileDescription", e[e.FileName = 18030] = "FileName", e[e.FileMediaType = 18016] = "FileMediaType", e[e.FileData = 18012] = "FileData", e[e.FileUID = 18094] = "FileUID", e[e.Chapters = 272869232] = "Chapters", e[e.Tags = 307544935] = "Tags", e[e.Tag = 29555] = "Tag", e[e.Targets = 25536] = "Targets", e[e.TargetTypeValue = 26826] = "TargetTypeValue", e[e.TargetType = 25546] = "TargetType", e[e.TagTrackUID = 25541] = "TagTrackUID", e[e.TagEditionUID = 25545] = "TagEditionUID", e[e.TagChapterUID = 25540] = "TagChapterUID", e[e.TagAttachmentUID = 25542] = "TagAttachmentUID", e[e.SimpleTag = 26568] = "SimpleTag", e[e.TagName = 17827] = "TagName", e[e.TagLanguage = 17530] = "TagLanguage", e[e.TagString = 17543] = "TagString", e[e.TagBinary = 17541] = "TagBinary", e[e.ContentEncodings = 28032] = "ContentEncodings", e[e.ContentEncoding = 25152] = "ContentEncoding", e[e.ContentEncodingOrder = 20529] = "ContentEncodingOrder", e[e.ContentEncodingScope = 20530] = "ContentEncodingScope", e[e.ContentCompression = 20532] = "ContentCompression", e[e.ContentCompAlgo = 16980] = "ContentCompAlgo", e[e.ContentCompSettings = 16981] = "ContentCompSettings", e[e.ContentEncryption = 20533] = "ContentEncryption";
|
|
1276
|
+
})(V ||= {});
|
|
1277
|
+
var ct = [V.EBML, V.Segment], lt = [
|
|
1278
|
+
V.SeekHead,
|
|
1279
|
+
V.Info,
|
|
1280
|
+
V.Cluster,
|
|
1281
|
+
V.Tracks,
|
|
1282
|
+
V.Cues,
|
|
1283
|
+
V.Attachments,
|
|
1284
|
+
V.Chapters,
|
|
1285
|
+
V.Tags
|
|
1286
|
+
];
|
|
1287
|
+
[...ct, ...lt];
|
|
1288
|
+
var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4 : e < 2 ** 40 ? 5 : 6, dt = (e) => e < 1n << 8n ? 1 : e < 1n << 16n ? 2 : e < 1n << 24n ? 3 : e < 1n << 32n ? 4 : e < 1n << 40n ? 5 : e < 1n << 48n ? 6 : e < 1n << 56n ? 7 : 8, ft = (e) => e >= -64 && e < 64 ? 1 : e >= -8192 && e < 8192 ? 2 : e >= -1048576 && e < 1 << 20 ? 3 : e >= -134217728 && e < 1 << 27 ? 4 : e >= -(2 ** 34) && e < 2 ** 34 ? 5 : 6, pt = (e) => {
|
|
1289
|
+
if (e < 127) return 1;
|
|
1290
|
+
if (e < 16383) return 2;
|
|
1291
|
+
if (e < (1 << 21) - 1) return 3;
|
|
1292
|
+
if (e < (1 << 28) - 1) return 4;
|
|
1293
|
+
if (e < 2 ** 35 - 1) return 5;
|
|
1294
|
+
if (e < 2 ** 42 - 1) return 6;
|
|
1295
|
+
throw Error("EBML varint size not supported " + e);
|
|
1296
|
+
}, mt = class {
|
|
1297
|
+
constructor(e) {
|
|
1298
|
+
this.writer = e, this.helper = /* @__PURE__ */ new Uint8Array(8), this.helperView = new DataView(this.helper.buffer), this.offsets = /* @__PURE__ */ new WeakMap(), this.dataOffsets = /* @__PURE__ */ new WeakMap();
|
|
1299
|
+
}
|
|
1300
|
+
writeByte(e) {
|
|
1301
|
+
this.helperView.setUint8(0, e), this.writer.write(this.helper.subarray(0, 1));
|
|
1302
|
+
}
|
|
1303
|
+
writeFloat32(e) {
|
|
1304
|
+
this.helperView.setFloat32(0, e, !1), this.writer.write(this.helper.subarray(0, 4));
|
|
1305
|
+
}
|
|
1306
|
+
writeFloat64(e) {
|
|
1307
|
+
this.helperView.setFloat64(0, e, !1), this.writer.write(this.helper);
|
|
1308
|
+
}
|
|
1309
|
+
writeUnsignedInt(e, t = ut(e)) {
|
|
1310
|
+
let n = 0;
|
|
1311
|
+
switch (t) {
|
|
1312
|
+
case 6: this.helperView.setUint8(n++, e / 2 ** 40 | 0);
|
|
1313
|
+
case 5: this.helperView.setUint8(n++, e / 2 ** 32 | 0);
|
|
1314
|
+
case 4: this.helperView.setUint8(n++, e >> 24);
|
|
1315
|
+
case 3: this.helperView.setUint8(n++, e >> 16);
|
|
1316
|
+
case 2: this.helperView.setUint8(n++, e >> 8);
|
|
1317
|
+
case 1:
|
|
1318
|
+
this.helperView.setUint8(n++, e);
|
|
1319
|
+
break;
|
|
1320
|
+
default: throw Error("Bad unsigned int size " + t);
|
|
1321
|
+
}
|
|
1322
|
+
this.writer.write(this.helper.subarray(0, n));
|
|
1323
|
+
}
|
|
1324
|
+
writeUnsignedBigInt(e, t = dt(e)) {
|
|
1325
|
+
let n = 0;
|
|
1326
|
+
for (let r = t - 1; r >= 0; r--) this.helperView.setUint8(n++, Number(e >> BigInt(r * 8) & 255n));
|
|
1327
|
+
this.writer.write(this.helper.subarray(0, n));
|
|
1328
|
+
}
|
|
1329
|
+
writeSignedInt(e, t = ft(e)) {
|
|
1330
|
+
e < 0 && (e += 2 ** (t * 8)), this.writeUnsignedInt(e, t);
|
|
1331
|
+
}
|
|
1332
|
+
writeVarInt(e, t = pt(e)) {
|
|
1333
|
+
let n = 0;
|
|
1334
|
+
switch (t) {
|
|
1335
|
+
case 1:
|
|
1336
|
+
this.helperView.setUint8(n++, 128 | e);
|
|
1337
|
+
break;
|
|
1338
|
+
case 2:
|
|
1339
|
+
this.helperView.setUint8(n++, 64 | e >> 8), this.helperView.setUint8(n++, e);
|
|
1340
|
+
break;
|
|
1341
|
+
case 3:
|
|
1342
|
+
this.helperView.setUint8(n++, 32 | e >> 16), this.helperView.setUint8(n++, e >> 8), this.helperView.setUint8(n++, e);
|
|
1343
|
+
break;
|
|
1344
|
+
case 4:
|
|
1345
|
+
this.helperView.setUint8(n++, 16 | e >> 24), this.helperView.setUint8(n++, e >> 16), this.helperView.setUint8(n++, e >> 8), this.helperView.setUint8(n++, e);
|
|
1346
|
+
break;
|
|
1347
|
+
case 5:
|
|
1348
|
+
this.helperView.setUint8(n++, 8 | e / 2 ** 32 & 7), this.helperView.setUint8(n++, e >> 24), this.helperView.setUint8(n++, e >> 16), this.helperView.setUint8(n++, e >> 8), this.helperView.setUint8(n++, e);
|
|
1349
|
+
break;
|
|
1350
|
+
case 6:
|
|
1351
|
+
this.helperView.setUint8(n++, 4 | e / 2 ** 40 & 3), this.helperView.setUint8(n++, e / 2 ** 32 | 0), this.helperView.setUint8(n++, e >> 24), this.helperView.setUint8(n++, e >> 16), this.helperView.setUint8(n++, e >> 8), this.helperView.setUint8(n++, e);
|
|
1352
|
+
break;
|
|
1353
|
+
default: throw Error("Bad EBML varint size " + t);
|
|
1354
|
+
}
|
|
1355
|
+
this.writer.write(this.helper.subarray(0, n));
|
|
1356
|
+
}
|
|
1357
|
+
writeAsciiString(e) {
|
|
1358
|
+
this.writer.write(new Uint8Array(e.split("").map((e) => e.charCodeAt(0))));
|
|
1359
|
+
}
|
|
1360
|
+
writeEBML(e) {
|
|
1361
|
+
if (e !== null) {
|
|
1362
|
+
if (e instanceof Uint8Array) this.writer.write(e);
|
|
1363
|
+
else if (Array.isArray(e)) for (let t of e) this.writeEBML(t);
|
|
1364
|
+
else if (this.offsets.set(e, this.writer.getPos()), this.writeUnsignedInt(e.id), Array.isArray(e.data)) {
|
|
1365
|
+
let t = this.writer.getPos(), n = e.size === -1 ? 1 : e.size ?? 4;
|
|
1366
|
+
e.size === -1 ? this.writeByte(255) : this.writer.seek(this.writer.getPos() + n);
|
|
1367
|
+
let r = this.writer.getPos();
|
|
1368
|
+
if (this.dataOffsets.set(e, r), this.writeEBML(e.data), e.size !== -1) {
|
|
1369
|
+
let e = this.writer.getPos() - r, i = this.writer.getPos();
|
|
1370
|
+
this.writer.seek(t), this.writeVarInt(e, n), this.writer.seek(i);
|
|
1371
|
+
}
|
|
1372
|
+
} else if (typeof e.data == "number") {
|
|
1373
|
+
let t = e.size ?? ut(e.data);
|
|
1374
|
+
this.writeVarInt(t), this.writeUnsignedInt(e.data, t);
|
|
1375
|
+
} else if (typeof e.data == "bigint") {
|
|
1376
|
+
let t = e.size ?? dt(e.data);
|
|
1377
|
+
this.writeVarInt(t), this.writeUnsignedBigInt(e.data, t);
|
|
1378
|
+
} else if (typeof e.data == "string") this.writeVarInt(e.data.length), this.writeAsciiString(e.data);
|
|
1379
|
+
else if (e.data instanceof Uint8Array) this.writeVarInt(e.data.byteLength, e.size), this.writer.write(e.data);
|
|
1380
|
+
else if (e.data instanceof at) this.writeVarInt(4), this.writeFloat32(e.data.value);
|
|
1381
|
+
else if (e.data instanceof ot) this.writeVarInt(8), this.writeFloat64(e.data.value);
|
|
1382
|
+
else if (e.data instanceof st) {
|
|
1383
|
+
let t = e.size ?? ft(e.data.value);
|
|
1384
|
+
this.writeVarInt(t), this.writeSignedInt(e.data.value, t);
|
|
1385
|
+
} else if (e.data instanceof B) {
|
|
1386
|
+
let t = c.encode(e.data.value);
|
|
1387
|
+
this.writeVarInt(t.length), this.writer.write(t);
|
|
1388
|
+
} else _(e.data);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}, ht = {
|
|
1392
|
+
avc: "V_MPEG4/ISO/AVC",
|
|
1393
|
+
hevc: "V_MPEGH/ISO/HEVC",
|
|
1394
|
+
vp8: "V_VP8",
|
|
1395
|
+
vp9: "V_VP9",
|
|
1396
|
+
av1: "V_AV1",
|
|
1397
|
+
prores: "V_PRORES",
|
|
1398
|
+
aac: "A_AAC",
|
|
1399
|
+
mp3: "A_MPEG/L3",
|
|
1400
|
+
opus: "A_OPUS",
|
|
1401
|
+
vorbis: "A_VORBIS",
|
|
1402
|
+
flac: "A_FLAC",
|
|
1403
|
+
ac3: "A_AC3",
|
|
1404
|
+
eac3: "A_EAC3",
|
|
1405
|
+
"pcm-u8": "A_PCM/INT/LIT",
|
|
1406
|
+
"pcm-s16": "A_PCM/INT/LIT",
|
|
1407
|
+
"pcm-s16be": "A_PCM/INT/BIG",
|
|
1408
|
+
"pcm-s24": "A_PCM/INT/LIT",
|
|
1409
|
+
"pcm-s24be": "A_PCM/INT/BIG",
|
|
1410
|
+
"pcm-s32": "A_PCM/INT/LIT",
|
|
1411
|
+
"pcm-s32be": "A_PCM/INT/BIG",
|
|
1412
|
+
"pcm-f32": "A_PCM/FLOAT/IEEE",
|
|
1413
|
+
"pcm-f64": "A_PCM/FLOAT/IEEE",
|
|
1414
|
+
webvtt: "S_TEXT/WEBVTT"
|
|
1415
|
+
}, gt = (e) => {
|
|
1416
|
+
let t = (e.hasVideo ? "video/" : e.hasAudio ? "audio/" : "application/") + (e.isWebM ? "webm" : "x-matroska");
|
|
1417
|
+
if (e.codecStrings.length > 0) {
|
|
1418
|
+
let n = [...new Set(e.codecStrings.filter(Boolean))];
|
|
1419
|
+
t += `; codecs="${n.join(", ")}"`;
|
|
1420
|
+
}
|
|
1421
|
+
return t;
|
|
1422
|
+
}, _t = (e) => {
|
|
1423
|
+
let t = e.filePos, n = new j(Kt(e, 9));
|
|
1424
|
+
if (n.readBits(12) !== 4095 || (n.skipBits(1), n.readBits(2) !== 0)) return null;
|
|
1425
|
+
let r = n.readBits(1), i = n.readBits(2) + 1, a = n.readBits(4);
|
|
1426
|
+
if (a === 15) return null;
|
|
1427
|
+
n.skipBits(1);
|
|
1428
|
+
let o = n.readBits(3);
|
|
1429
|
+
if (o === 0) throw Error("ADTS frames with channel configuration 0 are not supported.");
|
|
1430
|
+
n.skipBits(1), n.skipBits(1), n.skipBits(1), n.skipBits(1);
|
|
1431
|
+
let s = n.readBits(13);
|
|
1432
|
+
n.skipBits(11);
|
|
1433
|
+
let c = n.readBits(2) + 1;
|
|
1434
|
+
if (c !== 1) throw Error("ADTS frames with more than one AAC frame are not supported.");
|
|
1435
|
+
let l = null;
|
|
1436
|
+
return r === 1 ? e.filePos -= 2 : l = n.readBits(16), {
|
|
1437
|
+
objectType: i,
|
|
1438
|
+
samplingFrequencyIndex: a,
|
|
1439
|
+
channelConfiguration: o,
|
|
1440
|
+
frameLength: s,
|
|
1441
|
+
numberOfAacFrames: c,
|
|
1442
|
+
crcCheck: l,
|
|
1443
|
+
startPos: t
|
|
1444
|
+
};
|
|
1445
|
+
}, vt = function(e, t, n) {
|
|
1446
|
+
if (t != null) {
|
|
1447
|
+
if (typeof t != "object" && typeof t != "function") throw TypeError("Object expected.");
|
|
1448
|
+
var r, i;
|
|
1449
|
+
if (n) {
|
|
1450
|
+
if (!Symbol.asyncDispose) throw TypeError("Symbol.asyncDispose is not defined.");
|
|
1451
|
+
r = t[Symbol.asyncDispose];
|
|
1452
|
+
}
|
|
1453
|
+
if (r === void 0) {
|
|
1454
|
+
if (!Symbol.dispose) throw TypeError("Symbol.dispose is not defined.");
|
|
1455
|
+
r = t[Symbol.dispose], n && (i = r);
|
|
1456
|
+
}
|
|
1457
|
+
if (typeof r != "function") throw TypeError("Object not disposable.");
|
|
1458
|
+
i && (r = function() {
|
|
1459
|
+
try {
|
|
1460
|
+
i.call(this);
|
|
1461
|
+
} catch (e) {
|
|
1462
|
+
return Promise.reject(e);
|
|
1463
|
+
}
|
|
1464
|
+
}), e.stack.push({
|
|
1465
|
+
value: t,
|
|
1466
|
+
dispose: r,
|
|
1467
|
+
async: n
|
|
1468
|
+
});
|
|
1469
|
+
} else n && e.stack.push({ async: !0 });
|
|
1470
|
+
return t;
|
|
1471
|
+
}, yt = (function(e) {
|
|
1472
|
+
return function(t) {
|
|
1473
|
+
function n(n) {
|
|
1474
|
+
t.error = t.hasError ? new e(n, t.error, "An error was suppressed during disposal.") : n, t.hasError = !0;
|
|
1475
|
+
}
|
|
1476
|
+
var r, i = 0;
|
|
1477
|
+
function a() {
|
|
1478
|
+
for (; r = t.stack.pop();) try {
|
|
1479
|
+
if (!r.async && i === 1) return i = 0, t.stack.push(r), Promise.resolve().then(a);
|
|
1480
|
+
if (r.dispose) {
|
|
1481
|
+
var e = r.dispose.call(r.value);
|
|
1482
|
+
if (r.async) return i |= 2, Promise.resolve(e).then(a, function(e) {
|
|
1483
|
+
return n(e), a();
|
|
1484
|
+
});
|
|
1485
|
+
} else i |= 1;
|
|
1486
|
+
} catch (e) {
|
|
1487
|
+
n(e);
|
|
1488
|
+
}
|
|
1489
|
+
if (i === 1) return t.hasError ? Promise.reject(t.error) : Promise.resolve();
|
|
1490
|
+
if (t.hasError) throw t.error;
|
|
1491
|
+
}
|
|
1492
|
+
return a();
|
|
1493
|
+
};
|
|
1494
|
+
})(typeof SuppressedError == "function" ? SuppressedError : function(e, t, n) {
|
|
1495
|
+
var r = Error(n);
|
|
1496
|
+
return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
|
|
1497
|
+
});
|
|
1498
|
+
ue();
|
|
1499
|
+
var bt = -Infinity, xt = -Infinity, H = null;
|
|
1500
|
+
typeof FinalizationRegistry < "u" && (H = new FinalizationRegistry((e) => {
|
|
1501
|
+
let t = performance.now();
|
|
1502
|
+
e.type === "video" ? (t - bt >= 1e3 && (A._error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."), bt = t), typeof VideoFrame < "u" && e.data instanceof VideoFrame && e.data.close()) : (t - xt >= 1e3 && (A._error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."), xt = t), typeof AudioData < "u" && e.data instanceof AudioData && e.data.close());
|
|
1503
|
+
}));
|
|
1504
|
+
var U = class {
|
|
1505
|
+
constructor() {
|
|
1506
|
+
this._referenceCount = 0, this._lastAllocationBuffer = null;
|
|
1507
|
+
}
|
|
1508
|
+
}, W = [
|
|
1509
|
+
"I420",
|
|
1510
|
+
"I420P10",
|
|
1511
|
+
"I420P12",
|
|
1512
|
+
"I420A",
|
|
1513
|
+
"I420AP10",
|
|
1514
|
+
"I420AP12",
|
|
1515
|
+
"I422",
|
|
1516
|
+
"I422P10",
|
|
1517
|
+
"I422P12",
|
|
1518
|
+
"I422A",
|
|
1519
|
+
"I422AP10",
|
|
1520
|
+
"I422AP12",
|
|
1521
|
+
"I444",
|
|
1522
|
+
"I444P10",
|
|
1523
|
+
"I444P12",
|
|
1524
|
+
"I444A",
|
|
1525
|
+
"I444AP10",
|
|
1526
|
+
"I444AP12",
|
|
1527
|
+
"NV12",
|
|
1528
|
+
"RGBA",
|
|
1529
|
+
"RGBX",
|
|
1530
|
+
"BGRA",
|
|
1531
|
+
"BGRX"
|
|
1532
|
+
], St = new Set(W), G = class e {
|
|
1533
|
+
get codedWidth() {
|
|
1534
|
+
return this.visibleRect.width;
|
|
1535
|
+
}
|
|
1536
|
+
get codedHeight() {
|
|
1537
|
+
return this.visibleRect.height;
|
|
1538
|
+
}
|
|
1539
|
+
get displayWidth() {
|
|
1540
|
+
return this.rotation % 180 == 0 ? this.squarePixelWidth : this.squarePixelHeight;
|
|
1541
|
+
}
|
|
1542
|
+
get displayHeight() {
|
|
1543
|
+
return this.rotation % 180 == 0 ? this.squarePixelHeight : this.squarePixelWidth;
|
|
1544
|
+
}
|
|
1545
|
+
get microsecondTimestamp() {
|
|
1546
|
+
return Math.trunc(C * this.timestamp);
|
|
1547
|
+
}
|
|
1548
|
+
get microsecondDuration() {
|
|
1549
|
+
return Math.trunc(C * this.duration);
|
|
1550
|
+
}
|
|
1551
|
+
get hasAlpha() {
|
|
1552
|
+
return this.format && this.format.includes("A");
|
|
1553
|
+
}
|
|
1554
|
+
constructor(t, n) {
|
|
1555
|
+
if (this._closed = !1, t instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && t instanceof SharedArrayBuffer || ArrayBuffer.isView(t)) {
|
|
1556
|
+
if (!n || typeof n != "object") throw TypeError("init must be an object.");
|
|
1557
|
+
if (n.format === void 0 || !St.has(n.format)) throw TypeError("init.format must be one of: " + W.join(", "));
|
|
1558
|
+
if (!Number.isInteger(n.codedWidth) || n.codedWidth <= 0) throw TypeError("init.codedWidth must be a positive integer.");
|
|
1559
|
+
if (!Number.isInteger(n.codedHeight) || n.codedHeight <= 0) throw TypeError("init.codedHeight must be a positive integer.");
|
|
1560
|
+
if (n.rotation !== void 0 && ![
|
|
1561
|
+
0,
|
|
1562
|
+
90,
|
|
1563
|
+
180,
|
|
1564
|
+
270
|
|
1565
|
+
].includes(n.rotation)) throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1566
|
+
if (!Number.isFinite(n.timestamp)) throw TypeError("init.timestamp must be a number.");
|
|
1567
|
+
if (n.duration !== void 0 && (!Number.isFinite(n.duration) || n.duration < 0)) throw TypeError("init.duration, when provided, must be a non-negative number.");
|
|
1568
|
+
if (n.layout !== void 0) {
|
|
1569
|
+
if (!Array.isArray(n.layout)) throw TypeError("init.layout, when provided, must be an array.");
|
|
1570
|
+
for (let e of n.layout) {
|
|
1571
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("Each entry in init.layout must be an object.");
|
|
1572
|
+
if (!Number.isInteger(e.offset) || e.offset < 0) throw TypeError("plane.offset must be a non-negative integer.");
|
|
1573
|
+
if (!Number.isInteger(e.stride) || e.stride < 0) throw TypeError("plane.stride must be a non-negative integer.");
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
if (n.visibleRect !== void 0 && D(n.visibleRect, "init.visibleRect"), n.displayWidth !== void 0 && (!Number.isInteger(n.displayWidth) || n.displayWidth <= 0)) throw TypeError("init.displayWidth, when provided, must be a positive integer.");
|
|
1577
|
+
if (n.displayHeight !== void 0 && (!Number.isInteger(n.displayHeight) || n.displayHeight <= 0)) throw TypeError("init.displayHeight, when provided, must be a positive integer.");
|
|
1578
|
+
if (n.displayWidth !== void 0 != (n.displayHeight !== void 0)) throw TypeError("init.displayWidth and init.displayHeight must be either both provided or both omitted.");
|
|
1579
|
+
this.format = n.format, this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0;
|
|
1580
|
+
let e = n.layout ?? kt(n.format, n.codedWidth, n.codedHeight), r = n.colorSpace ?? null;
|
|
1581
|
+
r === null && (r = this.format === "RGBA" || this.format === "RGBX" || this.format === "BGRA" || this.format === "BGRX" ? {
|
|
1582
|
+
primaries: "bt709",
|
|
1583
|
+
transfer: "iec61966-2-1",
|
|
1584
|
+
matrix: "rgb",
|
|
1585
|
+
fullRange: !0
|
|
1586
|
+
} : {
|
|
1587
|
+
primaries: "bt709",
|
|
1588
|
+
transfer: "bt709",
|
|
1589
|
+
matrix: "bt709",
|
|
1590
|
+
fullRange: !1
|
|
1591
|
+
}), this.visibleRect = {
|
|
1592
|
+
left: n.visibleRect?.left ?? 0,
|
|
1593
|
+
top: n.visibleRect?.top ?? 0,
|
|
1594
|
+
width: n.visibleRect?.width ?? n.codedWidth,
|
|
1595
|
+
height: n.visibleRect?.height ?? n.codedHeight
|
|
1596
|
+
}, n.displayWidth === void 0 ? (this.squarePixelWidth = this.visibleRect.width, this.squarePixelHeight = this.visibleRect.height) : (this.squarePixelWidth = this.rotation % 180 == 0 ? n.displayWidth : n.displayHeight, this.squarePixelHeight = this.rotation % 180 == 0 ? n.displayHeight : n.displayWidth), this._data = n._doNotCopy ? o(t) : o(t).slice(), this._layout = e, this.colorSpace = new q(r);
|
|
1597
|
+
} else if (typeof VideoFrame < "u" && t instanceof VideoFrame) {
|
|
1598
|
+
if (n?.rotation !== void 0 && ![
|
|
1599
|
+
0,
|
|
1600
|
+
90,
|
|
1601
|
+
180,
|
|
1602
|
+
270
|
|
1603
|
+
].includes(n.rotation)) throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1604
|
+
if (n?.timestamp !== void 0 && !Number.isFinite(n?.timestamp)) throw TypeError("init.timestamp, when provided, must be a number.");
|
|
1605
|
+
if (n?.duration !== void 0 && (!Number.isFinite(n.duration) || n.duration < 0)) throw TypeError("init.duration, when provided, must be a non-negative number.");
|
|
1606
|
+
n?.visibleRect !== void 0 && D(n.visibleRect, "init.visibleRect"), this._data = t, this._layout = null, this.format = t.format, this.visibleRect = {
|
|
1607
|
+
left: t.visibleRect?.x ?? 0,
|
|
1608
|
+
top: t.visibleRect?.y ?? 0,
|
|
1609
|
+
width: t.visibleRect?.width ?? t.codedWidth,
|
|
1610
|
+
height: t.visibleRect?.height ?? t.codedHeight
|
|
1611
|
+
}, this.rotation = n?.rotation ?? 0, this.squarePixelWidth = t.displayWidth, this.squarePixelHeight = t.displayHeight, this.timestamp = n?.timestamp ?? t.timestamp / 1e6, this.duration = n?.duration ?? (t.duration ?? 0) / 1e6, this.colorSpace = new q(t.colorSpace);
|
|
1612
|
+
} else if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof SVGImageElement < "u" && t instanceof SVGImageElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap || typeof HTMLVideoElement < "u" && t instanceof HTMLVideoElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas) {
|
|
1613
|
+
if (!n || typeof n != "object") throw TypeError("init must be an object.");
|
|
1614
|
+
if (n.rotation !== void 0 && ![
|
|
1615
|
+
0,
|
|
1616
|
+
90,
|
|
1617
|
+
180,
|
|
1618
|
+
270
|
|
1619
|
+
].includes(n.rotation)) throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1620
|
+
if (!Number.isFinite(n.timestamp)) throw TypeError("init.timestamp must be a number.");
|
|
1621
|
+
if (n.duration !== void 0 && (!Number.isFinite(n.duration) || n.duration < 0)) throw TypeError("init.duration, when provided, must be a non-negative number.");
|
|
1622
|
+
if (n.visibleRect !== void 0 && D(n.visibleRect, "init.visibleRect"), typeof VideoFrame < "u") return new e(new VideoFrame(t, {
|
|
1623
|
+
timestamp: Math.trunc(n.timestamp * C),
|
|
1624
|
+
duration: Math.trunc((n.duration ?? 0) * C) || void 0,
|
|
1625
|
+
visibleRect: n.visibleRect && {
|
|
1626
|
+
x: n.visibleRect.left,
|
|
1627
|
+
y: n.visibleRect.top,
|
|
1628
|
+
width: n.visibleRect.width,
|
|
1629
|
+
height: n.visibleRect.height
|
|
1630
|
+
}
|
|
1631
|
+
}), n);
|
|
1632
|
+
let r = 0, i = 0;
|
|
1633
|
+
if ("naturalWidth" in t ? (r = t.naturalWidth, i = t.naturalHeight) : "videoWidth" in t ? (r = t.videoWidth, i = t.videoHeight) : "width" in t && (r = Number(t.width), i = Number(t.height)), !r || !i) throw TypeError("Could not determine dimensions.");
|
|
1634
|
+
let a = n.visibleRect ?? {
|
|
1635
|
+
left: 0,
|
|
1636
|
+
top: 0,
|
|
1637
|
+
width: r,
|
|
1638
|
+
height: i
|
|
1639
|
+
}, o = new OffscreenCanvas(a.width, a.height), s = o.getContext("2d", {
|
|
1640
|
+
alpha: ie(),
|
|
1641
|
+
willReadFrequently: !0
|
|
1642
|
+
});
|
|
1643
|
+
if (!s) throw Error("OffscreenCanvas must have support for the '2d' context in order to create a VideoSample from this data.");
|
|
1644
|
+
s.drawImage(t, -a.left, -a.top), this._data = o, this._layout = null, this.format = "RGBX", this.visibleRect = {
|
|
1645
|
+
left: 0,
|
|
1646
|
+
top: 0,
|
|
1647
|
+
width: a.width,
|
|
1648
|
+
height: a.height
|
|
1649
|
+
}, this.squarePixelWidth = a.width, this.squarePixelHeight = a.height, this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0, this.colorSpace = new q({
|
|
1650
|
+
matrix: "rgb",
|
|
1651
|
+
primaries: "bt709",
|
|
1652
|
+
transfer: "iec61966-2-1",
|
|
1653
|
+
fullRange: !0
|
|
1654
|
+
});
|
|
1655
|
+
} else if (t instanceof U) {
|
|
1656
|
+
if (!n || typeof n != "object") throw TypeError("init must be an object.");
|
|
1657
|
+
if (n.rotation !== void 0 && ![
|
|
1658
|
+
0,
|
|
1659
|
+
90,
|
|
1660
|
+
180,
|
|
1661
|
+
270
|
|
1662
|
+
].includes(n.rotation)) throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1663
|
+
if (!Number.isFinite(n.timestamp)) throw TypeError("init.timestamp must be a number.");
|
|
1664
|
+
if (n.duration !== void 0 && (!Number.isFinite(n.duration) || n.duration < 0)) throw TypeError("init.duration, when provided, must be a non-negative number.");
|
|
1665
|
+
if (this._data = t, t._referenceCount++, this.format = t.getFormat(), this.format !== null && !W.includes(this.format)) throw TypeError("getFormat() must return a VideoSamplePixelFormat or null.");
|
|
1666
|
+
if (this.visibleRect = {
|
|
1667
|
+
left: 0,
|
|
1668
|
+
top: 0,
|
|
1669
|
+
width: t.getCodedWidth(),
|
|
1670
|
+
height: t.getCodedHeight()
|
|
1671
|
+
}, !Number.isInteger(this.visibleRect.width) || this.visibleRect.width <= 0) throw TypeError("getCodedWidth() must return a positive integer.");
|
|
1672
|
+
if (!Number.isInteger(this.visibleRect.height) || this.visibleRect.height <= 0) throw TypeError("getCodedHeight() must return a positive integer.");
|
|
1673
|
+
if (this.squarePixelWidth = t.getSquarePixelWidth(), !Number.isInteger(this.squarePixelWidth) || this.squarePixelWidth <= 0) throw TypeError("getSquarePixelWidth() must return a positive integer.");
|
|
1674
|
+
if (this.squarePixelHeight = t.getSquarePixelHeight(), !Number.isInteger(this.squarePixelHeight) || this.squarePixelHeight <= 0) throw TypeError("getSquarePixelHeight() must return a positive integer.");
|
|
1675
|
+
this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0, this.colorSpace = t.getColorSpace();
|
|
1676
|
+
} else throw TypeError("Invalid data type: Must be a BufferSource, CanvasImageSource, or VideoSampleResource.");
|
|
1677
|
+
this.encodeOptions = n?.encodeOptions ?? {}, this.pixelAspectRatio = fe({
|
|
1678
|
+
num: this.squarePixelWidth * this.codedHeight,
|
|
1679
|
+
den: this.squarePixelHeight * this.codedWidth
|
|
1680
|
+
}), H?.register(this, {
|
|
1681
|
+
type: "video",
|
|
1682
|
+
data: this._data
|
|
1683
|
+
}, this);
|
|
1684
|
+
}
|
|
1685
|
+
clone() {
|
|
1686
|
+
if (this._closed) throw Error("VideoSample is closed.");
|
|
1687
|
+
return t(this._data !== null), this._data instanceof U ? new e(this._data, {
|
|
1688
|
+
timestamp: this.timestamp,
|
|
1689
|
+
duration: this.duration,
|
|
1690
|
+
rotation: this.rotation,
|
|
1691
|
+
encodeOptions: this.encodeOptions
|
|
1692
|
+
}) : J(this._data) ? new e(this._data.clone(), {
|
|
1693
|
+
timestamp: this.timestamp,
|
|
1694
|
+
duration: this.duration,
|
|
1695
|
+
rotation: this.rotation,
|
|
1696
|
+
encodeOptions: this.encodeOptions
|
|
1697
|
+
}) : this._data instanceof Uint8Array ? (t(this._layout), new e(this._data, {
|
|
1698
|
+
format: this.format,
|
|
1699
|
+
layout: this._layout,
|
|
1700
|
+
codedWidth: this.codedWidth,
|
|
1701
|
+
codedHeight: this.codedHeight,
|
|
1702
|
+
timestamp: this.timestamp,
|
|
1703
|
+
duration: this.duration,
|
|
1704
|
+
colorSpace: this.colorSpace,
|
|
1705
|
+
rotation: this.rotation,
|
|
1706
|
+
visibleRect: this.visibleRect,
|
|
1707
|
+
displayWidth: this.displayWidth,
|
|
1708
|
+
displayHeight: this.displayHeight,
|
|
1709
|
+
encodeOptions: this.encodeOptions,
|
|
1710
|
+
_doNotCopy: !0
|
|
1711
|
+
})) : new e(this._data, {
|
|
1712
|
+
format: this.format,
|
|
1713
|
+
codedWidth: this.codedWidth,
|
|
1714
|
+
codedHeight: this.codedHeight,
|
|
1715
|
+
timestamp: this.timestamp,
|
|
1716
|
+
duration: this.duration,
|
|
1717
|
+
colorSpace: this.colorSpace,
|
|
1718
|
+
rotation: this.rotation,
|
|
1719
|
+
visibleRect: this.visibleRect,
|
|
1720
|
+
displayWidth: this.displayWidth,
|
|
1721
|
+
displayHeight: this.displayHeight,
|
|
1722
|
+
encodeOptions: this.encodeOptions
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
close() {
|
|
1726
|
+
this._closed ||= (H?.unregister(this), this._data instanceof U ? (this._data._referenceCount--, this._data._referenceCount === 0 && this._data.close()) : J(this._data) ? this._data.close() : this._data = null, !0);
|
|
1727
|
+
}
|
|
1728
|
+
allocationSize(e = {}) {
|
|
1729
|
+
if (Ot(e), this._closed) throw Error("VideoSample is closed.");
|
|
1730
|
+
if ((e.format ?? this.format) == null) throw Error("Cannot get allocation size when format is null.");
|
|
1731
|
+
return J(this._data) ? this._data.allocationSize(e) : At(this, e).allocationSize;
|
|
1732
|
+
}
|
|
1733
|
+
async copyTo(n, r = {}) {
|
|
1734
|
+
if (!p(n)) throw TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");
|
|
1735
|
+
if (Ot(r), this._closed) throw Error("VideoSample is closed.");
|
|
1736
|
+
if ((r.format ?? this.format) == null) throw Error("Cannot copy video sample data when format is null.");
|
|
1737
|
+
if (t(this._data !== null), J(this._data)) return this._data.copyTo(n, r);
|
|
1738
|
+
if (r.format && ![
|
|
1739
|
+
"RGBA",
|
|
1740
|
+
"RGBX",
|
|
1741
|
+
"BGRA",
|
|
1742
|
+
"BGRX"
|
|
1743
|
+
].includes(this.format) && [
|
|
1744
|
+
"RGBA",
|
|
1745
|
+
"RGBX",
|
|
1746
|
+
"BGRA",
|
|
1747
|
+
"BGRX"
|
|
1748
|
+
].includes(r.format)) {
|
|
1749
|
+
if (this._data instanceof U) {
|
|
1750
|
+
let t = {
|
|
1751
|
+
stack: [],
|
|
1752
|
+
error: void 0,
|
|
1753
|
+
hasError: !1
|
|
1754
|
+
};
|
|
1755
|
+
try {
|
|
1756
|
+
let i = vt(t, await this._data.toRgbSample({
|
|
1757
|
+
timestamp: this.timestamp,
|
|
1758
|
+
duration: this.duration,
|
|
1759
|
+
rotation: this.rotation
|
|
1760
|
+
}, r.colorSpace ?? "srgb"), !1);
|
|
1761
|
+
if (!(i instanceof e)) throw TypeError("toRgbSample() must return a VideoSample.");
|
|
1762
|
+
if (![
|
|
1763
|
+
"RGBA",
|
|
1764
|
+
"RGBX",
|
|
1765
|
+
"BGRA",
|
|
1766
|
+
"BGRX"
|
|
1767
|
+
].includes(i.format)) throw Error(`Sample returned by toRgbSample was expected to have an RGB format, got '${i.format}' instead.`);
|
|
1768
|
+
return await i.copyTo(n, r);
|
|
1769
|
+
} catch (e) {
|
|
1770
|
+
t.error = e, t.hasError = !0;
|
|
1771
|
+
} finally {
|
|
1772
|
+
yt(t);
|
|
1773
|
+
}
|
|
1774
|
+
} else {
|
|
1775
|
+
if (typeof VideoFrame > "u") throw Error("For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.");
|
|
1776
|
+
let e = this.toVideoFrame(), t = await e.copyTo(n, r);
|
|
1777
|
+
return e.close(), t;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
let i = At(this, r);
|
|
1781
|
+
t(this.format);
|
|
1782
|
+
let a = o(n);
|
|
1783
|
+
if (a.byteLength < i.allocationSize) throw TypeError(`Destination buffer too small. Required: ${i.allocationSize}, Available: ${a.byteLength}`);
|
|
1784
|
+
let s = X(this.format), c;
|
|
1785
|
+
if (this._data instanceof U) {
|
|
1786
|
+
let e = this._data.getDataPlanes();
|
|
1787
|
+
if (e instanceof Promise && (e = await e), !Array.isArray(e) || e.some((e) => !(e.data instanceof Uint8Array) || !Number.isInteger(e.stride) || e.stride < 0)) throw TypeError("getDataPlanes() must return an array of objects with a Uint8Array \"data\" property and a non-negative integer \"stride\" property.");
|
|
1788
|
+
c = e;
|
|
1789
|
+
} else if (this._data instanceof Uint8Array) t(this._layout), t(this._layout.length === s.length), c = this._layout.map((e, t) => {
|
|
1790
|
+
let n = Math.ceil(this.codedHeight / s[t].heightDivisor);
|
|
1791
|
+
return {
|
|
1792
|
+
data: this._data.subarray(e.offset, e.offset + e.stride * n),
|
|
1793
|
+
stride: e.stride
|
|
1794
|
+
};
|
|
1795
|
+
});
|
|
1796
|
+
else {
|
|
1797
|
+
let e = this._data.getContext("2d");
|
|
1798
|
+
t(e), c = [{
|
|
1799
|
+
data: o(e.getImageData(0, 0, this.codedWidth, this.codedHeight).data),
|
|
1800
|
+
stride: 4 * this.codedWidth
|
|
1801
|
+
}];
|
|
1802
|
+
}
|
|
1803
|
+
let l = [], u = s.length;
|
|
1804
|
+
for (let e = 0; e < u; e++) {
|
|
1805
|
+
let t = i.computedLayouts[e], n = c[e].stride, r = c[e].data, o = t.sourceTop * n;
|
|
1806
|
+
o += t.sourceLeftBytes;
|
|
1807
|
+
let s = t.destinationOffset, u = t.sourceWidthBytes, d = {
|
|
1808
|
+
offset: s,
|
|
1809
|
+
stride: t.destinationStride
|
|
1810
|
+
};
|
|
1811
|
+
for (let e = 0; e < t.sourceHeight; e++) {
|
|
1812
|
+
if (o + u > r.byteLength) throw Error("Source buffer OOB read.");
|
|
1813
|
+
if (s + u > a.byteLength) throw Error("Destination buffer OOB write.");
|
|
1814
|
+
let e = r.subarray(o, o + u);
|
|
1815
|
+
a.set(e, s), o += n, s += t.destinationStride;
|
|
1816
|
+
}
|
|
1817
|
+
l.push(d);
|
|
1818
|
+
}
|
|
1819
|
+
if (r.format !== void 0) {
|
|
1820
|
+
let e = this.format.startsWith("RGB") !== r.format.startsWith("RGB"), t = this.format.includes("X") && r.format.includes("A");
|
|
1821
|
+
if (e || t) for (let n = 0; n < i.allocationSize; n += 4) {
|
|
1822
|
+
if (e) {
|
|
1823
|
+
let e = a[n], t = a[n + 2];
|
|
1824
|
+
a[n] = t, a[n + 2] = e;
|
|
1825
|
+
}
|
|
1826
|
+
t && (a[n + 3] = 255);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return l;
|
|
1830
|
+
}
|
|
1831
|
+
toVideoFrame() {
|
|
1832
|
+
if (this._closed) throw Error("VideoSample is closed.");
|
|
1833
|
+
if (t(this._data !== null), this._data instanceof U) {
|
|
1834
|
+
if (this.format === null) throw Error("Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if format is null.");
|
|
1835
|
+
let e = this._data.getDataPlanes();
|
|
1836
|
+
if (e instanceof Promise) throw Error("Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise.");
|
|
1837
|
+
let t = e.reduce((e, t) => e + t.data.byteLength, 0), n = new Uint8Array(t), r = 0, i = [];
|
|
1838
|
+
for (let t of e) n.set(t.data, r), i.push(r), r += t.data.byteLength;
|
|
1839
|
+
return new VideoFrame(n, {
|
|
1840
|
+
format: this.format,
|
|
1841
|
+
layout: e.map((e, t) => ({
|
|
1842
|
+
offset: i[t],
|
|
1843
|
+
stride: e.stride
|
|
1844
|
+
})),
|
|
1845
|
+
codedWidth: this.codedWidth,
|
|
1846
|
+
codedHeight: this.codedHeight,
|
|
1847
|
+
timestamp: this.microsecondTimestamp,
|
|
1848
|
+
duration: this.microsecondDuration,
|
|
1849
|
+
colorSpace: this.colorSpace,
|
|
1850
|
+
visibleRect: this.visibleRect,
|
|
1851
|
+
displayWidth: this.squarePixelWidth,
|
|
1852
|
+
displayHeight: this.squarePixelHeight
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
return J(this._data) ? new VideoFrame(this._data, {
|
|
1856
|
+
timestamp: this.microsecondTimestamp,
|
|
1857
|
+
duration: this.microsecondDuration || void 0
|
|
1858
|
+
}) : this._data instanceof Uint8Array ? (t(this._layout), new VideoFrame(this._data, {
|
|
1859
|
+
format: this.format,
|
|
1860
|
+
codedWidth: this.codedWidth,
|
|
1861
|
+
codedHeight: this.codedHeight,
|
|
1862
|
+
layout: this._layout,
|
|
1863
|
+
timestamp: this.microsecondTimestamp,
|
|
1864
|
+
duration: this.microsecondDuration || void 0,
|
|
1865
|
+
colorSpace: this.colorSpace,
|
|
1866
|
+
visibleRect: this.visibleRect,
|
|
1867
|
+
displayWidth: this.squarePixelWidth,
|
|
1868
|
+
displayHeight: this.squarePixelHeight
|
|
1869
|
+
})) : new VideoFrame(this._data, {
|
|
1870
|
+
timestamp: this.microsecondTimestamp,
|
|
1871
|
+
duration: this.microsecondDuration || void 0
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
draw(e, t, n, r, i, a, o, s, c) {
|
|
1875
|
+
let l = 0, u = 0, d = this.displayWidth, f = this.displayHeight, p = 0, m = 0, h = this.displayWidth, g = this.displayHeight;
|
|
1876
|
+
if (a === void 0 ? (p = t, m = n, r !== void 0 && (h = r, g = i)) : (l = t, u = n, d = r, f = i, p = a, m = o, s === void 0 ? (h = d, g = f) : (h = s, g = c)), !(typeof CanvasRenderingContext2D < "u" && e instanceof CanvasRenderingContext2D || typeof OffscreenCanvasRenderingContext2D < "u" && e instanceof OffscreenCanvasRenderingContext2D)) throw TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");
|
|
1877
|
+
if (!Number.isFinite(l)) throw TypeError("sx must be a number.");
|
|
1878
|
+
if (!Number.isFinite(u)) throw TypeError("sy must be a number.");
|
|
1879
|
+
if (!Number.isFinite(d) || d < 0) throw TypeError("sWidth must be a non-negative number.");
|
|
1880
|
+
if (!Number.isFinite(f) || f < 0) throw TypeError("sHeight must be a non-negative number.");
|
|
1881
|
+
if (!Number.isFinite(p)) throw TypeError("dx must be a number.");
|
|
1882
|
+
if (!Number.isFinite(m)) throw TypeError("dy must be a number.");
|
|
1883
|
+
if (!Number.isFinite(h) || h < 0) throw TypeError("dWidth must be a non-negative number.");
|
|
1884
|
+
if (!Number.isFinite(g) || g < 0) throw TypeError("dHeight must be a non-negative number.");
|
|
1885
|
+
if (this._closed) throw Error("VideoSample is closed.");
|
|
1886
|
+
({sx: l, sy: u, sWidth: d, sHeight: f} = this._rotateSourceRegion(l, u, d, f, this.rotation));
|
|
1887
|
+
let _ = this.toCanvasImageSource();
|
|
1888
|
+
e.save();
|
|
1889
|
+
let ee = p + h / 2, v = m + g / 2;
|
|
1890
|
+
e.translate(ee, v), e.rotate(this.rotation * Math.PI / 180);
|
|
1891
|
+
let y = this.rotation % 180 == 0 ? 1 : h / g;
|
|
1892
|
+
e.scale(1 / y, y), e.drawImage(_, l, u, d, f, -h / 2, -g / 2, h, g), e.restore();
|
|
1893
|
+
}
|
|
1894
|
+
drawWithFit(e, t) {
|
|
1895
|
+
if (!(typeof CanvasRenderingContext2D < "u" && e instanceof CanvasRenderingContext2D || typeof OffscreenCanvasRenderingContext2D < "u" && e instanceof OffscreenCanvasRenderingContext2D)) throw TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");
|
|
1896
|
+
if (!t || typeof t != "object") throw TypeError("options must be an object.");
|
|
1897
|
+
if (![
|
|
1898
|
+
"fill",
|
|
1899
|
+
"contain",
|
|
1900
|
+
"cover"
|
|
1901
|
+
].includes(t.fit)) throw TypeError("options.fit must be 'fill', 'contain', or 'cover'.");
|
|
1902
|
+
if (t.rotation !== void 0 && ![
|
|
1903
|
+
0,
|
|
1904
|
+
90,
|
|
1905
|
+
180,
|
|
1906
|
+
270
|
|
1907
|
+
].includes(t.rotation)) throw TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1908
|
+
t.crop !== void 0 && Y(t.crop, "options.");
|
|
1909
|
+
let n = e.canvas.width, r = e.canvas.height, i = t.rotation ?? this.rotation, [a, o] = i % 180 == 0 ? [this.squarePixelWidth, this.squarePixelHeight] : [this.squarePixelHeight, this.squarePixelWidth], s = t.crop;
|
|
1910
|
+
s &&= Dt(s, a, o);
|
|
1911
|
+
let c, l, u, d, { sx: f, sy: p, sWidth: m, sHeight: h } = this._rotateSourceRegion(t.crop?.left ?? 0, t.crop?.top ?? 0, t.crop?.width ?? a, t.crop?.height ?? o, i);
|
|
1912
|
+
if (t.fit === "fill") c = 0, l = 0, u = n, d = r;
|
|
1913
|
+
else {
|
|
1914
|
+
let [e, i] = t.crop ? [t.crop.width, t.crop.height] : [a, o], s = t.fit === "contain" ? Math.min(n / e, r / i) : Math.max(n / e, r / i);
|
|
1915
|
+
u = e * s, d = i * s, c = (n - u) / 2, l = (r - d) / 2;
|
|
1916
|
+
}
|
|
1917
|
+
e.save();
|
|
1918
|
+
let g = i % 180 == 0 ? 1 : u / d;
|
|
1919
|
+
e.translate(n / 2, r / 2), e.rotate(i * Math.PI / 180), e.scale(1 / g, g), e.translate(-n / 2, -r / 2), e.drawImage(this.toCanvasImageSource(), f, p, m, h, c, l, u, d), e.restore();
|
|
1920
|
+
}
|
|
1921
|
+
_rotateSourceRegion(e, t, n, r, i) {
|
|
1922
|
+
return i === 90 ? [e, t, n, r] = [
|
|
1923
|
+
t,
|
|
1924
|
+
this.squarePixelHeight - e - n,
|
|
1925
|
+
r,
|
|
1926
|
+
n
|
|
1927
|
+
] : i === 180 ? [e, t] = [this.squarePixelWidth - e - n, this.squarePixelHeight - t - r] : i === 270 && ([e, t, n, r] = [
|
|
1928
|
+
this.squarePixelWidth - t - r,
|
|
1929
|
+
e,
|
|
1930
|
+
r,
|
|
1931
|
+
n
|
|
1932
|
+
]), {
|
|
1933
|
+
sx: e,
|
|
1934
|
+
sy: t,
|
|
1935
|
+
sWidth: n,
|
|
1936
|
+
sHeight: r
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1939
|
+
_drawWithFitAndMipmapping(e, t, n) {
|
|
1940
|
+
let r = e.width, i = e.height, [a, o] = n.rotation % 180 == 0 ? [this.squarePixelWidth, this.squarePixelHeight] : [this.squarePixelHeight, this.squarePixelWidth], s = n.crop ? n.crop.width : a, c = n.crop ? n.crop.height : o, l = 0;
|
|
1941
|
+
2 * r < s && 2 * i < c && (l = Math.floor(Math.log2(Math.min(s / r, c / i))));
|
|
1942
|
+
let u = r * 2 ** l, d = i * 2 ** l, { canvas: f, context: p, isNew: m } = l > 0 ? Et(u, d) : {
|
|
1943
|
+
canvas: e,
|
|
1944
|
+
context: t,
|
|
1945
|
+
isNew: n.targetIsFresh
|
|
1946
|
+
};
|
|
1947
|
+
p.imageSmoothingQuality = "high", n.fillBlack ? (p.fillStyle = "black", p.fillRect(0, 0, u, d)) : m || p.clearRect(0, 0, u, d), this.drawWithFit(p, {
|
|
1948
|
+
fit: n.fit,
|
|
1949
|
+
rotation: n.rotation,
|
|
1950
|
+
crop: n.crop
|
|
1951
|
+
}), p.globalCompositeOperation = "copy";
|
|
1952
|
+
for (let e = l; e > 1; e--) {
|
|
1953
|
+
let t = r * 2 ** e, n = i * 2 ** e;
|
|
1954
|
+
p.drawImage(f, 0, 0, t, n, 0, 0, t / 2, n / 2);
|
|
1955
|
+
}
|
|
1956
|
+
p.globalCompositeOperation = "source-over", l > 0 && (t.imageSmoothingQuality = "high", t.globalCompositeOperation = "copy", t.drawImage(f, 0, 0, 2 * r, 2 * i, 0, 0, r, i), t.globalCompositeOperation = "source-over");
|
|
1957
|
+
}
|
|
1958
|
+
toCanvasImageSource() {
|
|
1959
|
+
if (this._closed) throw Error("VideoSample is closed.");
|
|
1960
|
+
if (t(this._data !== null), this._data instanceof U || this._data instanceof Uint8Array) {
|
|
1961
|
+
let e = this.toVideoFrame();
|
|
1962
|
+
return queueMicrotask(() => e.close()), e;
|
|
1963
|
+
}
|
|
1964
|
+
return this._data;
|
|
1965
|
+
}
|
|
1966
|
+
async transform(t) {
|
|
1967
|
+
if (!t || typeof t != "object") throw TypeError("options must be an object.");
|
|
1968
|
+
if (t.width !== void 0 && (!Number.isInteger(t.width) || t.width <= 0)) throw TypeError("options.width, when provided, must be a positive integer.");
|
|
1969
|
+
if (t.height !== void 0 && (!Number.isInteger(t.height) || t.height <= 0)) throw TypeError("options.height, when provided, must be a positive integer.");
|
|
1970
|
+
if (t.roundDimensionsTo !== void 0 && (!Number.isInteger(t.roundDimensionsTo) || t.roundDimensionsTo <= 0)) throw TypeError("options.roundDimensionsTo, when provided, must be a positive integer.");
|
|
1971
|
+
if (t.fit !== void 0 && ![
|
|
1972
|
+
"fill",
|
|
1973
|
+
"contain",
|
|
1974
|
+
"cover"
|
|
1975
|
+
].includes(t.fit)) throw TypeError("options.fit, when provided, must be one of \"fill\", \"contain\", or \"cover\".");
|
|
1976
|
+
if (t.width !== void 0 && t.height !== void 0 && t.fit === void 0) throw TypeError("When both options.width and options.height are provided, options.fit must also be provided.");
|
|
1977
|
+
if (t.rotate !== void 0 && ![
|
|
1978
|
+
0,
|
|
1979
|
+
90,
|
|
1980
|
+
180,
|
|
1981
|
+
270
|
|
1982
|
+
].includes(t.rotate)) throw TypeError("options.rotate, when provided, must be 0, 90, 180 or 270.");
|
|
1983
|
+
if (t.crop !== void 0 && Y(t.crop, "options."), t.alpha !== void 0 && !["keep", "discard"].includes(t.alpha)) throw TypeError("options.alpha, when provided, must be 'keep' or 'discard'.");
|
|
1984
|
+
let r = n(this.rotation + (t.rotate ?? 0)), [i, a] = r % 180 == 0 ? [this.squarePixelWidth, this.squarePixelHeight] : [this.squarePixelHeight, this.squarePixelWidth], o = t.crop;
|
|
1985
|
+
o &&= Dt(o, i, a);
|
|
1986
|
+
let s = o ? o.width : i, c = o ? o.height : a, l = s / c, u, d;
|
|
1987
|
+
t.width !== void 0 && t.height === void 0 ? (u = t.width, d = u / l) : t.width === void 0 && t.height !== void 0 ? (d = t.height, u = d * l) : t.width !== void 0 && t.height !== void 0 ? (u = t.width, d = t.height) : (u = s, d = c), u = b(u, t.roundDimensionsTo ?? 1), d = b(d, t.roundDimensionsTo ?? 1);
|
|
1988
|
+
let f = {
|
|
1989
|
+
width: u,
|
|
1990
|
+
height: d,
|
|
1991
|
+
fit: t.fit ?? "fill",
|
|
1992
|
+
rotation: r,
|
|
1993
|
+
crop: o ?? {
|
|
1994
|
+
left: 0,
|
|
1995
|
+
top: 0,
|
|
1996
|
+
width: i,
|
|
1997
|
+
height: a
|
|
1998
|
+
},
|
|
1999
|
+
alpha: t.alpha ?? "keep"
|
|
2000
|
+
};
|
|
2001
|
+
for (let e of Ct) {
|
|
2002
|
+
let t = e(this, f);
|
|
2003
|
+
if (t instanceof Promise && (t = await t), t !== null) return t;
|
|
2004
|
+
}
|
|
2005
|
+
let { canvas: p, context: m, isNew: h } = Et(f.width, f.height);
|
|
2006
|
+
return this._drawWithFitAndMipmapping(p, m, {
|
|
2007
|
+
fit: f.fit,
|
|
2008
|
+
rotation: f.rotation,
|
|
2009
|
+
crop: f.crop,
|
|
2010
|
+
targetIsFresh: h,
|
|
2011
|
+
fillBlack: f.alpha === "discard"
|
|
2012
|
+
}), new e(p, {
|
|
2013
|
+
timestamp: this.timestamp,
|
|
2014
|
+
duration: this.duration,
|
|
2015
|
+
rotation: 0
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
setRotation(e) {
|
|
2019
|
+
if (![
|
|
2020
|
+
0,
|
|
2021
|
+
90,
|
|
2022
|
+
180,
|
|
2023
|
+
270
|
|
2024
|
+
].includes(e)) throw TypeError("newRotation must be 0, 90, 180, or 270.");
|
|
2025
|
+
this.rotation = e;
|
|
2026
|
+
}
|
|
2027
|
+
setTimestamp(e) {
|
|
2028
|
+
if (!Number.isFinite(e)) throw TypeError("newTimestamp must be a number.");
|
|
2029
|
+
this.timestamp = e;
|
|
2030
|
+
}
|
|
2031
|
+
setDuration(e) {
|
|
2032
|
+
if (!Number.isFinite(e) || e < 0) throw TypeError("newDuration must be a non-negative number.");
|
|
2033
|
+
this.duration = e;
|
|
2034
|
+
}
|
|
2035
|
+
setEncodeOptions(e) {
|
|
2036
|
+
if (!e || typeof e != "object") throw TypeError("newEncodeOptions must be an object.");
|
|
2037
|
+
this.encodeOptions = e;
|
|
2038
|
+
}
|
|
2039
|
+
[Symbol.dispose]() {
|
|
2040
|
+
this.close();
|
|
2041
|
+
}
|
|
2042
|
+
}, Ct = [], wt = 3, K = [], Tt = 0, Et = (e, t) => {
|
|
2043
|
+
for (let n of K) if (n.canvas.width === e && n.canvas.height === t) return n.age = Tt++, {
|
|
2044
|
+
canvas: n.canvas,
|
|
2045
|
+
context: n.context,
|
|
2046
|
+
isNew: !1
|
|
2047
|
+
};
|
|
2048
|
+
let n;
|
|
2049
|
+
if (typeof OffscreenCanvas < "u") n = new OffscreenCanvas(e, t);
|
|
2050
|
+
else {
|
|
2051
|
+
if (typeof window > "u" || typeof document > "u") throw Error("Cannot transform VideoSamples in this environment. Either run in an environment with OffscreenCanvas or HTMLCanvasElement, or supply a custom VideoSample transformer using registerVideoSampleTransformer().");
|
|
2052
|
+
n = document.createElement("canvas"), n.width = e, n.height = t;
|
|
2053
|
+
}
|
|
2054
|
+
let r = n.getContext("2d", {
|
|
2055
|
+
alpha: !0,
|
|
2056
|
+
willReadFrequently: !1
|
|
2057
|
+
});
|
|
2058
|
+
if (!r) throw Error("The '2d' canvas context is required to transform VideoSamples. Register a custom transformer using registerVideoSampleTransformer to work around this limitation.");
|
|
2059
|
+
return K.length >= wt && K.splice(de(K, (e) => e.age), 1), K.push({
|
|
2060
|
+
canvas: n,
|
|
2061
|
+
context: r,
|
|
2062
|
+
age: Tt++
|
|
2063
|
+
}), {
|
|
2064
|
+
canvas: n,
|
|
2065
|
+
context: r,
|
|
2066
|
+
isNew: !0
|
|
2067
|
+
};
|
|
2068
|
+
}, q = class {
|
|
2069
|
+
constructor(e) {
|
|
2070
|
+
if (e !== void 0) {
|
|
2071
|
+
if (!e || typeof e != "object") throw TypeError("init.colorSpace, when provided, must be an object.");
|
|
2072
|
+
let t = Object.keys(l);
|
|
2073
|
+
if (e.primaries != null && !t.includes(e.primaries)) throw TypeError(`init.colorSpace.primaries, when provided, must be one of ${t.join(", ")}.`);
|
|
2074
|
+
let n = Object.keys(u);
|
|
2075
|
+
if (e.transfer != null && !n.includes(e.transfer)) throw TypeError(`init.colorSpace.transfer, when provided, must be one of ${n.join(", ")}.`);
|
|
2076
|
+
let r = Object.keys(d);
|
|
2077
|
+
if (e.matrix != null && !r.includes(e.matrix)) throw TypeError(`init.colorSpace.matrix, when provided, must be one of ${r.join(", ")}.`);
|
|
2078
|
+
if (e.fullRange != null && typeof e.fullRange != "boolean") throw TypeError("init.colorSpace.fullRange, when provided, must be a boolean.");
|
|
2079
|
+
}
|
|
2080
|
+
this.primaries = e?.primaries ?? null, this.transfer = e?.transfer ?? null, this.matrix = e?.matrix ?? null, this.fullRange = e?.fullRange ?? null;
|
|
2081
|
+
}
|
|
2082
|
+
toJSON() {
|
|
2083
|
+
return {
|
|
2084
|
+
primaries: this.primaries,
|
|
2085
|
+
transfer: this.transfer,
|
|
2086
|
+
matrix: this.matrix,
|
|
2087
|
+
fullRange: this.fullRange
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
}, J = (e) => typeof VideoFrame < "u" && e instanceof VideoFrame, Dt = (e, n, r) => {
|
|
2091
|
+
let i = Math.min(e.left, n), a = Math.min(e.top, r), o = Math.min(e.width, n - i), s = Math.min(e.height, r - a);
|
|
2092
|
+
return t(o >= 0), t(s >= 0), {
|
|
2093
|
+
left: i,
|
|
2094
|
+
top: a,
|
|
2095
|
+
width: o,
|
|
2096
|
+
height: s
|
|
2097
|
+
};
|
|
2098
|
+
}, Y = (e, t) => {
|
|
2099
|
+
if (!e || typeof e != "object") throw TypeError(t + "crop, when provided, must be an object.");
|
|
2100
|
+
if (!Number.isInteger(e.left) || e.left < 0) throw TypeError(t + "crop.left must be a non-negative integer.");
|
|
2101
|
+
if (!Number.isInteger(e.top) || e.top < 0) throw TypeError(t + "crop.top must be a non-negative integer.");
|
|
2102
|
+
if (!Number.isInteger(e.width) || e.width < 0) throw TypeError(t + "crop.width must be a non-negative integer.");
|
|
2103
|
+
if (!Number.isInteger(e.height) || e.height < 0) throw TypeError(t + "crop.height must be a non-negative integer.");
|
|
2104
|
+
}, Ot = (e) => {
|
|
2105
|
+
if (!e || typeof e != "object") throw TypeError("options must be an object.");
|
|
2106
|
+
if (e.colorSpace !== void 0 && !["display-p3", "srgb"].includes(e.colorSpace)) throw TypeError("options.colorSpace, when provided, must be 'display-p3' or 'srgb'.");
|
|
2107
|
+
if (e.format !== void 0 && typeof e.format != "string") throw TypeError("options.format, when provided, must be a string.");
|
|
2108
|
+
if (e.layout !== void 0) {
|
|
2109
|
+
if (!Array.isArray(e.layout)) throw TypeError("options.layout, when provided, must be an array.");
|
|
2110
|
+
for (let t of e.layout) {
|
|
2111
|
+
if (!t || typeof t != "object") throw TypeError("Each entry in options.layout must be an object.");
|
|
2112
|
+
if (!Number.isInteger(t.offset) || t.offset < 0) throw TypeError("plane.offset must be a non-negative integer.");
|
|
2113
|
+
if (!Number.isInteger(t.stride) || t.stride < 0) throw TypeError("plane.stride must be a non-negative integer.");
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
if (e.rect !== void 0) {
|
|
2117
|
+
if (!e.rect || typeof e.rect != "object") throw TypeError("options.rect, when provided, must be an object.");
|
|
2118
|
+
if (e.rect.x !== void 0 && (!Number.isInteger(e.rect.x) || e.rect.x < 0)) throw TypeError("options.rect.x, when provided, must be a non-negative integer.");
|
|
2119
|
+
if (e.rect.y !== void 0 && (!Number.isInteger(e.rect.y) || e.rect.y < 0)) throw TypeError("options.rect.y, when provided, must be a non-negative integer.");
|
|
2120
|
+
if (e.rect.width !== void 0 && (!Number.isInteger(e.rect.width) || e.rect.width < 0)) throw TypeError("options.rect.width, when provided, must be a non-negative integer.");
|
|
2121
|
+
if (e.rect.height !== void 0 && (!Number.isInteger(e.rect.height) || e.rect.height < 0)) throw TypeError("options.rect.height, when provided, must be a non-negative integer.");
|
|
2122
|
+
}
|
|
2123
|
+
}, kt = (e, t, n) => {
|
|
2124
|
+
let r = X(e), i = [], a = 0;
|
|
2125
|
+
for (let e of r) {
|
|
2126
|
+
let r = Math.ceil(t / e.widthDivisor), o = Math.ceil(n / e.heightDivisor), s = r * e.sampleBytes, c = s * o;
|
|
2127
|
+
i.push({
|
|
2128
|
+
offset: a,
|
|
2129
|
+
stride: s
|
|
2130
|
+
}), a += c;
|
|
2131
|
+
}
|
|
2132
|
+
return i;
|
|
2133
|
+
}, X = (e) => {
|
|
2134
|
+
let n = (e, t, n, r, i) => {
|
|
2135
|
+
let a = [
|
|
2136
|
+
{
|
|
2137
|
+
sampleBytes: e,
|
|
2138
|
+
widthDivisor: 1,
|
|
2139
|
+
heightDivisor: 1
|
|
2140
|
+
},
|
|
2141
|
+
{
|
|
2142
|
+
sampleBytes: t,
|
|
2143
|
+
widthDivisor: n,
|
|
2144
|
+
heightDivisor: r
|
|
2145
|
+
},
|
|
2146
|
+
{
|
|
2147
|
+
sampleBytes: t,
|
|
2148
|
+
widthDivisor: n,
|
|
2149
|
+
heightDivisor: r
|
|
2150
|
+
}
|
|
2151
|
+
];
|
|
2152
|
+
return i && a.push({
|
|
2153
|
+
sampleBytes: e,
|
|
2154
|
+
widthDivisor: 1,
|
|
2155
|
+
heightDivisor: 1
|
|
2156
|
+
}), a;
|
|
2157
|
+
};
|
|
2158
|
+
switch (e) {
|
|
2159
|
+
case "I420": return n(1, 1, 2, 2, !1);
|
|
2160
|
+
case "I420P10":
|
|
2161
|
+
case "I420P12": return n(2, 2, 2, 2, !1);
|
|
2162
|
+
case "I420A": return n(1, 1, 2, 2, !0);
|
|
2163
|
+
case "I420AP10":
|
|
2164
|
+
case "I420AP12": return n(2, 2, 2, 2, !0);
|
|
2165
|
+
case "I422": return n(1, 1, 2, 1, !1);
|
|
2166
|
+
case "I422P10":
|
|
2167
|
+
case "I422P12": return n(2, 2, 2, 1, !1);
|
|
2168
|
+
case "I422A": return n(1, 1, 2, 1, !0);
|
|
2169
|
+
case "I422AP10":
|
|
2170
|
+
case "I422AP12": return n(2, 2, 2, 1, !0);
|
|
2171
|
+
case "I444": return n(1, 1, 1, 1, !1);
|
|
2172
|
+
case "I444P10":
|
|
2173
|
+
case "I444P12": return n(2, 2, 1, 1, !1);
|
|
2174
|
+
case "I444A": return n(1, 1, 1, 1, !0);
|
|
2175
|
+
case "I444AP10":
|
|
2176
|
+
case "I444AP12": return n(2, 2, 1, 1, !0);
|
|
2177
|
+
case "NV12": return [{
|
|
2178
|
+
sampleBytes: 1,
|
|
2179
|
+
widthDivisor: 1,
|
|
2180
|
+
heightDivisor: 1
|
|
2181
|
+
}, {
|
|
2182
|
+
sampleBytes: 2,
|
|
2183
|
+
widthDivisor: 2,
|
|
2184
|
+
heightDivisor: 2
|
|
2185
|
+
}];
|
|
2186
|
+
case "RGBA":
|
|
2187
|
+
case "RGBX":
|
|
2188
|
+
case "BGRA":
|
|
2189
|
+
case "BGRX": return [{
|
|
2190
|
+
sampleBytes: 4,
|
|
2191
|
+
widthDivisor: 1,
|
|
2192
|
+
heightDivisor: 1
|
|
2193
|
+
}];
|
|
2194
|
+
default: _(e), t(!1);
|
|
2195
|
+
}
|
|
2196
|
+
}, At = (e, t) => {
|
|
2197
|
+
let n = {
|
|
2198
|
+
left: 0,
|
|
2199
|
+
top: 0,
|
|
2200
|
+
width: e.codedWidth,
|
|
2201
|
+
height: e.codedHeight
|
|
2202
|
+
}, r = t.rect, i = jt(n, r, e.codedWidth, e.codedHeight, e.format), a = t.layout, o;
|
|
2203
|
+
if (!t.format || t.format === e.format) o = e.format;
|
|
2204
|
+
else if ([
|
|
2205
|
+
"RGBA",
|
|
2206
|
+
"RGBX",
|
|
2207
|
+
"BGRA",
|
|
2208
|
+
"BGRX"
|
|
2209
|
+
].includes(t.format)) o = t.format;
|
|
2210
|
+
else throw Error("NotSupportedError: Invalid destination format.");
|
|
2211
|
+
return Nt(i, o, a);
|
|
2212
|
+
}, jt = (e, t, n, r, i) => {
|
|
2213
|
+
let a = { ...e };
|
|
2214
|
+
if (t !== void 0) {
|
|
2215
|
+
if (t.width === 0 || t.height === 0) throw TypeError("visibleRect dimensions cannot be zero.");
|
|
2216
|
+
if ((t.x || 0) + (t.width || 0) > n) throw TypeError("visibleRect exceeds codedWidth.");
|
|
2217
|
+
if ((t.y || 0) + (t.height || 0) > r) throw TypeError("visibleRect exceeds codedHeight.");
|
|
2218
|
+
a.x = t.x || 0, a.y = t.y || 0, a.width = t.width || 0, a.height = t.height || 0;
|
|
2219
|
+
}
|
|
2220
|
+
if (!Mt(i, a)) throw TypeError("visibleRect alignment is invalid for the format.");
|
|
2221
|
+
return a;
|
|
2222
|
+
}, Mt = (e, t) => {
|
|
2223
|
+
if (e === null) return !0;
|
|
2224
|
+
let n = X(e);
|
|
2225
|
+
for (let e = 0; e < n.length; e++) {
|
|
2226
|
+
let r = n[e], i = r.widthDivisor, a = r.heightDivisor;
|
|
2227
|
+
if ((t.x || 0) % i !== 0 || (t.y || 0) % a !== 0) return !1;
|
|
2228
|
+
}
|
|
2229
|
+
return !0;
|
|
2230
|
+
}, Nt = (e, t, n) => {
|
|
2231
|
+
let r = X(t), i = r.length;
|
|
2232
|
+
if (n !== void 0 && n.length !== i) throw TypeError(`Layout must have ${i} planes.`);
|
|
2233
|
+
let a = 0, o = [], s = [];
|
|
2234
|
+
for (let t = 0; t < i; t++) {
|
|
2235
|
+
let i = r[t], c = i.sampleBytes, l = i.widthDivisor, u = i.heightDivisor, d = {
|
|
2236
|
+
destinationOffset: 0,
|
|
2237
|
+
destinationStride: 0,
|
|
2238
|
+
sourceTop: 0,
|
|
2239
|
+
sourceHeight: 0,
|
|
2240
|
+
sourceLeftBytes: 0,
|
|
2241
|
+
sourceWidthBytes: 0
|
|
2242
|
+
};
|
|
2243
|
+
if (d.sourceTop = Math.ceil(Math.trunc(e.y || 0) / u), d.sourceHeight = Math.ceil(Math.trunc(e.height || 0) / u), d.sourceLeftBytes = Math.floor(Math.trunc(e.x || 0) / l) * c, d.sourceWidthBytes = Math.floor(Math.trunc(e.width || 0) / l) * c, n !== void 0) {
|
|
2244
|
+
let e = n[t];
|
|
2245
|
+
if (e.stride < d.sourceWidthBytes) throw TypeError(`Stride for plane ${t} is too small.`);
|
|
2246
|
+
d.destinationOffset = e.offset, d.destinationStride = e.stride;
|
|
2247
|
+
} else d.destinationOffset = a, d.destinationStride = d.sourceWidthBytes;
|
|
2248
|
+
let f = d.destinationStride * d.sourceHeight + d.destinationOffset;
|
|
2249
|
+
if (f > 4294967295) throw TypeError("Allocation size exceeds limit.");
|
|
2250
|
+
s.push(f), a = Math.max(a, f);
|
|
2251
|
+
for (let e = 0; e < t; e++) {
|
|
2252
|
+
let n = o[e];
|
|
2253
|
+
if (!(s[t] <= n.destinationOffset || s[e] <= d.destinationOffset)) throw TypeError("Planes overlap.");
|
|
2254
|
+
}
|
|
2255
|
+
o.push(d);
|
|
2256
|
+
}
|
|
2257
|
+
return {
|
|
2258
|
+
allocationSize: a,
|
|
2259
|
+
computedLayouts: o
|
|
2260
|
+
};
|
|
2261
|
+
}, Pt = (e) => {
|
|
2262
|
+
if (!e || typeof e != "object") throw TypeError("Encoding config must be an object.");
|
|
2263
|
+
if (!M.includes(e.codec)) throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${M.join(", ")}.`);
|
|
2264
|
+
let t = e.bitrate;
|
|
2265
|
+
if (e.quality === void 0 && t === void 0) throw TypeError("config.quality must be provided.");
|
|
2266
|
+
if (e.quality !== void 0 && t !== void 0) throw TypeError("config.quality and config.bitrate cannot both be provided.");
|
|
2267
|
+
if (e.quality !== void 0 && !(e.quality instanceof Z)) throw TypeError("config.quality, when provided, must be a Quality.");
|
|
2268
|
+
if (t !== void 0 && !(t instanceof Z) && (!Number.isInteger(t) || t <= 0)) throw TypeError("config.bitrate, when provided, must be a positive integer or a quality.");
|
|
2269
|
+
if (e.keyFrameInterval !== void 0 && (!Number.isFinite(e.keyFrameInterval) || e.keyFrameInterval < 0)) throw TypeError("config.keyFrameInterval, when provided, must be a non-negative number.");
|
|
2270
|
+
if (e.sizeChangeBehavior !== void 0 && ![
|
|
2271
|
+
"deny",
|
|
2272
|
+
"passThrough",
|
|
2273
|
+
"fill",
|
|
2274
|
+
"contain",
|
|
2275
|
+
"cover"
|
|
2276
|
+
].includes(e.sizeChangeBehavior)) throw TypeError("config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.");
|
|
2277
|
+
if (e.transform !== void 0) {
|
|
2278
|
+
if (typeof e.transform != "object" || !e.transform) throw TypeError("config.transform, when provided, must be an object.");
|
|
2279
|
+
if (e.transform.width !== void 0 && (!Number.isInteger(e.transform.width) || e.transform.width <= 0)) throw TypeError("config.transform.width, when provided, must be a positive integer.");
|
|
2280
|
+
if (e.transform.height !== void 0 && (!Number.isInteger(e.transform.height) || e.transform.height <= 0)) throw TypeError("config.transform.height, when provided, must be a positive integer.");
|
|
2281
|
+
if (e.transform.fit !== void 0 && ![
|
|
2282
|
+
"fill",
|
|
2283
|
+
"contain",
|
|
2284
|
+
"cover"
|
|
2285
|
+
].includes(e.transform.fit)) throw TypeError("config.transform.fit, when provided, must be one of \"fill\", \"contain\", or \"cover\".");
|
|
2286
|
+
if (e.transform.width !== void 0 && e.transform.height !== void 0 && e.transform.fit === void 0 && ![
|
|
2287
|
+
"fill",
|
|
2288
|
+
"contain",
|
|
2289
|
+
"cover"
|
|
2290
|
+
].includes(e.sizeChangeBehavior)) throw TypeError("When both config.transform.width and config.transform.height are provided, config.transform.fit must also be provided.");
|
|
2291
|
+
if (e.transform.fit !== void 0 && [
|
|
2292
|
+
"fill",
|
|
2293
|
+
"contain",
|
|
2294
|
+
"cover"
|
|
2295
|
+
].includes(e.sizeChangeBehavior) && e.transform.fit !== e.sizeChangeBehavior) throw TypeError("config.transform.fit, when provided, cannot differ from config.sizeChangeBehavior when config.sizeChangeBehavior is 'fill', 'contain' or 'cover', as sizeChangeBehavior already determines the fitting algorithm.");
|
|
2296
|
+
if (e.transform.rotate !== void 0 && ![
|
|
2297
|
+
0,
|
|
2298
|
+
90,
|
|
2299
|
+
180,
|
|
2300
|
+
270
|
|
2301
|
+
].includes(e.transform.rotate)) throw TypeError("config.transform.rotate, when provided, must be 0, 90, 180 or 270.");
|
|
2302
|
+
if (e.transform.crop !== void 0 && Y(e.transform.crop, "config.transform."), e.transform.process !== void 0 && typeof e.transform.process != "function") throw TypeError("config.transform.process, when provided, must be a function.");
|
|
2303
|
+
if (e.transform.frameRate !== void 0 && (!Number.isFinite(e.transform.frameRate) || e.transform.frameRate <= 0)) throw TypeError("config.transform.frameRate, when provided, must be a finite positive number.");
|
|
2304
|
+
if (e.transform.force !== void 0 && typeof e.transform.force != "boolean") throw TypeError("config.transform.force, when provided, must be a boolean.");
|
|
2305
|
+
}
|
|
2306
|
+
if (e.onEncodedPacket !== void 0 && typeof e.onEncodedPacket != "function") throw TypeError("config.onEncodedPacket, when provided, must be a function.");
|
|
2307
|
+
if (e.onEncoderConfig !== void 0 && typeof e.onEncoderConfig != "function") throw TypeError("config.onEncoderConfig, when provided, must be a function.");
|
|
2308
|
+
if (e.onEncodedSample !== void 0 && typeof e.onEncodedSample != "function") throw TypeError("config.onEncodedSample, when provided, must be a function.");
|
|
2309
|
+
Ft(e.codec, e);
|
|
2310
|
+
}, Ft = (e, t) => {
|
|
2311
|
+
if (!t || typeof t != "object") throw TypeError("Encoding options must be an object.");
|
|
2312
|
+
if (t.alpha !== void 0 && !["discard", "keep"].includes(t.alpha)) throw TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");
|
|
2313
|
+
let n = t.bitrateMode;
|
|
2314
|
+
if (n !== void 0 && !["constant", "variable"].includes(n)) throw TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");
|
|
2315
|
+
if (t.latencyMode !== void 0 && !["quality", "realtime"].includes(t.latencyMode)) throw TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");
|
|
2316
|
+
if (t.fullCodecString !== void 0 && typeof t.fullCodecString != "string") throw TypeError("fullCodecString, when provided, must be a string.");
|
|
2317
|
+
if (t.fullCodecString !== void 0 && L(t.fullCodecString) !== e) throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);
|
|
2318
|
+
if (t.hardwareAcceleration !== void 0 && ![
|
|
2319
|
+
"no-preference",
|
|
2320
|
+
"prefer-hardware",
|
|
2321
|
+
"prefer-software"
|
|
2322
|
+
].includes(t.hardwareAcceleration)) throw TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");
|
|
2323
|
+
if (t.scalabilityMode !== void 0 && typeof t.scalabilityMode != "string") throw TypeError("scalabilityMode, when provided, must be a string.");
|
|
2324
|
+
if (t.contentHint !== void 0 && typeof t.contentHint != "string") throw TypeError("contentHint, when provided, must be a string.");
|
|
2325
|
+
}, It = (e) => {
|
|
2326
|
+
let n = e.bitrateMode, r = e.quality._toVideoRateControl(e.codec, e.width, e.height, n), i = (t, n, r) => ({
|
|
2327
|
+
codec: e.fullCodecString ?? ke(e.codec, e.width, e.height, r, e.alpha === "keep"),
|
|
2328
|
+
width: e.width,
|
|
2329
|
+
height: e.height,
|
|
2330
|
+
displayWidth: e.squarePixelWidth,
|
|
2331
|
+
displayHeight: e.squarePixelHeight,
|
|
2332
|
+
bitrate: t,
|
|
2333
|
+
bitrateMode: n,
|
|
2334
|
+
alpha: e.alpha ?? "discard",
|
|
2335
|
+
framerate: e.framerate,
|
|
2336
|
+
latencyMode: e.latencyMode,
|
|
2337
|
+
hardwareAcceleration: e.hardwareAcceleration,
|
|
2338
|
+
scalabilityMode: e.scalabilityMode,
|
|
2339
|
+
contentHint: e.contentHint,
|
|
2340
|
+
...Fe(e.codec)
|
|
2341
|
+
}), a = [];
|
|
2342
|
+
return r.quantizer !== null && a.push({
|
|
2343
|
+
config: i(void 0, "quantizer", r.bitrate),
|
|
2344
|
+
quantizer: r.quantizer
|
|
2345
|
+
}), r.bitrateMode !== "quantizer" && a.push({
|
|
2346
|
+
config: i(r.bitrate, r.bitrateMode, r.bitrate),
|
|
2347
|
+
quantizer: null
|
|
2348
|
+
}), t(a.length > 0), a;
|
|
2349
|
+
}, Z = class {
|
|
2350
|
+
constructor(e) {
|
|
2351
|
+
if ((typeof e == "number" || typeof e == "string") && (e = { quality: e }), !e || typeof e != "object") throw TypeError("options must be an object.");
|
|
2352
|
+
if (e.bitrateMode !== void 0 && !["constant", "variable"].includes(e.bitrateMode)) throw TypeError("options.bitrateMode, when provided, must be 'constant' or 'variable'.");
|
|
2353
|
+
if ("quality" in e) {
|
|
2354
|
+
if (typeof e.quality == "string" ? !(e.quality in Lt) : typeof e.quality != "number" || Number.isNaN(e.quality)) throw TypeError("options.quality must be a number, or one of 'very-low', 'low', 'medium', 'high' or 'very-high'.");
|
|
2355
|
+
if (e.preferBitrate !== void 0 && typeof e.preferBitrate != "boolean") throw TypeError("options.preferBitrate, when provided, must be a boolean.");
|
|
2356
|
+
if ("bitrate" in e || "quantizer" in e) throw TypeError("options.quality cannot be combined with options.bitrate or options.quantizer.");
|
|
2357
|
+
this._quality = typeof e.quality == "string" ? Lt[e.quality] : e.quality, this._preferBitrate = e.preferBitrate ?? !1, this._bitrate = void 0, this._quantizer = void 0;
|
|
2358
|
+
} else {
|
|
2359
|
+
if (e.bitrate !== void 0 && (!Number.isInteger(e.bitrate) || e.bitrate <= 0)) throw TypeError("options.bitrate, when provided, must be a positive integer.");
|
|
2360
|
+
if (e.quantizer !== void 0 && (!Number.isInteger(e.quantizer) || e.quantizer < 0)) throw TypeError("options.quantizer, when provided, must be a non-negative integer.");
|
|
2361
|
+
if (e.bitrate === void 0 && e.quantizer === void 0) throw TypeError("At least one of options.bitrate or options.quantizer must be set.");
|
|
2362
|
+
if ("preferBitrate" in e) throw TypeError("options.preferBitrate can only be combined with options.quality.");
|
|
2363
|
+
this._quality = void 0, this._preferBitrate = !1, this._bitrate = e.bitrate, this._quantizer = e.quantizer;
|
|
2364
|
+
}
|
|
2365
|
+
this._bitrateMode = e.bitrateMode;
|
|
2366
|
+
}
|
|
2367
|
+
_toVideoRateControl(e, n, r, i) {
|
|
2368
|
+
let a = Rt[e], o = null, s = this._bitrateMode ?? i ?? "variable";
|
|
2369
|
+
if (this._quantizer !== void 0) {
|
|
2370
|
+
if (!a) {
|
|
2371
|
+
if (this._bitrate === void 0) throw Error(`Codec '${e}' does not support quantizer-based encoding. Provide a bitrate in the Quality to define a fallback.`);
|
|
2372
|
+
} else if (this._quantizer < a.min || this._quantizer > a.max) {
|
|
2373
|
+
if (this._bitrate === void 0) throw Error(`Quantizer ${this._quantizer} is out of range for codec '${e}'; must be between ${a.min} and ${a.max}.`);
|
|
2374
|
+
} else o = this._quantizer, this._bitrate === void 0 && (s = "quantizer");
|
|
2375
|
+
} else this._bitrate === void 0 && a && !this._preferBitrate && (t(this._quality !== void 0), o = v(Math.round(y(a.worst, a.best, this._quality)), a.min, a.max));
|
|
2376
|
+
let c;
|
|
2377
|
+
if (this._bitrate !== void 0) c = this._bitrate;
|
|
2378
|
+
else {
|
|
2379
|
+
let i = this._quality;
|
|
2380
|
+
i === void 0 && (t(o !== null && a), i = v((o - a.worst) / (a.best - a.worst), 0, 1)), c = Bt(e, n, r, zt(i));
|
|
2381
|
+
}
|
|
2382
|
+
return {
|
|
2383
|
+
quantizer: o,
|
|
2384
|
+
bitrate: c,
|
|
2385
|
+
bitrateMode: s
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
_toVideoBitrate(e, n, r) {
|
|
2389
|
+
return this._bitrate === void 0 ? (t(this._quality !== void 0), Bt(e, n, r, zt(this._quality))) : this._bitrate;
|
|
2390
|
+
}
|
|
2391
|
+
_toAudioBitrate(e) {
|
|
2392
|
+
if (N.includes(e) || e === "flac") return;
|
|
2393
|
+
if (this._bitrate !== void 0) return this._bitrate;
|
|
2394
|
+
if (this._quality === void 0) throw Error("This Quality defines neither a quality level nor a bitrate and therefore cannot be used for audio encoding.");
|
|
2395
|
+
let t = zt(this._quality), n = {
|
|
2396
|
+
aac: 128e3,
|
|
2397
|
+
opus: 64e3,
|
|
2398
|
+
mp3: 16e4,
|
|
2399
|
+
vorbis: 64e3,
|
|
2400
|
+
ac3: 384e3,
|
|
2401
|
+
eac3: 192e3
|
|
2402
|
+
}[e];
|
|
2403
|
+
if (!n) throw Error(`Unhandled codec: ${e}`);
|
|
2404
|
+
let r = n * t;
|
|
2405
|
+
return e === "aac" ? r = [
|
|
2406
|
+
96e3,
|
|
2407
|
+
128e3,
|
|
2408
|
+
16e4,
|
|
2409
|
+
192e3
|
|
2410
|
+
].reduce((e, t) => Math.abs(t - r) < Math.abs(e - r) ? t : e) : e === "opus" || e === "vorbis" ? r = Math.max(6e3, r) : e === "mp3" && (r = [
|
|
2411
|
+
8e3,
|
|
2412
|
+
16e3,
|
|
2413
|
+
24e3,
|
|
2414
|
+
32e3,
|
|
2415
|
+
4e4,
|
|
2416
|
+
48e3,
|
|
2417
|
+
64e3,
|
|
2418
|
+
8e4,
|
|
2419
|
+
96e3,
|
|
2420
|
+
112e3,
|
|
2421
|
+
128e3,
|
|
2422
|
+
16e4,
|
|
2423
|
+
192e3,
|
|
2424
|
+
224e3,
|
|
2425
|
+
256e3,
|
|
2426
|
+
32e4
|
|
2427
|
+
].reduce((e, t) => Math.abs(t - r) < Math.abs(e - r) ? t : e)), Math.round(r / 1e3) * 1e3;
|
|
2428
|
+
}
|
|
2429
|
+
}, Lt = {
|
|
2430
|
+
"very-low": 0,
|
|
2431
|
+
low: .25,
|
|
2432
|
+
medium: .5,
|
|
2433
|
+
high: .75,
|
|
2434
|
+
"very-high": 1
|
|
2435
|
+
}, Rt = {
|
|
2436
|
+
avc: {
|
|
2437
|
+
min: 0,
|
|
2438
|
+
max: 51,
|
|
2439
|
+
worst: 41,
|
|
2440
|
+
best: 16
|
|
2441
|
+
},
|
|
2442
|
+
hevc: {
|
|
2443
|
+
min: 0,
|
|
2444
|
+
max: 51,
|
|
2445
|
+
worst: 41,
|
|
2446
|
+
best: 16
|
|
2447
|
+
},
|
|
2448
|
+
vp9: {
|
|
2449
|
+
min: 0,
|
|
2450
|
+
max: 63,
|
|
2451
|
+
worst: 52,
|
|
2452
|
+
best: 20
|
|
2453
|
+
},
|
|
2454
|
+
av1: {
|
|
2455
|
+
min: 0,
|
|
2456
|
+
max: 255,
|
|
2457
|
+
worst: 208,
|
|
2458
|
+
best: 80
|
|
2459
|
+
}
|
|
2460
|
+
}, zt = (e) => .3 * Math.exp(2.5538 * e), Bt = (e, t, n, r) => {
|
|
2461
|
+
let i = t * n, a = 3e6, o = a * (i / 2073600) ** .95 * {
|
|
2462
|
+
avc: 1,
|
|
2463
|
+
hevc: .6,
|
|
2464
|
+
vp9: .6,
|
|
2465
|
+
av1: .4,
|
|
2466
|
+
vp8: 1.2,
|
|
2467
|
+
prores: 22e7 / a
|
|
2468
|
+
}[e] * r;
|
|
2469
|
+
return Math.ceil(o / 1e3) * 1e3;
|
|
2470
|
+
}, Vt = (e, n) => {
|
|
2471
|
+
if (e === "avc") return { avc: { quantizer: n } };
|
|
2472
|
+
if (e === "hevc") return { hevc: { quantizer: n } };
|
|
2473
|
+
if (e === "vp9") return { vp9: { quantizer: n } };
|
|
2474
|
+
if (e === "av1") return { av1: { quantizer: n } };
|
|
2475
|
+
t(!1);
|
|
2476
|
+
}, Ht = (e, t) => {
|
|
2477
|
+
if (e !== void 0) return e;
|
|
2478
|
+
if (t !== void 0) return t instanceof Z ? t : new Z({ bitrate: t });
|
|
2479
|
+
}, Ut = [], Wt = class e {
|
|
2480
|
+
constructor(e, t, n, r, i) {
|
|
2481
|
+
this.bytes = e, this.view = t, this.offset = n, this.start = r, this.end = i, this.bufferPos = r - n;
|
|
2482
|
+
}
|
|
2483
|
+
static tempFromBytes(t) {
|
|
2484
|
+
return new e(t, s(t), 0, 0, t.length);
|
|
2485
|
+
}
|
|
2486
|
+
get length() {
|
|
2487
|
+
return this.end - this.start;
|
|
2488
|
+
}
|
|
2489
|
+
get filePos() {
|
|
2490
|
+
return this.offset + this.bufferPos;
|
|
2491
|
+
}
|
|
2492
|
+
set filePos(e) {
|
|
2493
|
+
this.bufferPos = e - this.offset;
|
|
2494
|
+
}
|
|
2495
|
+
get remainingLength() {
|
|
2496
|
+
return Math.max(this.end - this.filePos, 0);
|
|
2497
|
+
}
|
|
2498
|
+
skip(e) {
|
|
2499
|
+
this.bufferPos += e;
|
|
2500
|
+
}
|
|
2501
|
+
slice(t, n = this.end - t) {
|
|
2502
|
+
if (t < this.start || t + n > this.end) throw RangeError("Slicing outside of original slice.");
|
|
2503
|
+
return new e(this.bytes, this.view, this.offset, t, t + n);
|
|
2504
|
+
}
|
|
2505
|
+
}, Gt = (e, t) => {
|
|
2506
|
+
if (e.filePos < e.start || e.filePos + t > e.end) throw RangeError(`Tried reading [${e.filePos}, ${e.filePos + t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`);
|
|
2507
|
+
}, Kt = (e, t) => {
|
|
2508
|
+
Gt(e, t);
|
|
2509
|
+
let n = e.bytes.subarray(e.bufferPos, e.bufferPos + t);
|
|
2510
|
+
return e.bufferPos += t, n;
|
|
2511
|
+
}, qt = class {
|
|
2512
|
+
constructor(e) {
|
|
2513
|
+
this.mutex = new m(), this.trackTimestampInfo = /* @__PURE__ */ new WeakMap(), this.output = e;
|
|
2514
|
+
}
|
|
2515
|
+
onTrackClose(e) {}
|
|
2516
|
+
validateTimestamp(e, t, n) {
|
|
2517
|
+
if (t < 0) throw Error(`Timestamps must be non-negative (got ${t}s).`);
|
|
2518
|
+
let r = this.trackTimestampInfo.get(e);
|
|
2519
|
+
if (r) {
|
|
2520
|
+
if (n && (r.maxTimestampBeforeLastKeyPacket = r.maxTimestamp), r.maxTimestampBeforeLastKeyPacket !== null && t < r.maxTimestampBeforeLastKeyPacket) throw Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${r.maxTimestampBeforeLastKeyPacket}s.`);
|
|
2521
|
+
r.maxTimestamp = Math.max(r.maxTimestamp, t);
|
|
2522
|
+
} else {
|
|
2523
|
+
if (!n) throw Error("First packet must be a key packet.");
|
|
2524
|
+
r = {
|
|
2525
|
+
maxTimestamp: t,
|
|
2526
|
+
maxTimestampBeforeLastKeyPacket: null
|
|
2527
|
+
}, this.trackTimestampInfo.set(e, r);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
}, Jt = /<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g, Yt = /(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})/, Xt = (e) => {
|
|
2531
|
+
let t = Yt.exec(e);
|
|
2532
|
+
if (!t) throw Error("Expected match.");
|
|
2533
|
+
return 36e5 * Number(t[1] || "0") + 6e4 * Number(t[2]) + 1e3 * Number(t[3]) + Number(t[4]);
|
|
2534
|
+
}, Zt = (e) => {
|
|
2535
|
+
let t = Math.floor(e / 36e5), n = Math.floor(e % 36e5 / 6e4), r = Math.floor(e % 6e4 / 1e3), i = e % 1e3;
|
|
2536
|
+
return t.toString().padStart(2, "0") + ":" + n.toString().padStart(2, "0") + ":" + r.toString().padStart(2, "0") + "." + i.toString().padStart(3, "0");
|
|
2537
|
+
};
|
|
2538
|
+
e();
|
|
2539
|
+
var Qt = class {
|
|
2540
|
+
constructor(e, t) {
|
|
2541
|
+
if (this.finalized = !1, this.started = !1, this.pos = 0, this.trackedWrites = null, this.trackedStart = -1, this.trackedEnd = -1, e._writerAcquired) throw Error("Can't have multiple Writers for the same Target.");
|
|
2542
|
+
this.target = e, e._setMonotonicity(t), e._writerAcquired = !0;
|
|
2543
|
+
}
|
|
2544
|
+
start() {
|
|
2545
|
+
t(!this.started), this.target._start(), this.started = !0;
|
|
2546
|
+
}
|
|
2547
|
+
write(e) {
|
|
2548
|
+
t(this.started && !this.finalized), this.maybeTrackWrites(e), this.target._write(e, this.pos), this.pos += e.byteLength;
|
|
2549
|
+
}
|
|
2550
|
+
seek(e) {
|
|
2551
|
+
this.pos = e;
|
|
2552
|
+
}
|
|
2553
|
+
getPos() {
|
|
2554
|
+
return this.pos;
|
|
2555
|
+
}
|
|
2556
|
+
async flush() {
|
|
2557
|
+
return t(this.started && !this.finalized), this.target._flush();
|
|
2558
|
+
}
|
|
2559
|
+
async finalize() {
|
|
2560
|
+
t(this.started && !this.finalized), await this.target._finalize(), this.finalized = !0;
|
|
2561
|
+
}
|
|
2562
|
+
maybeTrackWrites(e) {
|
|
2563
|
+
if (!this.trackedWrites) return;
|
|
2564
|
+
let t = this.getPos();
|
|
2565
|
+
if (t < this.trackedStart) {
|
|
2566
|
+
if (t + e.byteLength <= this.trackedStart) return;
|
|
2567
|
+
e = e.subarray(this.trackedStart - t), t = 0;
|
|
2568
|
+
}
|
|
2569
|
+
let n = t + e.byteLength - this.trackedStart, r = this.trackedWrites.byteLength;
|
|
2570
|
+
for (; r < n;) r *= 2;
|
|
2571
|
+
if (r !== this.trackedWrites.byteLength) {
|
|
2572
|
+
let e = new Uint8Array(r);
|
|
2573
|
+
e.set(this.trackedWrites, 0), this.trackedWrites = e;
|
|
2574
|
+
}
|
|
2575
|
+
this.trackedWrites.set(e, t - this.trackedStart), this.trackedEnd = Math.max(this.trackedEnd, t + e.byteLength);
|
|
2576
|
+
}
|
|
2577
|
+
startTrackingWrites() {
|
|
2578
|
+
this.trackedWrites = /* @__PURE__ */ new Uint8Array(1024), this.trackedStart = this.getPos(), this.trackedEnd = this.trackedStart;
|
|
2579
|
+
}
|
|
2580
|
+
stopTrackingWrites() {
|
|
2581
|
+
if (!this.trackedWrites) throw Error("Internal error: Can't get tracked writes since nothing was tracked.");
|
|
2582
|
+
let e = {
|
|
2583
|
+
data: this.trackedWrites.subarray(0, this.trackedEnd - this.trackedStart),
|
|
2584
|
+
start: this.trackedStart,
|
|
2585
|
+
end: this.trackedEnd
|
|
2586
|
+
};
|
|
2587
|
+
return this.trackedWrites = null, e;
|
|
2588
|
+
}
|
|
2589
|
+
}, Q = class extends O {
|
|
2590
|
+
constructor() {
|
|
2591
|
+
super(...arguments), this._writerAcquired = !1, this._monotonicity = null, this.onwrite = null;
|
|
2592
|
+
}
|
|
2593
|
+
_setMonotonicity(e) {
|
|
2594
|
+
this._monotonicity !== !1 && (this._monotonicity = e);
|
|
2595
|
+
}
|
|
2596
|
+
_dispatchWrite(e, t) {
|
|
2597
|
+
this.onwrite?.(e, t), this._emit("write", {
|
|
2598
|
+
start: e,
|
|
2599
|
+
end: t
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2602
|
+
slice(e) {
|
|
2603
|
+
if (!Number.isInteger(e) || e < 0) throw TypeError("offset must be a non-negative integer.");
|
|
2604
|
+
return new tn(this, e);
|
|
2605
|
+
}
|
|
2606
|
+
}, $ = 2 ** 16, $t = 2 ** 32, en = class extends Q {
|
|
2607
|
+
constructor(e = {}) {
|
|
2608
|
+
if (super(), this.buffer = null, this._maxPos = 0, !e || typeof e != "object") throw TypeError("BufferTarget options, when provided, must be an object.");
|
|
2609
|
+
if (e.onFinalize !== void 0 && typeof e.onFinalize != "function") throw TypeError("options.onFinalize, when provided, must be a function.");
|
|
2610
|
+
if (this._options = e, this._supportsResize = "resize" in /* @__PURE__ */ new ArrayBuffer(0), this._supportsResize) try {
|
|
2611
|
+
this._buffer = new ArrayBuffer($, { maxByteLength: $t });
|
|
2612
|
+
} catch {
|
|
2613
|
+
this._buffer = new ArrayBuffer($), this._supportsResize = !1;
|
|
2614
|
+
}
|
|
2615
|
+
else this._buffer = new ArrayBuffer($);
|
|
2616
|
+
this._bytes = new Uint8Array(this._buffer);
|
|
2617
|
+
}
|
|
2618
|
+
_ensureSize(e) {
|
|
2619
|
+
let t = this._buffer.byteLength;
|
|
2620
|
+
for (; t < e;) t *= 2;
|
|
2621
|
+
if (t !== this._buffer.byteLength) {
|
|
2622
|
+
if (t > $t) throw Error(`ArrayBuffer exceeded maximum size of ${$t} bytes. Please consider using another target.`);
|
|
2623
|
+
if (this._supportsResize) this._buffer.resize(t);
|
|
2624
|
+
else {
|
|
2625
|
+
let e = new ArrayBuffer(t), n = new Uint8Array(e);
|
|
2626
|
+
n.set(this._bytes, 0), this._buffer = e, this._bytes = n;
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
_start() {}
|
|
2631
|
+
_write(e, t) {
|
|
2632
|
+
this._ensureSize(t + e.byteLength), this._bytes.set(e, t), this._maxPos = Math.max(this._maxPos, t + e.byteLength), this._dispatchWrite(t, t + e.byteLength);
|
|
2633
|
+
}
|
|
2634
|
+
async _flush() {}
|
|
2635
|
+
async _finalize() {
|
|
2636
|
+
this.buffer = this._buffer.slice(0, this._maxPos), this._options.onFinalize && await this._options.onFinalize(this.buffer), this._emit("finalized");
|
|
2637
|
+
}
|
|
2638
|
+
async _close() {}
|
|
2639
|
+
_getSlice(e, t) {
|
|
2640
|
+
return this._bytes.slice(e, t);
|
|
2641
|
+
}
|
|
2642
|
+
}, tn = class extends Q {
|
|
2643
|
+
constructor(e, t) {
|
|
2644
|
+
super(), this._baseTarget = e, this._offset = t;
|
|
2645
|
+
}
|
|
2646
|
+
_start() {}
|
|
2647
|
+
_write(e, t) {
|
|
2648
|
+
this._baseTarget._write(e, this._offset + t), this._dispatchWrite(t, t + e.byteLength);
|
|
2649
|
+
}
|
|
2650
|
+
_flush() {
|
|
2651
|
+
return this._baseTarget._flush();
|
|
2652
|
+
}
|
|
2653
|
+
async _finalize() {
|
|
2654
|
+
this._emit("finalized");
|
|
2655
|
+
}
|
|
2656
|
+
async _close() {}
|
|
2657
|
+
_setMonotonicity(e) {
|
|
2658
|
+
super._setMonotonicity(e), this._baseTarget._setMonotonicity(e);
|
|
2659
|
+
}
|
|
2660
|
+
}, nn = class {
|
|
2661
|
+
constructor(e, t) {
|
|
2662
|
+
if (this.rootPath = e, this.getTarget = t, typeof e != "string") throw TypeError("rootPath must be a string.");
|
|
2663
|
+
if (typeof t != "function") throw TypeError("getTarget must be a function.");
|
|
2664
|
+
}
|
|
2665
|
+
}, rn = -(2 ** 15), an = 2 ** 15 - 1, on = "Mediabunny", sn = 6, cn = 5, ln = {
|
|
2666
|
+
video: 1,
|
|
2667
|
+
audio: 2,
|
|
2668
|
+
subtitle: 17
|
|
2669
|
+
}, un = class extends qt {
|
|
2670
|
+
constructor(e, t) {
|
|
2671
|
+
super(e), this.trackDatas = [], this.allTracksKnown = g(), this.segment = null, this.segmentInfo = null, this.seekHead = null, this.tracksElement = null, this.tagsElement = null, this.attachmentsElement = null, this.segmentDuration = null, this.cues = null, this.currentCluster = null, this.currentClusterStartMsTimestamp = null, this.currentClusterMaxMsTimestamp = null, this.trackDatasInCurrentCluster = /* @__PURE__ */ new Map(), this.startTimestamp = Infinity, this.endTimestamp = -Infinity, this.format = t;
|
|
2672
|
+
}
|
|
2673
|
+
async start() {
|
|
2674
|
+
let e = await this.mutex.acquire();
|
|
2675
|
+
this.writer = await this.output._getRootWriter(!!this.format._options.appendOnly), this.ebmlWriter = new mt(this.writer), this.writeEBMLHeader(), this.createSegmentInfo(), this.createCues(), await this.writer.flush();
|
|
2676
|
+
for (let e of this.output.tracks) e.isVideoTrack() && e.metadata.decoderConfig ? this.getVideoTrackData(e, e.metadata.primingPacket ?? null, { decoderConfig: e.metadata.decoderConfig }) : e.isAudioTrack() && e.metadata.decoderConfig && this.getAudioTrackData(e, e.metadata.primingPacket ?? null, { decoderConfig: e.metadata.decoderConfig });
|
|
2677
|
+
e();
|
|
2678
|
+
}
|
|
2679
|
+
writeEBMLHeader() {
|
|
2680
|
+
this.format._options.onEbmlHeader && this.writer.startTrackingWrites();
|
|
2681
|
+
let e = {
|
|
2682
|
+
id: V.EBML,
|
|
2683
|
+
data: [
|
|
2684
|
+
{
|
|
2685
|
+
id: V.EBMLVersion,
|
|
2686
|
+
data: 1
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
id: V.EBMLReadVersion,
|
|
2690
|
+
data: 1
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
id: V.EBMLMaxIDLength,
|
|
2694
|
+
data: 4
|
|
2695
|
+
},
|
|
2696
|
+
{
|
|
2697
|
+
id: V.EBMLMaxSizeLength,
|
|
2698
|
+
data: 8
|
|
2699
|
+
},
|
|
2700
|
+
{
|
|
2701
|
+
id: V.DocType,
|
|
2702
|
+
data: this.format instanceof Tn ? "webm" : "matroska"
|
|
2703
|
+
},
|
|
2704
|
+
{
|
|
2705
|
+
id: V.DocTypeVersion,
|
|
2706
|
+
data: 2
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
id: V.DocTypeReadVersion,
|
|
2710
|
+
data: 2
|
|
2711
|
+
}
|
|
2712
|
+
]
|
|
2713
|
+
};
|
|
2714
|
+
if (this.ebmlWriter.writeEBML(e), this.format._options.onEbmlHeader) {
|
|
2715
|
+
let { data: e, start: t } = this.writer.stopTrackingWrites();
|
|
2716
|
+
this.format._options.onEbmlHeader(e, t);
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
maybeCreateSeekHead(e) {
|
|
2720
|
+
if (this.format._options.appendOnly) return;
|
|
2721
|
+
let t = new Uint8Array([
|
|
2722
|
+
28,
|
|
2723
|
+
83,
|
|
2724
|
+
187,
|
|
2725
|
+
107
|
|
2726
|
+
]), n = new Uint8Array([
|
|
2727
|
+
21,
|
|
2728
|
+
73,
|
|
2729
|
+
169,
|
|
2730
|
+
102
|
|
2731
|
+
]), r = new Uint8Array([
|
|
2732
|
+
22,
|
|
2733
|
+
84,
|
|
2734
|
+
174,
|
|
2735
|
+
107
|
|
2736
|
+
]), i = new Uint8Array([
|
|
2737
|
+
25,
|
|
2738
|
+
65,
|
|
2739
|
+
164,
|
|
2740
|
+
105
|
|
2741
|
+
]), a = new Uint8Array([
|
|
2742
|
+
18,
|
|
2743
|
+
84,
|
|
2744
|
+
195,
|
|
2745
|
+
103
|
|
2746
|
+
]), o = {
|
|
2747
|
+
id: V.SeekHead,
|
|
2748
|
+
data: [
|
|
2749
|
+
{
|
|
2750
|
+
id: V.Seek,
|
|
2751
|
+
data: [{
|
|
2752
|
+
id: V.SeekID,
|
|
2753
|
+
data: t
|
|
2754
|
+
}, {
|
|
2755
|
+
id: V.SeekPosition,
|
|
2756
|
+
size: 5,
|
|
2757
|
+
data: e ? this.ebmlWriter.offsets.get(this.cues) - this.segmentDataOffset : 0
|
|
2758
|
+
}]
|
|
2759
|
+
},
|
|
2760
|
+
{
|
|
2761
|
+
id: V.Seek,
|
|
2762
|
+
data: [{
|
|
2763
|
+
id: V.SeekID,
|
|
2764
|
+
data: n
|
|
2765
|
+
}, {
|
|
2766
|
+
id: V.SeekPosition,
|
|
2767
|
+
size: 5,
|
|
2768
|
+
data: e ? this.ebmlWriter.offsets.get(this.segmentInfo) - this.segmentDataOffset : 0
|
|
2769
|
+
}]
|
|
2770
|
+
},
|
|
2771
|
+
{
|
|
2772
|
+
id: V.Seek,
|
|
2773
|
+
data: [{
|
|
2774
|
+
id: V.SeekID,
|
|
2775
|
+
data: r
|
|
2776
|
+
}, {
|
|
2777
|
+
id: V.SeekPosition,
|
|
2778
|
+
size: 5,
|
|
2779
|
+
data: e ? this.ebmlWriter.offsets.get(this.tracksElement) - this.segmentDataOffset : 0
|
|
2780
|
+
}]
|
|
2781
|
+
},
|
|
2782
|
+
this.attachmentsElement ? {
|
|
2783
|
+
id: V.Seek,
|
|
2784
|
+
data: [{
|
|
2785
|
+
id: V.SeekID,
|
|
2786
|
+
data: i
|
|
2787
|
+
}, {
|
|
2788
|
+
id: V.SeekPosition,
|
|
2789
|
+
size: 5,
|
|
2790
|
+
data: e ? this.ebmlWriter.offsets.get(this.attachmentsElement) - this.segmentDataOffset : 0
|
|
2791
|
+
}]
|
|
2792
|
+
} : null,
|
|
2793
|
+
this.tagsElement ? {
|
|
2794
|
+
id: V.Seek,
|
|
2795
|
+
data: [{
|
|
2796
|
+
id: V.SeekID,
|
|
2797
|
+
data: a
|
|
2798
|
+
}, {
|
|
2799
|
+
id: V.SeekPosition,
|
|
2800
|
+
size: 5,
|
|
2801
|
+
data: e ? this.ebmlWriter.offsets.get(this.tagsElement) - this.segmentDataOffset : 0
|
|
2802
|
+
}]
|
|
2803
|
+
} : null
|
|
2804
|
+
]
|
|
2805
|
+
};
|
|
2806
|
+
this.seekHead = o;
|
|
2807
|
+
}
|
|
2808
|
+
createSegmentInfo() {
|
|
2809
|
+
let e = {
|
|
2810
|
+
id: V.Duration,
|
|
2811
|
+
data: new ot(0)
|
|
2812
|
+
};
|
|
2813
|
+
this.segmentDuration = e;
|
|
2814
|
+
let t = {
|
|
2815
|
+
id: V.Info,
|
|
2816
|
+
data: [
|
|
2817
|
+
{
|
|
2818
|
+
id: V.TimestampScale,
|
|
2819
|
+
data: 1e6
|
|
2820
|
+
},
|
|
2821
|
+
{
|
|
2822
|
+
id: V.MuxingApp,
|
|
2823
|
+
data: on
|
|
2824
|
+
},
|
|
2825
|
+
{
|
|
2826
|
+
id: V.WritingApp,
|
|
2827
|
+
data: on
|
|
2828
|
+
},
|
|
2829
|
+
this.format._options.appendOnly ? null : e
|
|
2830
|
+
]
|
|
2831
|
+
};
|
|
2832
|
+
this.segmentInfo = t;
|
|
2833
|
+
}
|
|
2834
|
+
createTracks() {
|
|
2835
|
+
let e = {
|
|
2836
|
+
id: V.Tracks,
|
|
2837
|
+
data: []
|
|
2838
|
+
};
|
|
2839
|
+
this.tracksElement = e;
|
|
2840
|
+
for (let n of this.trackDatas) {
|
|
2841
|
+
let r = ht[n.track.source._codec];
|
|
2842
|
+
t(r);
|
|
2843
|
+
let i = 0;
|
|
2844
|
+
if (n.type === "audio" && n.track.source._codec === "opus") {
|
|
2845
|
+
i = 8e7;
|
|
2846
|
+
let e = n.info.decoderConfig.description;
|
|
2847
|
+
if (e) {
|
|
2848
|
+
let t = tt(o(e));
|
|
2849
|
+
i = Math.round(1e9 * (t.preSkip / Me));
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
e.data.push({
|
|
2853
|
+
id: V.TrackEntry,
|
|
2854
|
+
data: [
|
|
2855
|
+
{
|
|
2856
|
+
id: V.TrackNumber,
|
|
2857
|
+
data: n.track.id
|
|
2858
|
+
},
|
|
2859
|
+
{
|
|
2860
|
+
id: V.TrackUID,
|
|
2861
|
+
data: n.track.id
|
|
2862
|
+
},
|
|
2863
|
+
{
|
|
2864
|
+
id: V.TrackType,
|
|
2865
|
+
data: ln[n.type]
|
|
2866
|
+
},
|
|
2867
|
+
n.track.metadata.disposition?.default === !1 ? {
|
|
2868
|
+
id: V.FlagDefault,
|
|
2869
|
+
data: 0
|
|
2870
|
+
} : null,
|
|
2871
|
+
n.track.metadata.disposition?.forced ? {
|
|
2872
|
+
id: V.FlagForced,
|
|
2873
|
+
data: 1
|
|
2874
|
+
} : null,
|
|
2875
|
+
n.track.metadata.disposition?.hearingImpaired ? {
|
|
2876
|
+
id: V.FlagHearingImpaired,
|
|
2877
|
+
data: 1
|
|
2878
|
+
} : null,
|
|
2879
|
+
n.track.metadata.disposition?.visuallyImpaired ? {
|
|
2880
|
+
id: V.FlagVisualImpaired,
|
|
2881
|
+
data: 1
|
|
2882
|
+
} : null,
|
|
2883
|
+
n.track.metadata.disposition?.original ? {
|
|
2884
|
+
id: V.FlagOriginal,
|
|
2885
|
+
data: 1
|
|
2886
|
+
} : null,
|
|
2887
|
+
n.track.metadata.disposition?.commentary ? {
|
|
2888
|
+
id: V.FlagCommentary,
|
|
2889
|
+
data: 1
|
|
2890
|
+
} : null,
|
|
2891
|
+
{
|
|
2892
|
+
id: V.FlagLacing,
|
|
2893
|
+
data: 0
|
|
2894
|
+
},
|
|
2895
|
+
{
|
|
2896
|
+
id: V.Language,
|
|
2897
|
+
data: n.track.metadata.languageCode ?? "und"
|
|
2898
|
+
},
|
|
2899
|
+
{
|
|
2900
|
+
id: V.CodecID,
|
|
2901
|
+
data: r
|
|
2902
|
+
},
|
|
2903
|
+
n.codecPrivate ? {
|
|
2904
|
+
id: V.CodecPrivate,
|
|
2905
|
+
data: o(n.codecPrivate)
|
|
2906
|
+
} : null,
|
|
2907
|
+
{
|
|
2908
|
+
id: V.CodecDelay,
|
|
2909
|
+
data: 0
|
|
2910
|
+
},
|
|
2911
|
+
{
|
|
2912
|
+
id: V.SeekPreRoll,
|
|
2913
|
+
data: i
|
|
2914
|
+
},
|
|
2915
|
+
n.track.metadata.name === void 0 ? null : {
|
|
2916
|
+
id: V.Name,
|
|
2917
|
+
data: new B(n.track.metadata.name)
|
|
2918
|
+
},
|
|
2919
|
+
n.type === "video" ? this.videoSpecificTrackInfo(n) : null,
|
|
2920
|
+
n.type === "audio" ? this.audioSpecificTrackInfo(n) : null,
|
|
2921
|
+
n.type === "subtitle" ? this.subtitleSpecificTrackInfo(n) : null
|
|
2922
|
+
]
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
videoSpecificTrackInfo(e) {
|
|
2927
|
+
let { frameRate: t, rotation: r } = e.track.metadata, i = [t ? {
|
|
2928
|
+
id: V.DefaultDuration,
|
|
2929
|
+
data: 1e9 / t
|
|
2930
|
+
} : null], a = r ? n(-r) : 0, o = !!e.info.aspectRatio && e.info.aspectRatio.num * e.info.height !== e.info.aspectRatio.den * e.info.width, s = e.info.decoderConfig.colorSpace, c = {
|
|
2931
|
+
id: V.Video,
|
|
2932
|
+
data: [
|
|
2933
|
+
{
|
|
2934
|
+
id: V.PixelWidth,
|
|
2935
|
+
data: e.info.width
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
id: V.PixelHeight,
|
|
2939
|
+
data: e.info.height
|
|
2940
|
+
},
|
|
2941
|
+
o ? {
|
|
2942
|
+
id: V.DisplayWidth,
|
|
2943
|
+
data: e.info.aspectRatio.num
|
|
2944
|
+
} : null,
|
|
2945
|
+
o ? {
|
|
2946
|
+
id: V.DisplayHeight,
|
|
2947
|
+
data: e.info.aspectRatio.den
|
|
2948
|
+
} : null,
|
|
2949
|
+
o ? {
|
|
2950
|
+
id: V.DisplayUnit,
|
|
2951
|
+
data: 3
|
|
2952
|
+
} : null,
|
|
2953
|
+
e.info.alphaMode ? {
|
|
2954
|
+
id: V.AlphaMode,
|
|
2955
|
+
data: 1
|
|
2956
|
+
} : null,
|
|
2957
|
+
f(s) ? {
|
|
2958
|
+
id: V.Colour,
|
|
2959
|
+
data: [
|
|
2960
|
+
{
|
|
2961
|
+
id: V.MatrixCoefficients,
|
|
2962
|
+
data: d[s.matrix]
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
id: V.TransferCharacteristics,
|
|
2966
|
+
data: u[s.transfer]
|
|
2967
|
+
},
|
|
2968
|
+
{
|
|
2969
|
+
id: V.Primaries,
|
|
2970
|
+
data: l[s.primaries]
|
|
2971
|
+
},
|
|
2972
|
+
{
|
|
2973
|
+
id: V.Range,
|
|
2974
|
+
data: s.fullRange ? 2 : 1
|
|
2975
|
+
}
|
|
2976
|
+
]
|
|
2977
|
+
} : null,
|
|
2978
|
+
a ? {
|
|
2979
|
+
id: V.Projection,
|
|
2980
|
+
data: [{
|
|
2981
|
+
id: V.ProjectionType,
|
|
2982
|
+
data: 0
|
|
2983
|
+
}, {
|
|
2984
|
+
id: V.ProjectionPoseRoll,
|
|
2985
|
+
data: new at((a + 180) % 360 - 180)
|
|
2986
|
+
}]
|
|
2987
|
+
} : null
|
|
2988
|
+
]
|
|
2989
|
+
};
|
|
2990
|
+
return i.push(c), i;
|
|
2991
|
+
}
|
|
2992
|
+
audioSpecificTrackInfo(e) {
|
|
2993
|
+
let t = N.includes(e.track.source._codec) ? Pe(e.track.source._codec) : null;
|
|
2994
|
+
return [{
|
|
2995
|
+
id: V.Audio,
|
|
2996
|
+
data: [
|
|
2997
|
+
{
|
|
2998
|
+
id: V.SamplingFrequency,
|
|
2999
|
+
data: new at(e.info.sampleRate)
|
|
3000
|
+
},
|
|
3001
|
+
{
|
|
3002
|
+
id: V.Channels,
|
|
3003
|
+
data: e.info.numberOfChannels
|
|
3004
|
+
},
|
|
3005
|
+
t ? {
|
|
3006
|
+
id: V.BitDepth,
|
|
3007
|
+
data: 8 * t.sampleSize
|
|
3008
|
+
} : null
|
|
3009
|
+
]
|
|
3010
|
+
}];
|
|
3011
|
+
}
|
|
3012
|
+
subtitleSpecificTrackInfo(e) {
|
|
3013
|
+
return [];
|
|
3014
|
+
}
|
|
3015
|
+
maybeCreateTags() {
|
|
3016
|
+
let e = [], t = (t, n) => {
|
|
3017
|
+
e.push({
|
|
3018
|
+
id: V.SimpleTag,
|
|
3019
|
+
data: [{
|
|
3020
|
+
id: V.TagName,
|
|
3021
|
+
data: new B(t)
|
|
3022
|
+
}, typeof n == "string" ? {
|
|
3023
|
+
id: V.TagString,
|
|
3024
|
+
data: new B(n)
|
|
3025
|
+
} : {
|
|
3026
|
+
id: V.TagBinary,
|
|
3027
|
+
data: n
|
|
3028
|
+
}]
|
|
3029
|
+
});
|
|
3030
|
+
}, n = this.output._metadataTags, r = /* @__PURE__ */ new Set();
|
|
3031
|
+
for (let { key: e, value: i } of se(n)) switch (e) {
|
|
3032
|
+
case "title":
|
|
3033
|
+
t("TITLE", i), r.add("TITLE");
|
|
3034
|
+
break;
|
|
3035
|
+
case "description":
|
|
3036
|
+
t("DESCRIPTION", i), r.add("DESCRIPTION");
|
|
3037
|
+
break;
|
|
3038
|
+
case "artist":
|
|
3039
|
+
t("ARTIST", i), r.add("ARTIST");
|
|
3040
|
+
break;
|
|
3041
|
+
case "album":
|
|
3042
|
+
t("ALBUM", i), r.add("ALBUM");
|
|
3043
|
+
break;
|
|
3044
|
+
case "albumArtist":
|
|
3045
|
+
t("ALBUM_ARTIST", i), r.add("ALBUM_ARTIST");
|
|
3046
|
+
break;
|
|
3047
|
+
case "genre":
|
|
3048
|
+
t("GENRE", i), r.add("GENRE");
|
|
3049
|
+
break;
|
|
3050
|
+
case "comment":
|
|
3051
|
+
t("COMMENT", i), r.add("COMMENT");
|
|
3052
|
+
break;
|
|
3053
|
+
case "lyrics":
|
|
3054
|
+
t("LYRICS", i), r.add("LYRICS");
|
|
3055
|
+
break;
|
|
3056
|
+
case "date":
|
|
3057
|
+
t("DATE", i.toISOString().slice(0, 10)), r.add("DATE");
|
|
3058
|
+
break;
|
|
3059
|
+
case "trackNumber":
|
|
3060
|
+
t("PART_NUMBER", n.tracksTotal === void 0 ? i.toString() : `${i}/${n.tracksTotal}`), r.add("PART_NUMBER");
|
|
3061
|
+
break;
|
|
3062
|
+
case "discNumber":
|
|
3063
|
+
t("DISC", n.discsTotal === void 0 ? i.toString() : `${i}/${n.discsTotal}`), r.add("DISC");
|
|
3064
|
+
break;
|
|
3065
|
+
case "tracksTotal":
|
|
3066
|
+
case "discsTotal": break;
|
|
3067
|
+
case "images":
|
|
3068
|
+
case "raw": break;
|
|
3069
|
+
default: _(e);
|
|
3070
|
+
}
|
|
3071
|
+
if (n.raw) for (let e in n.raw) {
|
|
3072
|
+
let i = n.raw[e];
|
|
3073
|
+
i == null || r.has(e) || (typeof i == "string" || i instanceof Uint8Array) && t(e, i);
|
|
3074
|
+
}
|
|
3075
|
+
e.length !== 0 && (this.tagsElement = {
|
|
3076
|
+
id: V.Tags,
|
|
3077
|
+
data: [{
|
|
3078
|
+
id: V.Tag,
|
|
3079
|
+
data: [{
|
|
3080
|
+
id: V.Targets,
|
|
3081
|
+
data: [{
|
|
3082
|
+
id: V.TargetTypeValue,
|
|
3083
|
+
data: 50
|
|
3084
|
+
}, {
|
|
3085
|
+
id: V.TargetType,
|
|
3086
|
+
data: "MOVIE"
|
|
3087
|
+
}]
|
|
3088
|
+
}, ...e]
|
|
3089
|
+
}]
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
maybeCreateAttachments() {
|
|
3093
|
+
let e = this.output._metadataTags, t = [], n = /* @__PURE__ */ new Set(), r = e.images ?? [];
|
|
3094
|
+
for (let e of r) {
|
|
3095
|
+
let r = e.name;
|
|
3096
|
+
r === void 0 && (r = (e.kind === "coverFront" ? "cover" : e.kind === "coverBack" ? "back" : "image") + (ce(e.mimeType) ?? ""));
|
|
3097
|
+
let i;
|
|
3098
|
+
for (;;) {
|
|
3099
|
+
i = 0n;
|
|
3100
|
+
for (let e = 0; e < 8; e++) i <<= 8n, i |= BigInt(Math.floor(Math.random() * 256));
|
|
3101
|
+
if (i !== 0n && !n.has(i)) break;
|
|
3102
|
+
}
|
|
3103
|
+
n.add(i), t.push({
|
|
3104
|
+
id: V.AttachedFile,
|
|
3105
|
+
data: [
|
|
3106
|
+
e.description === void 0 ? null : {
|
|
3107
|
+
id: V.FileDescription,
|
|
3108
|
+
data: new B(e.description)
|
|
3109
|
+
},
|
|
3110
|
+
{
|
|
3111
|
+
id: V.FileName,
|
|
3112
|
+
data: new B(r)
|
|
3113
|
+
},
|
|
3114
|
+
{
|
|
3115
|
+
id: V.FileMediaType,
|
|
3116
|
+
data: e.mimeType
|
|
3117
|
+
},
|
|
3118
|
+
{
|
|
3119
|
+
id: V.FileData,
|
|
3120
|
+
data: e.data
|
|
3121
|
+
},
|
|
3122
|
+
{
|
|
3123
|
+
id: V.FileUID,
|
|
3124
|
+
data: i
|
|
3125
|
+
}
|
|
3126
|
+
]
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
for (let [n, i] of Object.entries(e.raw ?? {})) i instanceof _e && /^\d+$/.test(n) && (r.find((e) => e.mimeType === i.mimeType && le(e.data, i.data)) || t.push({
|
|
3130
|
+
id: V.AttachedFile,
|
|
3131
|
+
data: [
|
|
3132
|
+
i.description === void 0 ? null : {
|
|
3133
|
+
id: V.FileDescription,
|
|
3134
|
+
data: new B(i.description)
|
|
3135
|
+
},
|
|
3136
|
+
{
|
|
3137
|
+
id: V.FileName,
|
|
3138
|
+
data: new B(i.name ?? "")
|
|
3139
|
+
},
|
|
3140
|
+
{
|
|
3141
|
+
id: V.FileMediaType,
|
|
3142
|
+
data: i.mimeType ?? ""
|
|
3143
|
+
},
|
|
3144
|
+
{
|
|
3145
|
+
id: V.FileData,
|
|
3146
|
+
data: i.data
|
|
3147
|
+
},
|
|
3148
|
+
{
|
|
3149
|
+
id: V.FileUID,
|
|
3150
|
+
data: BigInt(n)
|
|
3151
|
+
}
|
|
3152
|
+
]
|
|
3153
|
+
}));
|
|
3154
|
+
t.length !== 0 && (this.attachmentsElement = {
|
|
3155
|
+
id: V.Attachments,
|
|
3156
|
+
data: t
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
createSegment() {
|
|
3160
|
+
this.createTracks(), this.maybeCreateTags(), this.maybeCreateAttachments(), this.maybeCreateSeekHead(!1);
|
|
3161
|
+
let e = {
|
|
3162
|
+
id: V.Segment,
|
|
3163
|
+
size: this.format._options.appendOnly ? -1 : sn,
|
|
3164
|
+
data: [
|
|
3165
|
+
this.seekHead,
|
|
3166
|
+
this.segmentInfo,
|
|
3167
|
+
this.tracksElement,
|
|
3168
|
+
this.attachmentsElement,
|
|
3169
|
+
this.tagsElement
|
|
3170
|
+
]
|
|
3171
|
+
};
|
|
3172
|
+
if (this.segment = e, this.format._options.onSegmentHeader && this.writer.startTrackingWrites(), this.ebmlWriter.writeEBML(e), this.format._options.onSegmentHeader) {
|
|
3173
|
+
let { data: e, start: t } = this.writer.stopTrackingWrites();
|
|
3174
|
+
this.format._options.onSegmentHeader(e, t);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
createCues() {
|
|
3178
|
+
this.cues = {
|
|
3179
|
+
id: V.Cues,
|
|
3180
|
+
data: []
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3183
|
+
get segmentDataOffset() {
|
|
3184
|
+
return t(this.segment), this.ebmlWriter.dataOffsets.get(this.segment);
|
|
3185
|
+
}
|
|
3186
|
+
allTracksAreKnown() {
|
|
3187
|
+
for (let e of this.output.tracks) if (!e.source._closed && !this.trackDatas.some((t) => t.track === e)) return !1;
|
|
3188
|
+
return !0;
|
|
3189
|
+
}
|
|
3190
|
+
async getMimeType() {
|
|
3191
|
+
await this.allTracksKnown.promise;
|
|
3192
|
+
let e = this.trackDatas.map((e) => e.type === "video" || e.type === "audio" ? e.info.decoderConfig.codec : { webvtt: "wvtt" }[e.track.source._codec]);
|
|
3193
|
+
return gt({
|
|
3194
|
+
isWebM: this.format instanceof Tn,
|
|
3195
|
+
hasVideo: this.trackDatas.some((e) => e.type === "video"),
|
|
3196
|
+
hasAudio: this.trackDatas.some((e) => e.type === "audio"),
|
|
3197
|
+
codecStrings: e
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
getVideoTrackData(e, n, r) {
|
|
3201
|
+
let i = this.trackDatas.find((t) => t.track === e);
|
|
3202
|
+
if (i) return i;
|
|
3203
|
+
Ve(r, e.source._codec), t(r), t(r.decoderConfig), t(r.decoderConfig.codedWidth !== void 0), t(r.decoderConfig.codedHeight !== void 0);
|
|
3204
|
+
let a = r.decoderConfig.displayAspectWidth, o = r.decoderConfig.displayAspectHeight, s = a === void 0 || o === void 0 ? null : fe({
|
|
3205
|
+
num: a,
|
|
3206
|
+
den: o
|
|
3207
|
+
}), l = {
|
|
3208
|
+
track: e,
|
|
3209
|
+
type: "video",
|
|
3210
|
+
info: {
|
|
3211
|
+
width: r.decoderConfig.codedWidth,
|
|
3212
|
+
height: r.decoderConfig.codedHeight,
|
|
3213
|
+
aspectRatio: s,
|
|
3214
|
+
decoderConfig: r.decoderConfig,
|
|
3215
|
+
alphaMode: n ? !!n.sideData.alpha : null
|
|
3216
|
+
},
|
|
3217
|
+
chunkQueue: [],
|
|
3218
|
+
lastWrittenMsTimestamp: null,
|
|
3219
|
+
codecPrivate: r.decoderConfig.description ?? null,
|
|
3220
|
+
closed: !1
|
|
3221
|
+
};
|
|
3222
|
+
return e.source._codec === "vp9" ? l.codecPrivate = new Uint8Array(Ae(l.info.decoderConfig.codec)) : e.source._codec === "av1" ? l.codecPrivate = new Uint8Array(je(l.info.decoderConfig.codec)) : e.source._codec === "prores" && (l.codecPrivate = c.encode(r.decoderConfig.codec)), this.trackDatas.push(l), this.trackDatas.sort((e, t) => e.track.id - t.track.id), this.allTracksAreKnown() && this.allTracksKnown.resolve(), l;
|
|
3223
|
+
}
|
|
3224
|
+
getAudioTrackData(e, n, r) {
|
|
3225
|
+
let i = this.trackDatas.find((t) => t.track === e);
|
|
3226
|
+
if (i) return i;
|
|
3227
|
+
Ue(r, e.source._codec), t(r), t(r.decoderConfig);
|
|
3228
|
+
let a = { ...r.decoderConfig }, o = !1;
|
|
3229
|
+
if (e.source._codec === "aac" && !a.description) {
|
|
3230
|
+
if (!n) throw Error("No AAC description provided; you must therefore provide a priming packet.");
|
|
3231
|
+
let e = _t(Wt.tempFromBytes(n.data));
|
|
3232
|
+
if (!e) throw Error("Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.");
|
|
3233
|
+
let t = be[e.samplingFrequencyIndex], r = xe[e.channelConfiguration];
|
|
3234
|
+
if (t === void 0 || r === void 0) throw Error("Invalid ADTS frame header.");
|
|
3235
|
+
a.description = Se({
|
|
3236
|
+
objectType: e.objectType,
|
|
3237
|
+
sampleRate: t,
|
|
3238
|
+
numberOfChannels: r
|
|
3239
|
+
}), o = !0;
|
|
3240
|
+
}
|
|
3241
|
+
let s = {
|
|
3242
|
+
track: e,
|
|
3243
|
+
type: "audio",
|
|
3244
|
+
info: {
|
|
3245
|
+
numberOfChannels: r.decoderConfig.numberOfChannels,
|
|
3246
|
+
sampleRate: r.decoderConfig.sampleRate,
|
|
3247
|
+
decoderConfig: a,
|
|
3248
|
+
requiresAdtsStripping: o
|
|
3249
|
+
},
|
|
3250
|
+
chunkQueue: [],
|
|
3251
|
+
lastWrittenMsTimestamp: null,
|
|
3252
|
+
codecPrivate: a.description ?? null,
|
|
3253
|
+
closed: !1
|
|
3254
|
+
};
|
|
3255
|
+
return this.trackDatas.push(s), this.trackDatas.sort((e, t) => e.track.id - t.track.id), this.allTracksAreKnown() && this.allTracksKnown.resolve(), s;
|
|
3256
|
+
}
|
|
3257
|
+
getSubtitleTrackData(e, n) {
|
|
3258
|
+
let r = this.trackDatas.find((t) => t.track === e);
|
|
3259
|
+
if (r) return r;
|
|
3260
|
+
We(n), t(n), t(n.config);
|
|
3261
|
+
let i = {
|
|
3262
|
+
track: e,
|
|
3263
|
+
type: "subtitle",
|
|
3264
|
+
info: { config: n.config },
|
|
3265
|
+
chunkQueue: [],
|
|
3266
|
+
lastWrittenMsTimestamp: null,
|
|
3267
|
+
codecPrivate: c.encode(n.config.description),
|
|
3268
|
+
closed: !1
|
|
3269
|
+
};
|
|
3270
|
+
return this.trackDatas.push(i), this.trackDatas.sort((e, t) => e.track.id - t.track.id), this.allTracksAreKnown() && this.allTracksKnown.resolve(), i;
|
|
3271
|
+
}
|
|
3272
|
+
async addEncodedVideoPacket(e, t, n) {
|
|
3273
|
+
let r = await this.mutex.acquire();
|
|
3274
|
+
try {
|
|
3275
|
+
let r = this.getVideoTrackData(e, t, n);
|
|
3276
|
+
r.info.alphaMode ??= !!t.sideData.alpha;
|
|
3277
|
+
let i = t.data;
|
|
3278
|
+
if (e.source._codec === "prores") {
|
|
3279
|
+
if (i.byteLength < 8) throw Error("ProRes packet too small, expected at least 8 bytes.");
|
|
3280
|
+
i = i.subarray(8);
|
|
3281
|
+
}
|
|
3282
|
+
let a = t.type === "key";
|
|
3283
|
+
this.validateTimestamp(r.track, t.timestamp, a);
|
|
3284
|
+
let o = t.timestamp, s = t.duration;
|
|
3285
|
+
e.metadata.frameRate !== void 0 && (o = x(o, e.metadata.frameRate), s = x(s, e.metadata.frameRate));
|
|
3286
|
+
let c = r.info.alphaMode ? t.sideData.alpha ?? null : null, l = this.createInternalChunk(i, o, s, t.type, c);
|
|
3287
|
+
e.source._codec === "vp9" && this.fixVP9ColorSpace(r, l), r.chunkQueue.push(l), await this.interleaveChunks();
|
|
3288
|
+
} finally {
|
|
3289
|
+
r();
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
async addEncodedAudioPacket(e, t, n) {
|
|
3293
|
+
let r = await this.mutex.acquire();
|
|
3294
|
+
try {
|
|
3295
|
+
let r = this.getAudioTrackData(e, t, n), i = t.data;
|
|
3296
|
+
if (r.info.requiresAdtsStripping) {
|
|
3297
|
+
let e = _t(Wt.tempFromBytes(i));
|
|
3298
|
+
if (!e) throw Error("Expected ADTS frame, didn't get one.");
|
|
3299
|
+
let t = e.crcCheck === null ? 7 : 9;
|
|
3300
|
+
i = i.subarray(t);
|
|
3301
|
+
}
|
|
3302
|
+
let a = t.type === "key";
|
|
3303
|
+
this.validateTimestamp(r.track, t.timestamp, a);
|
|
3304
|
+
let o = this.createInternalChunk(i, t.timestamp, t.duration, t.type);
|
|
3305
|
+
r.chunkQueue.push(o), await this.interleaveChunks();
|
|
3306
|
+
} finally {
|
|
3307
|
+
r();
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
async addSubtitleCue(e, t, n) {
|
|
3311
|
+
let r = await this.mutex.acquire();
|
|
3312
|
+
try {
|
|
3313
|
+
let r = this.getSubtitleTrackData(e, n);
|
|
3314
|
+
this.validateTimestamp(r.track, t.timestamp, !0);
|
|
3315
|
+
let i = t.text, a = Math.round(t.timestamp * 1e3);
|
|
3316
|
+
Jt.lastIndex = 0, i = i.replace(Jt, (e) => `<${Zt(Xt(e.slice(1, -1)) - a)}>`);
|
|
3317
|
+
let o = c.encode(i), s = `${t.settings ?? ""}\n${t.identifier ?? ""}\n${t.notes ?? ""}`, l = this.createInternalChunk(o, t.timestamp, t.duration, "key", s.trim() ? c.encode(s) : null);
|
|
3318
|
+
r.chunkQueue.push(l), await this.interleaveChunks();
|
|
3319
|
+
} finally {
|
|
3320
|
+
r();
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
async interleaveChunks(e = !1) {
|
|
3324
|
+
if (!(!e && !this.allTracksAreKnown())) {
|
|
3325
|
+
outer: for (;;) {
|
|
3326
|
+
let t = null, n = Infinity;
|
|
3327
|
+
for (let r of this.trackDatas) {
|
|
3328
|
+
if (!e && r.chunkQueue.length === 0 && !r.closed) break outer;
|
|
3329
|
+
r.chunkQueue.length > 0 && r.chunkQueue[0].timestamp < n && (t = r, n = r.chunkQueue[0].timestamp);
|
|
3330
|
+
}
|
|
3331
|
+
if (!t) break;
|
|
3332
|
+
let r = t.chunkQueue.shift();
|
|
3333
|
+
this.writeBlock(t, r);
|
|
3334
|
+
}
|
|
3335
|
+
e || await this.writer.flush();
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
fixVP9ColorSpace(e, t) {
|
|
3339
|
+
if (t.type !== "key" || !e.info.decoderConfig.colorSpace || !e.info.decoderConfig.colorSpace.matrix) return;
|
|
3340
|
+
let n = new j(t.data);
|
|
3341
|
+
n.skipBits(2);
|
|
3342
|
+
let r = n.readBits(1), i = (n.readBits(1) << 1) + r;
|
|
3343
|
+
if (i === 3 && n.skipBits(1), n.readBits(1) || n.readBits(1) !== 0 || (n.skipBits(2), n.readBits(24) !== 4817730)) return;
|
|
3344
|
+
i >= 2 && n.skipBits(1);
|
|
3345
|
+
let o = {
|
|
3346
|
+
rgb: 7,
|
|
3347
|
+
bt709: 2,
|
|
3348
|
+
bt470bg: 1,
|
|
3349
|
+
smpte170m: 3
|
|
3350
|
+
}[e.info.decoderConfig.colorSpace.matrix];
|
|
3351
|
+
a(t.data, n.pos, n.pos + 3, o);
|
|
3352
|
+
}
|
|
3353
|
+
createInternalChunk(e, t, n, r, i = null) {
|
|
3354
|
+
return {
|
|
3355
|
+
data: e,
|
|
3356
|
+
type: r,
|
|
3357
|
+
timestamp: t,
|
|
3358
|
+
duration: n,
|
|
3359
|
+
additions: i
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
writeBlock(e, n) {
|
|
3363
|
+
this.segment || this.createSegment();
|
|
3364
|
+
let r = Math.round(1e3 * n.timestamp), i = this.trackDatas.every((t) => {
|
|
3365
|
+
if (e === t) return n.type === "key";
|
|
3366
|
+
let r = t.chunkQueue[0];
|
|
3367
|
+
return r ? r.type === "key" : t.closed;
|
|
3368
|
+
}), a = !1;
|
|
3369
|
+
if (!this.currentCluster) a = !0;
|
|
3370
|
+
else {
|
|
3371
|
+
t(this.currentClusterStartMsTimestamp !== null), t(this.currentClusterMaxMsTimestamp !== null);
|
|
3372
|
+
let e = r - this.currentClusterStartMsTimestamp;
|
|
3373
|
+
a = i && r > this.currentClusterMaxMsTimestamp && e >= 1e3 * (this.format._options.minimumClusterDuration ?? 1) || e > an;
|
|
3374
|
+
}
|
|
3375
|
+
a && this.createNewCluster(r);
|
|
3376
|
+
let o = r - this.currentClusterStartMsTimestamp;
|
|
3377
|
+
if (o < rn) return;
|
|
3378
|
+
let s = /* @__PURE__ */ new Uint8Array(4), c = new DataView(s.buffer);
|
|
3379
|
+
c.setUint8(0, 128 | e.track.id), c.setInt16(1, o, !1);
|
|
3380
|
+
let l = Math.round(1e3 * n.duration);
|
|
3381
|
+
if (n.additions || e.type === "subtitle") {
|
|
3382
|
+
let t = {
|
|
3383
|
+
id: V.BlockGroup,
|
|
3384
|
+
data: [
|
|
3385
|
+
{
|
|
3386
|
+
id: V.Block,
|
|
3387
|
+
data: [s, n.data]
|
|
3388
|
+
},
|
|
3389
|
+
n.type === "delta" ? {
|
|
3390
|
+
id: V.ReferenceBlock,
|
|
3391
|
+
data: new st(e.lastWrittenMsTimestamp - r)
|
|
3392
|
+
} : null,
|
|
3393
|
+
n.additions ? {
|
|
3394
|
+
id: V.BlockAdditions,
|
|
3395
|
+
data: [{
|
|
3396
|
+
id: V.BlockMore,
|
|
3397
|
+
data: [{
|
|
3398
|
+
id: V.BlockAddID,
|
|
3399
|
+
data: 1
|
|
3400
|
+
}, {
|
|
3401
|
+
id: V.BlockAdditional,
|
|
3402
|
+
data: n.additions
|
|
3403
|
+
}]
|
|
3404
|
+
}]
|
|
3405
|
+
} : null,
|
|
3406
|
+
l > 0 ? {
|
|
3407
|
+
id: V.BlockDuration,
|
|
3408
|
+
data: l
|
|
3409
|
+
} : null
|
|
3410
|
+
]
|
|
3411
|
+
};
|
|
3412
|
+
this.ebmlWriter.writeEBML(t);
|
|
3413
|
+
} else {
|
|
3414
|
+
c.setUint8(3, Number(n.type === "key") << 7);
|
|
3415
|
+
let e = {
|
|
3416
|
+
id: V.SimpleBlock,
|
|
3417
|
+
data: [s, n.data]
|
|
3418
|
+
};
|
|
3419
|
+
this.ebmlWriter.writeEBML(e);
|
|
3420
|
+
}
|
|
3421
|
+
this.startTimestamp = Math.min(this.startTimestamp, r), this.endTimestamp = Math.max(this.endTimestamp, r + l), e.lastWrittenMsTimestamp = r, this.trackDatasInCurrentCluster.has(e) || this.trackDatasInCurrentCluster.set(e, { firstMsTimestamp: r }), this.currentClusterMaxMsTimestamp = Math.max(this.currentClusterMaxMsTimestamp, r);
|
|
3422
|
+
}
|
|
3423
|
+
createNewCluster(e) {
|
|
3424
|
+
this.currentCluster && this.finalizeCurrentCluster(), this.format._options.onCluster && this.writer.startTrackingWrites(), this.currentCluster = {
|
|
3425
|
+
id: V.Cluster,
|
|
3426
|
+
size: this.format._options.appendOnly ? -1 : cn,
|
|
3427
|
+
data: [{
|
|
3428
|
+
id: V.Timestamp,
|
|
3429
|
+
data: e
|
|
3430
|
+
}]
|
|
3431
|
+
}, this.ebmlWriter.writeEBML(this.currentCluster), this.currentClusterStartMsTimestamp = e, this.currentClusterMaxMsTimestamp = e, this.trackDatasInCurrentCluster.clear();
|
|
3432
|
+
}
|
|
3433
|
+
finalizeCurrentCluster() {
|
|
3434
|
+
if (t(this.currentCluster), !this.format._options.appendOnly) {
|
|
3435
|
+
let e = this.writer.getPos() - this.ebmlWriter.dataOffsets.get(this.currentCluster), t = this.writer.getPos();
|
|
3436
|
+
this.writer.seek(this.ebmlWriter.offsets.get(this.currentCluster) + 4), this.ebmlWriter.writeVarInt(e, cn), this.writer.seek(t);
|
|
3437
|
+
}
|
|
3438
|
+
if (this.format._options.onCluster) {
|
|
3439
|
+
t(this.currentClusterStartMsTimestamp !== null);
|
|
3440
|
+
let { data: e, start: n } = this.writer.stopTrackingWrites();
|
|
3441
|
+
this.format._options.onCluster(e, n, this.currentClusterStartMsTimestamp / 1e3);
|
|
3442
|
+
}
|
|
3443
|
+
let e = this.ebmlWriter.offsets.get(this.currentCluster) - this.segmentDataOffset, n = /* @__PURE__ */ new Map();
|
|
3444
|
+
for (let [e, { firstMsTimestamp: t }] of this.trackDatasInCurrentCluster) n.has(t) || n.set(t, []), n.get(t).push(e);
|
|
3445
|
+
let r = [...n.entries()].sort((e, t) => e[0] - t[0]);
|
|
3446
|
+
for (let [n, i] of r) t(this.cues), this.cues.data.push({
|
|
3447
|
+
id: V.CuePoint,
|
|
3448
|
+
data: [{
|
|
3449
|
+
id: V.CueTime,
|
|
3450
|
+
data: n
|
|
3451
|
+
}, ...i.map((t) => ({
|
|
3452
|
+
id: V.CueTrackPositions,
|
|
3453
|
+
data: [{
|
|
3454
|
+
id: V.CueTrack,
|
|
3455
|
+
data: t.track.id
|
|
3456
|
+
}, {
|
|
3457
|
+
id: V.CueClusterPosition,
|
|
3458
|
+
data: e
|
|
3459
|
+
}]
|
|
3460
|
+
}))]
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
async onTrackClose(e) {
|
|
3464
|
+
let t = await this.mutex.acquire(), n = this.trackDatas.find((t) => t.track === e);
|
|
3465
|
+
n && (n.closed = !0), this.allTracksAreKnown() && this.allTracksKnown.resolve(), await this.interleaveChunks(), t();
|
|
3466
|
+
}
|
|
3467
|
+
async finalize() {
|
|
3468
|
+
let e = await this.mutex.acquire();
|
|
3469
|
+
this.allTracksKnown.resolve();
|
|
3470
|
+
for (let e of this.trackDatas) e.closed = !0;
|
|
3471
|
+
if (this.segment || this.createSegment(), await this.interleaveChunks(!0), this.currentCluster && this.finalizeCurrentCluster(), t(this.cues), this.ebmlWriter.writeEBML(this.cues), !this.format._options.appendOnly) {
|
|
3472
|
+
let e = this.writer.getPos() - this.segmentDataOffset;
|
|
3473
|
+
this.writer.seek(this.ebmlWriter.offsets.get(this.segment) + 4), this.ebmlWriter.writeVarInt(e, sn);
|
|
3474
|
+
let n = this.startTimestamp === Infinity ? 0 : this.endTimestamp - this.startTimestamp;
|
|
3475
|
+
this.segmentDuration.data = new ot(n), this.writer.seek(this.ebmlWriter.offsets.get(this.segmentDuration)), this.ebmlWriter.writeEBML(this.segmentDuration), t(this.seekHead), this.writer.seek(this.ebmlWriter.offsets.get(this.seekHead)), this.maybeCreateSeekHead(!0), this.ebmlWriter.writeEBML(this.seekHead);
|
|
3476
|
+
}
|
|
3477
|
+
e();
|
|
3478
|
+
}
|
|
3479
|
+
}, dn = function(e, t, n) {
|
|
3480
|
+
if (t != null) {
|
|
3481
|
+
if (typeof t != "object" && typeof t != "function") throw TypeError("Object expected.");
|
|
3482
|
+
var r, i;
|
|
3483
|
+
if (n) {
|
|
3484
|
+
if (!Symbol.asyncDispose) throw TypeError("Symbol.asyncDispose is not defined.");
|
|
3485
|
+
r = t[Symbol.asyncDispose];
|
|
3486
|
+
}
|
|
3487
|
+
if (r === void 0) {
|
|
3488
|
+
if (!Symbol.dispose) throw TypeError("Symbol.dispose is not defined.");
|
|
3489
|
+
r = t[Symbol.dispose], n && (i = r);
|
|
3490
|
+
}
|
|
3491
|
+
if (typeof r != "function") throw TypeError("Object not disposable.");
|
|
3492
|
+
i && (r = function() {
|
|
3493
|
+
try {
|
|
3494
|
+
i.call(this);
|
|
3495
|
+
} catch (e) {
|
|
3496
|
+
return Promise.reject(e);
|
|
3497
|
+
}
|
|
3498
|
+
}), e.stack.push({
|
|
3499
|
+
value: t,
|
|
3500
|
+
dispose: r,
|
|
3501
|
+
async: n
|
|
3502
|
+
});
|
|
3503
|
+
} else n && e.stack.push({ async: !0 });
|
|
3504
|
+
return t;
|
|
3505
|
+
}, fn = (function(e) {
|
|
3506
|
+
return function(t) {
|
|
3507
|
+
function n(n) {
|
|
3508
|
+
t.error = t.hasError ? new e(n, t.error, "An error was suppressed during disposal.") : n, t.hasError = !0;
|
|
3509
|
+
}
|
|
3510
|
+
var r, i = 0;
|
|
3511
|
+
function a() {
|
|
3512
|
+
for (; r = t.stack.pop();) try {
|
|
3513
|
+
if (!r.async && i === 1) return i = 0, t.stack.push(r), Promise.resolve().then(a);
|
|
3514
|
+
if (r.dispose) {
|
|
3515
|
+
var e = r.dispose.call(r.value);
|
|
3516
|
+
if (r.async) return i |= 2, Promise.resolve(e).then(a, function(e) {
|
|
3517
|
+
return n(e), a();
|
|
3518
|
+
});
|
|
3519
|
+
} else i |= 1;
|
|
3520
|
+
} catch (e) {
|
|
3521
|
+
n(e);
|
|
3522
|
+
}
|
|
3523
|
+
if (i === 1) return t.hasError ? Promise.reject(t.error) : Promise.resolve();
|
|
3524
|
+
if (t.hasError) throw t.error;
|
|
3525
|
+
}
|
|
3526
|
+
return a();
|
|
3527
|
+
};
|
|
3528
|
+
})(typeof SuppressedError == "function" ? SuppressedError : function(e, t, n) {
|
|
3529
|
+
var r = Error(n);
|
|
3530
|
+
return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
|
|
3531
|
+
}), pn = class {
|
|
3532
|
+
constructor() {
|
|
3533
|
+
this._connectedTrack = null, this._closingPromise = null, this._closed = !1;
|
|
3534
|
+
}
|
|
3535
|
+
_ensureValidAdd() {
|
|
3536
|
+
if (!this._connectedTrack) throw Error("Source is not connected to an output track.");
|
|
3537
|
+
if (this._connectedTrack.output.state === "canceled") throw Error("Output has been canceled.");
|
|
3538
|
+
if (this._connectedTrack.output.state === "finalizing" || this._connectedTrack.output.state === "finalized") throw Error("Output has been finalized.");
|
|
3539
|
+
if (this._connectedTrack.output.state === "pending") throw Error("Output has not started.");
|
|
3540
|
+
if (this._closed) throw Error("Source is closed.");
|
|
3541
|
+
}
|
|
3542
|
+
async _start() {}
|
|
3543
|
+
async _flushAndClose(e) {}
|
|
3544
|
+
close() {
|
|
3545
|
+
if (this._closingPromise) return;
|
|
3546
|
+
let e = this._connectedTrack;
|
|
3547
|
+
if (!e) throw Error("Cannot call close without connecting the source to an output track.");
|
|
3548
|
+
if (e.output.state === "pending") throw Error("Cannot call close before output has been started.");
|
|
3549
|
+
this._closingPromise = (async () => {
|
|
3550
|
+
await this._flushAndClose(!1), this._closed = !0, e.output.state !== "finalizing" && e.output.state !== "finalized" && e.output._muxer.onTrackClose(e);
|
|
3551
|
+
})();
|
|
3552
|
+
}
|
|
3553
|
+
async _flushOrWaitForOngoingClose(e) {
|
|
3554
|
+
return this._closingPromise ??= (async () => {
|
|
3555
|
+
await this._flushAndClose(e), this._closed = !0;
|
|
3556
|
+
})();
|
|
3557
|
+
}
|
|
3558
|
+
}, mn = class extends pn {
|
|
3559
|
+
constructor(e) {
|
|
3560
|
+
if (super(), this._connectedTrack = null, !M.includes(e)) throw TypeError(`Invalid video codec '${e}'. Must be one of: ${M.join(", ")}.`);
|
|
3561
|
+
this._codec = e;
|
|
3562
|
+
}
|
|
3563
|
+
}, hn = (e, t) => {
|
|
3564
|
+
if (e.metadata.hasOnlyKeyPackets && t.type !== "key") throw Error("Cannot add non-key packets to a hasOnlyKeyPackets video track.");
|
|
3565
|
+
}, gn = class {
|
|
3566
|
+
setError(e) {
|
|
3567
|
+
this.errorSet ||= (this.error = e, !0);
|
|
3568
|
+
}
|
|
3569
|
+
constructor(e, t) {
|
|
3570
|
+
this.source = e, this.encodingConfig = t, this.ensureEncoderPromise = null, this.encoderInitialized = !1, this.encoder = null, this.muxer = null, this.lastMultipleOfKeyFrameInterval = -1, this.emittedEncoderPackets = 0, this.codedWidth = null, this.codedHeight = null, this.outputWidth = null, this.outputHeight = null, this.frameRateLastSample = null, this.frameRateLastTimestamp = null, this.frameRateLastEndTimestamp = null, this.preciseTimings = [], this.customEncoder = null, this.customEncoderCallSerializer = new re(), this.customEncoderQueueSize = 0, this.defaultEncodeOptions = {}, this.alphaEncoder = null, this.splitter = null, this.splitterCreationFailed = !1, this.alphaFrameQueue = [], this.error = null, this.errorSet = !1, this.lastMuxerPromise = Promise.resolve(), this.closed = !1;
|
|
3571
|
+
}
|
|
3572
|
+
async add(e, n, r) {
|
|
3573
|
+
let i = e;
|
|
3574
|
+
try {
|
|
3575
|
+
this.checkForEncoderError(), this.source._ensureValidAdd();
|
|
3576
|
+
let a = this.encodingConfig, o = a.sizeChangeBehavior ?? "deny", s = !1;
|
|
3577
|
+
if (this.codedWidth !== null && this.codedHeight !== null) {
|
|
3578
|
+
if ((e.codedWidth !== this.codedWidth || e.codedHeight !== this.codedHeight) && (s = !0, o === "deny")) throw Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'deny' in the encoding options.`);
|
|
3579
|
+
} else this.codedWidth = e.codedWidth, this.codedHeight = e.codedHeight;
|
|
3580
|
+
if (a.transform?.width !== void 0 || a.transform?.height !== void 0 || a.transform?.rotate !== void 0 || a.transform?.crop !== void 0 || a.transform?.force === !0 || s && o !== "passThrough") {
|
|
3581
|
+
let r = a.transform?.width, i = a.transform?.height, c = a.transform?.fit ?? "fill";
|
|
3582
|
+
s && o !== "passThrough" && (t(this.outputWidth), t(this.outputHeight), t(o !== "deny"), r = this.outputWidth, i = this.outputHeight, c = o);
|
|
3583
|
+
let l = await e.transform({
|
|
3584
|
+
width: r,
|
|
3585
|
+
height: i,
|
|
3586
|
+
roundDimensionsTo: 2,
|
|
3587
|
+
crop: a.transform?.crop,
|
|
3588
|
+
rotate: a.transform?.rotate,
|
|
3589
|
+
fit: c,
|
|
3590
|
+
alpha: a.alpha
|
|
3591
|
+
});
|
|
3592
|
+
(this.outputWidth === null || this.outputHeight === null) && (this.outputWidth = l.displayWidth, this.outputHeight = l.displayHeight), n && e.close(), e = l, n = !0;
|
|
3593
|
+
} else (this.outputWidth === null || this.outputHeight === null) && (this.outputWidth = e.codedWidth, this.outputHeight = e.codedHeight);
|
|
3594
|
+
let c = a.transform?.frameRate;
|
|
3595
|
+
if (c !== void 0) {
|
|
3596
|
+
let t = e.timestamp + e.duration, a = S(e.timestamp, c);
|
|
3597
|
+
if (this.frameRateLastSample !== null) {
|
|
3598
|
+
if (a <= this.frameRateLastTimestamp) {
|
|
3599
|
+
this.frameRateLastSample.close(), this.frameRateLastSample = e.clone(), this.frameRateLastEndTimestamp = t;
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3602
|
+
await this.padFrameRate(a, r);
|
|
3603
|
+
}
|
|
3604
|
+
e === i && (e = e.clone(), n = !0), e.setTimestamp(a), e.setDuration(1 / c), this.frameRateLastSample?.close(), this.frameRateLastSample = e.clone(), this.frameRateLastTimestamp = a, this.frameRateLastEndTimestamp = t;
|
|
3605
|
+
}
|
|
3606
|
+
await this.processAndEncode(e, r);
|
|
3607
|
+
} finally {
|
|
3608
|
+
n && e.close();
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
async processAndEncode(e, n) {
|
|
3612
|
+
let r = this.encodingConfig, i;
|
|
3613
|
+
if (r.transform?.process) {
|
|
3614
|
+
let t = r.transform.process(e);
|
|
3615
|
+
if (t instanceof Promise && (t = await t), t === null) return;
|
|
3616
|
+
Array.isArray(t) || (t = [t]);
|
|
3617
|
+
let n = [];
|
|
3618
|
+
try {
|
|
3619
|
+
for (let r of t) r instanceof G ? n.push(r) : typeof VideoFrame < "u" && r instanceof VideoFrame ? n.push(new G(r)) : n.push(new G(r, {
|
|
3620
|
+
timestamp: e.timestamp,
|
|
3621
|
+
duration: e.duration
|
|
3622
|
+
}));
|
|
3623
|
+
} catch (r) {
|
|
3624
|
+
for (let t of n) t !== e && t.close();
|
|
3625
|
+
for (let n of t) (n instanceof G && n !== e || typeof VideoFrame < "u" && n instanceof VideoFrame) && n.close();
|
|
3626
|
+
throw r;
|
|
3627
|
+
}
|
|
3628
|
+
i = n;
|
|
3629
|
+
} else i = [e];
|
|
3630
|
+
try {
|
|
3631
|
+
for (let e of i) {
|
|
3632
|
+
if (this.encoderInitialized || (this.ensureEncoderPromise || this.ensureEncoder(e), this.encoderInitialized || await this.ensureEncoderPromise), t(this.encoderInitialized), this.closed) break;
|
|
3633
|
+
let r = this.encodingConfig.keyFrameInterval ?? 2, i = Math.floor(e.timestamp / r), a = {
|
|
3634
|
+
...this.defaultEncodeOptions,
|
|
3635
|
+
...e.encodeOptions,
|
|
3636
|
+
...n
|
|
3637
|
+
}, o = {
|
|
3638
|
+
...a,
|
|
3639
|
+
keyFrame: a.keyFrame === void 0 ? r === 0 || i !== this.lastMultipleOfKeyFrameInterval : a.keyFrame
|
|
3640
|
+
};
|
|
3641
|
+
if (this.lastMultipleOfKeyFrameInterval = i, this.encodingConfig.onEncodedSample?.(e), this.customEncoder) {
|
|
3642
|
+
this.customEncoderQueueSize++;
|
|
3643
|
+
let t = e.clone(), n = this.customEncoderCallSerializer.call(() => this.customEncoder.encode(t, o)).catch((e) => this.setError(e)).finally(() => {
|
|
3644
|
+
this.customEncoderQueueSize--, t.close();
|
|
3645
|
+
});
|
|
3646
|
+
this.customEncoderQueueSize >= 4 && await n;
|
|
3647
|
+
} else {
|
|
3648
|
+
t(this.encoder);
|
|
3649
|
+
let n = e.toVideoFrame(), r = h(this.preciseTimings, n.timestamp, (e) => e.microsecondTimestamp), i = r === -1 ? null : this.preciseTimings[r];
|
|
3650
|
+
if (i && i.microsecondTimestamp === n.timestamp ? (i.timestamp !== e.timestamp && (i.timestampIsValid = !1), i.duration !== e.duration && (i.durationIsValid = !1)) : (this.preciseTimings.splice(r + 1, 0, {
|
|
3651
|
+
microsecondTimestamp: n.timestamp,
|
|
3652
|
+
timestamp: e.timestamp,
|
|
3653
|
+
duration: e.duration,
|
|
3654
|
+
timestampIsValid: !0,
|
|
3655
|
+
durationIsValid: !0
|
|
3656
|
+
}), this.preciseTimings.length > 128 && this.preciseTimings.shift()), !this.alphaEncoder) try {
|
|
3657
|
+
this.encoder.encode(n, o);
|
|
3658
|
+
} finally {
|
|
3659
|
+
n.close();
|
|
3660
|
+
}
|
|
3661
|
+
else if (n.format && !n.format.includes("A") || this.splitterCreationFailed) {
|
|
3662
|
+
this.alphaFrameQueue.push(null);
|
|
3663
|
+
try {
|
|
3664
|
+
this.encoder.encode(n, o);
|
|
3665
|
+
} finally {
|
|
3666
|
+
n.close();
|
|
3667
|
+
}
|
|
3668
|
+
} else {
|
|
3669
|
+
this.splitter ||= new vn();
|
|
3670
|
+
let { colorFrame: e, alphaFrame: t } = await this.splitter.split(n);
|
|
3671
|
+
this.alphaFrameQueue.push(t);
|
|
3672
|
+
try {
|
|
3673
|
+
this.encoder.encode(e, o);
|
|
3674
|
+
} finally {
|
|
3675
|
+
e.close();
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
this.encoder.encodeQueueSize >= 4 && await new Promise((e) => this.encoder.addEventListener("dequeue", e, { once: !0 }));
|
|
3679
|
+
}
|
|
3680
|
+
await this.lastMuxerPromise;
|
|
3681
|
+
}
|
|
3682
|
+
} finally {
|
|
3683
|
+
for (let t of i) t !== e && t.close();
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
async padFrameRate(e, n) {
|
|
3687
|
+
let r = this.encodingConfig.transform.frameRate;
|
|
3688
|
+
t(this.frameRateLastSample);
|
|
3689
|
+
let i = Math.round((e - this.frameRateLastTimestamp) * r);
|
|
3690
|
+
for (let e = 1; e < i; e++) {
|
|
3691
|
+
let t = {
|
|
3692
|
+
stack: [],
|
|
3693
|
+
error: void 0,
|
|
3694
|
+
hasError: !1
|
|
3695
|
+
};
|
|
3696
|
+
try {
|
|
3697
|
+
let i = dn(t, this.frameRateLastSample.clone(), !1);
|
|
3698
|
+
i.setTimestamp(this.frameRateLastTimestamp + e / r), i.setDuration(1 / r), await this.processAndEncode(i, n);
|
|
3699
|
+
} catch (e) {
|
|
3700
|
+
t.error = e, t.hasError = !0;
|
|
3701
|
+
} finally {
|
|
3702
|
+
fn(t);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3706
|
+
ensureEncoder(e) {
|
|
3707
|
+
this.ensureEncoderPromise = (async () => {
|
|
3708
|
+
let n = Ht(this.encodingConfig.quality, this.encodingConfig.bitrate);
|
|
3709
|
+
t(n !== void 0);
|
|
3710
|
+
let r = It({
|
|
3711
|
+
...this.encodingConfig,
|
|
3712
|
+
quality: n,
|
|
3713
|
+
width: e.codedWidth,
|
|
3714
|
+
height: e.codedHeight,
|
|
3715
|
+
squarePixelWidth: e.squarePixelWidth,
|
|
3716
|
+
squarePixelHeight: e.squarePixelHeight,
|
|
3717
|
+
framerate: this.source._connectedTrack?.metadata.frameRate
|
|
3718
|
+
}), i = null, a;
|
|
3719
|
+
for (let e of r) {
|
|
3720
|
+
let t = e.config;
|
|
3721
|
+
if (this.encodingConfig.onEncoderConfig?.(t), a = Ut.find((e) => e.supports(this.encodingConfig.codec, t)), a) {
|
|
3722
|
+
i = e;
|
|
3723
|
+
break;
|
|
3724
|
+
}
|
|
3725
|
+
if (!(typeof VideoEncoder > "u")) {
|
|
3726
|
+
if (t.alpha = "discard", this.encodingConfig.alpha === "keep" && (t.latencyMode = "quality"), (t.width % 2 == 1 || t.height % 2 == 1) && (this.encodingConfig.codec === "avc" || this.encodingConfig.codec === "hevc")) throw Error(`The dimensions ${t.width}x${t.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);
|
|
3727
|
+
try {
|
|
3728
|
+
if ((await VideoEncoder.isConfigSupported(t)).supported) {
|
|
3729
|
+
i = e;
|
|
3730
|
+
break;
|
|
3731
|
+
}
|
|
3732
|
+
} catch {}
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
if (!i) {
|
|
3736
|
+
if (typeof VideoEncoder > "u") throw Error("VideoEncoder is not supported by this browser.");
|
|
3737
|
+
let e = r[0].config, t = r.map(({ config: e, quantizer: t }) => t === null ? `${e.bitrate} bps` : `quantizer ${t}`);
|
|
3738
|
+
throw Error(`This specific encoder configuration (${e.codec}, ${t.join(" / ")}, ${e.width}x${e.height}, hardware acceleration: ${e.hardwareAcceleration ?? "no-preference"}) is not supported by this browser. Consider using another codec or changing your video parameters.`);
|
|
3739
|
+
}
|
|
3740
|
+
let o = i.config;
|
|
3741
|
+
if (i.quantizer !== null && (this.defaultEncodeOptions = Vt(this.encodingConfig.codec, i.quantizer)), a) this.customEncoder = new a(), this.customEncoder.codec = this.encodingConfig.codec, this.customEncoder.config = o, this.customEncoder.onPacket = (e, t) => {
|
|
3742
|
+
if (!(e instanceof z)) throw TypeError("The first argument passed to onPacket must be an EncodedPacket.");
|
|
3743
|
+
if (t !== void 0 && (!t || typeof t != "object")) throw TypeError("The second argument passed to onPacket must be an object or undefined.");
|
|
3744
|
+
hn(this.source._connectedTrack, e), this.encodingConfig.onEncodedPacket?.(e, t), this.lastMuxerPromise = this.muxer.addEncodedVideoPacket(this.source._connectedTrack, e, t).catch((e) => {
|
|
3745
|
+
this.setError(e);
|
|
3746
|
+
});
|
|
3747
|
+
}, this.customEncoder.onError = (e) => {
|
|
3748
|
+
this.setError(e);
|
|
3749
|
+
}, await this.customEncoder.init();
|
|
3750
|
+
else {
|
|
3751
|
+
let e = [], n = [], r = 0, i = 0, a = (e, t, n) => {
|
|
3752
|
+
let r = {};
|
|
3753
|
+
if (t) {
|
|
3754
|
+
let e = new Uint8Array(t.byteLength);
|
|
3755
|
+
t.copyTo(e), r.alpha = e;
|
|
3756
|
+
}
|
|
3757
|
+
let i = z.fromEncodedChunk(e, r), a = h(this.preciseTimings, e.timestamp, (e) => e.microsecondTimestamp), o = a === -1 ? null : this.preciseTimings[a], s = null;
|
|
3758
|
+
this.emittedEncoderPackets === 0 && i.type === "delta" && n?.decoderConfig && (s = nt(this.encodingConfig.codec, n.decoderConfig, i.data)), (o && o.microsecondTimestamp === e.timestamp || s !== null) && (i = i.clone({
|
|
3759
|
+
timestamp: o?.timestampIsValid ? o.timestamp : void 0,
|
|
3760
|
+
duration: o?.durationIsValid ? o.duration : void 0,
|
|
3761
|
+
type: s ?? void 0
|
|
3762
|
+
})), hn(this.source._connectedTrack, i), this.encodingConfig.onEncodedPacket?.(i, n), this.lastMuxerPromise = this.muxer.addEncodedVideoPacket(this.source._connectedTrack, i, n).catch((e) => {
|
|
3763
|
+
this.setError(e);
|
|
3764
|
+
}), this.emittedEncoderPackets++;
|
|
3765
|
+
}, s = (/* @__PURE__ */ Error("Encoding error")).stack;
|
|
3766
|
+
if (this.encoder = new VideoEncoder({
|
|
3767
|
+
output: (o, s) => {
|
|
3768
|
+
if (!this.alphaEncoder) {
|
|
3769
|
+
a(o, null, s);
|
|
3770
|
+
return;
|
|
3771
|
+
}
|
|
3772
|
+
let c = this.alphaFrameQueue.shift();
|
|
3773
|
+
t(c !== void 0), c ? (this.alphaEncoder.encode(c, {
|
|
3774
|
+
...this.defaultEncodeOptions,
|
|
3775
|
+
keyFrame: o.type === "key"
|
|
3776
|
+
}), i++, c.close(), e.push({
|
|
3777
|
+
chunk: o,
|
|
3778
|
+
meta: s
|
|
3779
|
+
})) : i === 0 ? a(o, null, s) : (n.push(r + i), e.push({
|
|
3780
|
+
chunk: o,
|
|
3781
|
+
meta: s
|
|
3782
|
+
}));
|
|
3783
|
+
},
|
|
3784
|
+
error: (e) => {
|
|
3785
|
+
e.stack = s, this.setError(e);
|
|
3786
|
+
}
|
|
3787
|
+
}), this.encoder.configure(o), this.encodingConfig.alpha === "keep") {
|
|
3788
|
+
let s = (/* @__PURE__ */ Error("Encoding error")).stack;
|
|
3789
|
+
this.alphaEncoder = new VideoEncoder({
|
|
3790
|
+
output: (o, s) => {
|
|
3791
|
+
i--;
|
|
3792
|
+
let c = e.shift();
|
|
3793
|
+
for (t(c !== void 0), a(c.chunk, o, c.meta), r++; n.length > 0 && n[0] === r;) {
|
|
3794
|
+
n.shift();
|
|
3795
|
+
let r = e.shift();
|
|
3796
|
+
t(r !== void 0), a(r.chunk, null, r.meta);
|
|
3797
|
+
}
|
|
3798
|
+
},
|
|
3799
|
+
error: (e) => {
|
|
3800
|
+
e.stack = s, this.setError(e);
|
|
3801
|
+
}
|
|
3802
|
+
}), this.alphaEncoder.configure(o);
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
t(this.source._connectedTrack), this.muxer = this.source._connectedTrack.output._muxer, this.encoderInitialized = !0;
|
|
3806
|
+
})();
|
|
3807
|
+
}
|
|
3808
|
+
async flushAndClose(e) {
|
|
3809
|
+
try {
|
|
3810
|
+
if (!e && (this.checkForEncoderError(), this.frameRateLastSample)) {
|
|
3811
|
+
let e = this.encodingConfig.transform.frameRate, t = S(this.frameRateLastEndTimestamp, e);
|
|
3812
|
+
await this.padFrameRate(t);
|
|
3813
|
+
}
|
|
3814
|
+
this.closed = !0, e || (this.customEncoder ? this.customEncoderCallSerializer.call(() => this.customEncoder.flush()) : this.encoder && (await this.encoder.flush(), await this.alphaEncoder?.flush(), await pe(25)));
|
|
3815
|
+
} finally {
|
|
3816
|
+
this.closed = !0, this.frameRateLastSample?.close(), this.frameRateLastSample = null, this.customEncoder ? await this.customEncoderCallSerializer.call(() => this.customEncoder.close()).catch((e) => this.setError(e)) : this.encoder && (this.encoder.state !== "closed" && this.encoder.close(), this.alphaEncoder && this.alphaEncoder.state !== "closed" && this.alphaEncoder.close(), this.alphaFrameQueue.forEach((e) => e?.close()), this.alphaFrameQueue.length = 0, this.splitter?.close());
|
|
3817
|
+
}
|
|
3818
|
+
e || this.checkForEncoderError();
|
|
3819
|
+
}
|
|
3820
|
+
getQueueSize() {
|
|
3821
|
+
return this.customEncoder ? this.customEncoderQueueSize : this.encoder?.encodeQueueSize ?? 0;
|
|
3822
|
+
}
|
|
3823
|
+
checkForEncoderError() {
|
|
3824
|
+
if (this.errorSet) throw this.error;
|
|
3825
|
+
}
|
|
3826
|
+
}, _n = null, vn = class {
|
|
3827
|
+
constructor() {
|
|
3828
|
+
this.worker = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.nextRequestId = 0;
|
|
3829
|
+
}
|
|
3830
|
+
split(e) {
|
|
3831
|
+
if (!this.worker) {
|
|
3832
|
+
if (!_n) {
|
|
3833
|
+
let e = new Blob([`(${yn.toString()})()`], { type: "application/javascript" });
|
|
3834
|
+
_n = URL.createObjectURL(e);
|
|
3835
|
+
}
|
|
3836
|
+
this.worker = new Worker(_n), this.worker.addEventListener("message", (e) => {
|
|
3837
|
+
let t = e.data, n = this.pendingRequests.get(t.id);
|
|
3838
|
+
n && (this.pendingRequests.delete(t.id), "error" in t ? n.reject(Error(t.error)) : n.resolve({
|
|
3839
|
+
colorFrame: t.colorFrame,
|
|
3840
|
+
alphaFrame: t.alphaFrame
|
|
3841
|
+
}));
|
|
3842
|
+
}), this.worker.addEventListener("error", (e) => {
|
|
3843
|
+
let t = Error(e.message || "Color/alpha splitter worker error.");
|
|
3844
|
+
for (let e of this.pendingRequests.values()) e.reject(t);
|
|
3845
|
+
this.pendingRequests.clear();
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
let t = this.nextRequestId++, n = g();
|
|
3849
|
+
return this.pendingRequests.set(t, n), this.worker.postMessage({
|
|
3850
|
+
id: t,
|
|
3851
|
+
sourceFrame: e
|
|
3852
|
+
}, { transfer: [e] }), n.promise;
|
|
3853
|
+
}
|
|
3854
|
+
close() {
|
|
3855
|
+
this.worker?.terminate(), this.worker = null;
|
|
3856
|
+
let e = /* @__PURE__ */ Error("Color/alpha splitter closed.");
|
|
3857
|
+
for (let t of this.pendingRequests.values()) t.reject(e);
|
|
3858
|
+
this.pendingRequests.clear();
|
|
3859
|
+
}
|
|
3860
|
+
}, yn = () => {
|
|
3861
|
+
let e = null, t = Promise.resolve();
|
|
3862
|
+
self.addEventListener("message", (e) => {
|
|
3863
|
+
let { id: r, sourceFrame: i } = e.data;
|
|
3864
|
+
t = t.then(async () => {
|
|
3865
|
+
try {
|
|
3866
|
+
let { colorFrame: e, alphaFrame: t } = await n(i);
|
|
3867
|
+
self.postMessage({
|
|
3868
|
+
id: r,
|
|
3869
|
+
colorFrame: e,
|
|
3870
|
+
alphaFrame: t
|
|
3871
|
+
}, { transfer: [e, t] });
|
|
3872
|
+
} catch (e) {
|
|
3873
|
+
self.postMessage({
|
|
3874
|
+
id: r,
|
|
3875
|
+
error: e.message
|
|
3876
|
+
});
|
|
3877
|
+
} finally {
|
|
3878
|
+
i.close();
|
|
3879
|
+
}
|
|
3880
|
+
});
|
|
3881
|
+
});
|
|
3882
|
+
let n = async (t) => {
|
|
3883
|
+
let n = t.format;
|
|
3884
|
+
if (!n) throw Error("CPU color/alpha splitting requires a known VideoFrame format.");
|
|
3885
|
+
let a = t.allocationSize();
|
|
3886
|
+
if ((!e || e.byteLength !== a) && (e = new Uint8Array(a)), await t.copyTo(e), n === "RGBA" || n === "BGRA") return r(e, n, t);
|
|
3887
|
+
if (n === "I420A" || n === "I420AP10" || n === "I420AP12" || n === "I422A" || n === "I422AP10" || n === "I422AP12" || n === "I444A" || n === "I444AP10" || n === "I444AP12") return i(e, n, t);
|
|
3888
|
+
throw Error(`CPU color/alpha splitting does not support format '${n}'.`);
|
|
3889
|
+
}, r = (e, t, n) => {
|
|
3890
|
+
let r = n.visibleRect?.width ?? n.codedWidth, i = n.visibleRect?.height ?? n.codedHeight, a = r * i, o = a + Math.ceil(r / 2) * Math.ceil(i / 2) * 2, s = new Uint8Array(o);
|
|
3891
|
+
for (let t = 0, n = 3; t < a; t++, n += 4) s[t] = e[n];
|
|
3892
|
+
s.fill(128, a);
|
|
3893
|
+
let c = new VideoFrame(e, {
|
|
3894
|
+
format: t === "RGBA" ? "RGBX" : "BGRX",
|
|
3895
|
+
codedWidth: r,
|
|
3896
|
+
codedHeight: i,
|
|
3897
|
+
timestamp: n.timestamp,
|
|
3898
|
+
duration: n.duration ?? void 0
|
|
3899
|
+
}), l = {
|
|
3900
|
+
format: "I420",
|
|
3901
|
+
codedWidth: r,
|
|
3902
|
+
codedHeight: i,
|
|
3903
|
+
timestamp: n.timestamp,
|
|
3904
|
+
duration: n.duration ?? void 0,
|
|
3905
|
+
transfer: [s.buffer]
|
|
3906
|
+
};
|
|
3907
|
+
return {
|
|
3908
|
+
colorFrame: c,
|
|
3909
|
+
alphaFrame: new VideoFrame(s, l)
|
|
3910
|
+
};
|
|
3911
|
+
}, i = (e, t, n) => {
|
|
3912
|
+
let r = n.visibleRect?.width ?? n.codedWidth, i = n.visibleRect?.height ?? n.codedHeight, a = t.includes("P10"), o = t.includes("P12"), s = a || o ? 2 : 1, c, l;
|
|
3913
|
+
t.startsWith("I420") ? (c = Math.ceil(r / 2), l = Math.ceil(i / 2)) : t.startsWith("I422") ? (c = Math.ceil(r / 2), l = i) : (c = r, l = i);
|
|
3914
|
+
let u = r * i, d = c * l, f = u * s, p = d * s, m = u * s, h = f + p * 2, g = t.replace("A", ""), _ = Math.ceil(r / 2) * Math.ceil(i / 2), ee = m + _ * s * 2, v = new Uint8Array(ee), y = h;
|
|
3915
|
+
v.set(e.subarray(y, y + m), 0);
|
|
3916
|
+
let b = m, x = a ? 512 : o ? 2048 : 128;
|
|
3917
|
+
s === 1 ? v.fill(x, b) : new Uint16Array(v.buffer, b, 2 * _).fill(x);
|
|
3918
|
+
let S = a ? "I420P10" : o ? "I420P12" : "I420", te = new VideoFrame(e.subarray(0, h), {
|
|
3919
|
+
format: g,
|
|
3920
|
+
codedWidth: r,
|
|
3921
|
+
codedHeight: i,
|
|
3922
|
+
timestamp: n.timestamp,
|
|
3923
|
+
duration: n.duration ?? void 0
|
|
3924
|
+
}), ne = {
|
|
3925
|
+
format: S,
|
|
3926
|
+
codedWidth: r,
|
|
3927
|
+
codedHeight: i,
|
|
3928
|
+
timestamp: n.timestamp,
|
|
3929
|
+
duration: n.duration ?? void 0,
|
|
3930
|
+
transfer: [v.buffer]
|
|
3931
|
+
};
|
|
3932
|
+
return {
|
|
3933
|
+
colorFrame: te,
|
|
3934
|
+
alphaFrame: new VideoFrame(v, ne)
|
|
3935
|
+
};
|
|
3936
|
+
};
|
|
3937
|
+
}, bn = class extends mn {
|
|
3938
|
+
constructor(e, t) {
|
|
3939
|
+
if (!(typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement) && !(typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas)) throw TypeError("canvas must be an HTMLCanvasElement or OffscreenCanvas.");
|
|
3940
|
+
Pt(t), super(t.codec), this._encoder = new gn(this, t), this._canvas = e;
|
|
3941
|
+
}
|
|
3942
|
+
add(e, t = 0, n) {
|
|
3943
|
+
if (!Number.isFinite(e) || e < 0) throw TypeError("timestamp must be a non-negative number.");
|
|
3944
|
+
if (!Number.isFinite(t) || t < 0) throw TypeError("duration must be a non-negative number.");
|
|
3945
|
+
let r = new G(this._canvas, {
|
|
3946
|
+
timestamp: e,
|
|
3947
|
+
duration: t
|
|
3948
|
+
});
|
|
3949
|
+
return this._encoder.add(r, !0, n);
|
|
3950
|
+
}
|
|
3951
|
+
_flushAndClose(e) {
|
|
3952
|
+
return this._encoder.flushAndClose(e);
|
|
3953
|
+
}
|
|
3954
|
+
}, xn = class extends pn {
|
|
3955
|
+
constructor(e) {
|
|
3956
|
+
if (super(), this._connectedTrack = null, !P.includes(e)) throw TypeError(`Invalid audio codec '${e}'. Must be one of: ${P.join(", ")}.`);
|
|
3957
|
+
this._codec = e;
|
|
3958
|
+
}
|
|
3959
|
+
}, Sn = class extends pn {
|
|
3960
|
+
constructor(e) {
|
|
3961
|
+
if (super(), this._connectedTrack = null, !F.includes(e)) throw TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${F.join(", ")}.`);
|
|
3962
|
+
this._codec = e;
|
|
3963
|
+
}
|
|
3964
|
+
}, Cn = class {
|
|
3965
|
+
getSupportedVideoCodecs() {
|
|
3966
|
+
return this.getSupportedCodecs().filter((e) => M.includes(e));
|
|
3967
|
+
}
|
|
3968
|
+
getSupportedAudioCodecs() {
|
|
3969
|
+
return this.getSupportedCodecs().filter((e) => P.includes(e));
|
|
3970
|
+
}
|
|
3971
|
+
getSupportedSubtitleCodecs() {
|
|
3972
|
+
return this.getSupportedCodecs().filter((e) => F.includes(e));
|
|
3973
|
+
}
|
|
3974
|
+
_codecUnsupportedHint(e) {
|
|
3975
|
+
return "";
|
|
3976
|
+
}
|
|
3977
|
+
_isFragmentedIsobmff() {
|
|
3978
|
+
return !1;
|
|
3979
|
+
}
|
|
3980
|
+
}, wn = class extends Cn {
|
|
3981
|
+
constructor(e = {}) {
|
|
3982
|
+
if (!e || typeof e != "object") throw TypeError("options must be an object.");
|
|
3983
|
+
if (e.appendOnly !== void 0 && typeof e.appendOnly != "boolean") throw TypeError("options.appendOnly, when provided, must be a boolean.");
|
|
3984
|
+
if (e.minimumClusterDuration !== void 0 && (!Number.isFinite(e.minimumClusterDuration) || e.minimumClusterDuration < 0)) throw TypeError("options.minimumClusterDuration, when provided, must be a non-negative number.");
|
|
3985
|
+
if (e.onEbmlHeader !== void 0 && typeof e.onEbmlHeader != "function") throw TypeError("options.onEbmlHeader, when provided, must be a function.");
|
|
3986
|
+
if (e.onSegmentHeader !== void 0 && typeof e.onSegmentHeader != "function") throw TypeError("options.onHeader, when provided, must be a function.");
|
|
3987
|
+
if (e.onCluster !== void 0 && typeof e.onCluster != "function") throw TypeError("options.onCluster, when provided, must be a function.");
|
|
3988
|
+
super(), this._options = e;
|
|
3989
|
+
}
|
|
3990
|
+
_createMuxer(e) {
|
|
3991
|
+
return new un(e, this);
|
|
3992
|
+
}
|
|
3993
|
+
get _name() {
|
|
3994
|
+
return "Matroska";
|
|
3995
|
+
}
|
|
3996
|
+
getSupportedTrackCounts() {
|
|
3997
|
+
return {
|
|
3998
|
+
video: {
|
|
3999
|
+
min: 0,
|
|
4000
|
+
max: 127
|
|
4001
|
+
},
|
|
4002
|
+
audio: {
|
|
4003
|
+
min: 0,
|
|
4004
|
+
max: 127
|
|
4005
|
+
},
|
|
4006
|
+
subtitle: {
|
|
4007
|
+
min: 0,
|
|
4008
|
+
max: 127
|
|
4009
|
+
},
|
|
4010
|
+
total: {
|
|
4011
|
+
min: 0,
|
|
4012
|
+
max: 127
|
|
4013
|
+
}
|
|
4014
|
+
};
|
|
4015
|
+
}
|
|
4016
|
+
get fileExtension() {
|
|
4017
|
+
return ".mkv";
|
|
4018
|
+
}
|
|
4019
|
+
get mimeType() {
|
|
4020
|
+
return "video/x-matroska";
|
|
4021
|
+
}
|
|
4022
|
+
getSupportedCodecs() {
|
|
4023
|
+
return [
|
|
4024
|
+
...M,
|
|
4025
|
+
...Ce,
|
|
4026
|
+
...N.filter((e) => ![
|
|
4027
|
+
"pcm-s8",
|
|
4028
|
+
"pcm-f32be",
|
|
4029
|
+
"pcm-f64be",
|
|
4030
|
+
"ulaw",
|
|
4031
|
+
"alaw"
|
|
4032
|
+
].includes(e)),
|
|
4033
|
+
...F
|
|
4034
|
+
];
|
|
4035
|
+
}
|
|
4036
|
+
get supportsVideoRotationMetadata() {
|
|
4037
|
+
return !1;
|
|
4038
|
+
}
|
|
4039
|
+
get supportsTimestampedMediaData() {
|
|
4040
|
+
return !0;
|
|
4041
|
+
}
|
|
4042
|
+
}, Tn = class extends wn {
|
|
4043
|
+
constructor(e) {
|
|
4044
|
+
super(e);
|
|
4045
|
+
}
|
|
4046
|
+
getSupportedCodecs() {
|
|
4047
|
+
return [
|
|
4048
|
+
...M.filter((e) => [
|
|
4049
|
+
"vp8",
|
|
4050
|
+
"vp9",
|
|
4051
|
+
"av1"
|
|
4052
|
+
].includes(e)),
|
|
4053
|
+
...P.filter((e) => ["opus", "vorbis"].includes(e)),
|
|
4054
|
+
...F
|
|
4055
|
+
];
|
|
4056
|
+
}
|
|
4057
|
+
get _name() {
|
|
4058
|
+
return "WebM";
|
|
4059
|
+
}
|
|
4060
|
+
get fileExtension() {
|
|
4061
|
+
return ".webm";
|
|
4062
|
+
}
|
|
4063
|
+
get mimeType() {
|
|
4064
|
+
return "video/webm";
|
|
4065
|
+
}
|
|
4066
|
+
_codecUnsupportedHint(e) {
|
|
4067
|
+
return new wn().getSupportedCodecs().includes(e) ? " Switching to MKV will grant support for this codec." : "";
|
|
4068
|
+
}
|
|
4069
|
+
}, En = [
|
|
4070
|
+
"video",
|
|
4071
|
+
"audio",
|
|
4072
|
+
"subtitle"
|
|
4073
|
+
], Dn = class e {
|
|
4074
|
+
constructor(e, t, n, r, i) {
|
|
4075
|
+
this.id = e, this.output = t, this.type = n, this.source = r, this.metadata = i;
|
|
4076
|
+
}
|
|
4077
|
+
isVideoTrack() {
|
|
4078
|
+
return this.type === "video";
|
|
4079
|
+
}
|
|
4080
|
+
isAudioTrack() {
|
|
4081
|
+
return this.type === "audio";
|
|
4082
|
+
}
|
|
4083
|
+
isSubtitleTrack() {
|
|
4084
|
+
return this.type === "subtitle";
|
|
4085
|
+
}
|
|
4086
|
+
canBePairedWith(t) {
|
|
4087
|
+
if (!(t instanceof e)) throw TypeError("other must be an OutputTrack.");
|
|
4088
|
+
if (this === t) return !1;
|
|
4089
|
+
let n = me(this.metadata.group), r = me(t.metadata.group);
|
|
4090
|
+
for (let e of n) if (this.type !== t.type && r.some((t) => e === t) || r.some((t) => e._pairedGroups.has(t))) return !0;
|
|
4091
|
+
return !1;
|
|
4092
|
+
}
|
|
4093
|
+
}, On = class extends Dn {
|
|
4094
|
+
constructor(e, t, n, r) {
|
|
4095
|
+
super(e, t, "video", n, r);
|
|
4096
|
+
}
|
|
4097
|
+
}, kn = class extends Dn {
|
|
4098
|
+
constructor(e, t, n, r) {
|
|
4099
|
+
super(e, t, "audio", n, r);
|
|
4100
|
+
}
|
|
4101
|
+
}, An = class extends Dn {
|
|
4102
|
+
constructor(e, t, n, r) {
|
|
4103
|
+
super(e, t, "subtitle", n, r);
|
|
4104
|
+
}
|
|
4105
|
+
}, jn = class e {
|
|
4106
|
+
constructor() {
|
|
4107
|
+
this._pairedGroups = /* @__PURE__ */ new Set();
|
|
4108
|
+
}
|
|
4109
|
+
pairWith(t) {
|
|
4110
|
+
if (!(t instanceof e)) throw TypeError("other must be an OutputTrackGroup.");
|
|
4111
|
+
if (this === t) throw TypeError("Cannot pair a group with itself.");
|
|
4112
|
+
this._pairedGroups.add(t), t._pairedGroups.add(this);
|
|
4113
|
+
}
|
|
4114
|
+
}, Mn = (e) => {
|
|
4115
|
+
if (!e || typeof e != "object") throw TypeError("metadata must be an object.");
|
|
4116
|
+
if (e.languageCode !== void 0 && !ne(e.languageCode)) throw TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");
|
|
4117
|
+
if (e.name !== void 0 && typeof e.name != "string") throw TypeError("metadata.name, when provided, must be a string.");
|
|
4118
|
+
if (e.disposition !== void 0 && ye(e.disposition), e.maximumPacketCount !== void 0 && (!Number.isInteger(e.maximumPacketCount) || e.maximumPacketCount < 0)) throw TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.");
|
|
4119
|
+
if (e.group !== void 0 && !(e.group instanceof jn) && (!Array.isArray(e.group) || e.group.some((e) => !(e instanceof jn)))) throw TypeError("metadata.group, when provided, must be an OutputTrackGroup instance or an array of OutputTrackGroup instances.");
|
|
4120
|
+
}, Nn = class extends O {
|
|
4121
|
+
get target() {
|
|
4122
|
+
let e = "Output.target cannot be used when using PathedTarget with an async callback. Use the 'target' event instead.";
|
|
4123
|
+
if (this._rootTargetPromise) throw TypeError(e);
|
|
4124
|
+
let t = this._getRootTarget();
|
|
4125
|
+
if (t instanceof Promise) throw TypeError(e);
|
|
4126
|
+
return t;
|
|
4127
|
+
}
|
|
4128
|
+
constructor(e) {
|
|
4129
|
+
if (super(), this.state = "pending", this.defaultTrackGroup = new jn(), this.tracks = [], this._onFinalize = null, this._unfinalizedTargets = /* @__PURE__ */ new Set(), this._rootWriterPromise = null, this._startPromise = null, this._cancelPromise = null, this._finalizePromise = null, this._mutex = new m(), this._metadataTags = {}, this._rootTarget = null, this._rootTargetPromise = null, this._firstMediaStreamTimestamp = null, !e || typeof e != "object") throw TypeError("options must be an object.");
|
|
4130
|
+
if (!(e.format instanceof Cn)) throw TypeError("options.format must be an OutputFormat.");
|
|
4131
|
+
if (!(e.target instanceof Q || e.target instanceof nn)) throw TypeError("options.target must be a Target or a PathedTarget.");
|
|
4132
|
+
if (e.target instanceof Q && this._rememberTarget(e.target), e.initTarget !== void 0 && !(e.initTarget instanceof Q) && typeof e.initTarget != "function") throw Error("options.initTarget, when provided, must be a Target or a function that returns or resolves to a Target.");
|
|
4133
|
+
if (e.onFinalize !== void 0 && typeof e.onFinalize != "function") throw TypeError("options.onFinalize, when provided, must be a function.");
|
|
4134
|
+
this.format = e.format, this._target = e.target, this._onFinalize = e.onFinalize ?? null, this._initTarget = e.initTarget ?? null, this._initTarget instanceof Q && this._rememberTarget(this._initTarget), this._muxer = e.format._createMuxer(this);
|
|
4135
|
+
}
|
|
4136
|
+
_getTargetValidated(e) {
|
|
4137
|
+
t(this._target instanceof nn);
|
|
4138
|
+
let n = this._target.getTarget(e), r = (e) => {
|
|
4139
|
+
if (!(e instanceof Q)) throw TypeError("getTarget must return a Target.");
|
|
4140
|
+
return e;
|
|
4141
|
+
};
|
|
4142
|
+
return n instanceof Promise ? n.then(r) : r(n);
|
|
4143
|
+
}
|
|
4144
|
+
async _getTarget(e) {
|
|
4145
|
+
t(this._target instanceof nn);
|
|
4146
|
+
let n = await this._getTargetValidated(e);
|
|
4147
|
+
return this._emit("target", {
|
|
4148
|
+
target: n,
|
|
4149
|
+
request: e,
|
|
4150
|
+
isRoot: e.isRoot
|
|
4151
|
+
}), this.state === "canceled" ? await n._close() : this._rememberTarget(n), n;
|
|
4152
|
+
}
|
|
4153
|
+
_rememberTarget(e) {
|
|
4154
|
+
this._unfinalizedTargets.add(e), e.on("finalized", () => this._unfinalizedTargets.delete(e), { once: !0 });
|
|
4155
|
+
}
|
|
4156
|
+
async _getInitTarget() {
|
|
4157
|
+
if (t(this._initTarget !== null), this._initTarget instanceof Q) return this._initTarget;
|
|
4158
|
+
let e = await this._initTarget();
|
|
4159
|
+
return this.state === "canceled" ? await e._close() : this._rememberTarget(e), e;
|
|
4160
|
+
}
|
|
4161
|
+
_hasInitTarget() {
|
|
4162
|
+
return this._initTarget !== null;
|
|
4163
|
+
}
|
|
4164
|
+
_getRootTarget() {
|
|
4165
|
+
if (this._rootTarget) return this._rootTarget;
|
|
4166
|
+
if (this._rootTargetPromise) return this._rootTargetPromise;
|
|
4167
|
+
if (this._target instanceof Q) return this._emit("target", {
|
|
4168
|
+
target: this._target,
|
|
4169
|
+
request: null,
|
|
4170
|
+
isRoot: !0
|
|
4171
|
+
}), this._rootTarget = this._target, this._target;
|
|
4172
|
+
let e = {
|
|
4173
|
+
path: this._target.rootPath,
|
|
4174
|
+
isRoot: !0,
|
|
4175
|
+
mimeType: this.format.mimeType
|
|
4176
|
+
}, t = this._getTargetValidated(e), n = (t) => (this.state === "canceled" ? t._close() : this._rememberTarget(t), this._emit("target", {
|
|
4177
|
+
target: t,
|
|
4178
|
+
request: e,
|
|
4179
|
+
isRoot: !0
|
|
4180
|
+
}), this._rootTarget = t, t);
|
|
4181
|
+
return t instanceof Promise ? this._rootTargetPromise = t.then(n) : n(t);
|
|
4182
|
+
}
|
|
4183
|
+
_getRootWriter(e) {
|
|
4184
|
+
return this._rootWriterPromise ??= (async () => {
|
|
4185
|
+
let t = await this._getRootTarget(), n = new Qt(t, typeof e == "boolean" ? e : e(t));
|
|
4186
|
+
return n.start(), n;
|
|
4187
|
+
})();
|
|
4188
|
+
}
|
|
4189
|
+
addVideoTrack(e, t = {}) {
|
|
4190
|
+
if (!(e instanceof mn)) throw TypeError("source must be a VideoSource.");
|
|
4191
|
+
if (Mn(t), t.rotation !== void 0 && ![
|
|
4192
|
+
0,
|
|
4193
|
+
90,
|
|
4194
|
+
180,
|
|
4195
|
+
270
|
|
4196
|
+
].includes(t.rotation)) throw TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);
|
|
4197
|
+
if (!this.format.supportsVideoRotationMetadata && t.rotation) throw Error(`${this.format._name} does not support video rotation metadata.`);
|
|
4198
|
+
if (t.frameRate !== void 0 && (!Number.isFinite(t.frameRate) || t.frameRate <= 0)) throw TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);
|
|
4199
|
+
if (t.decoderConfig !== void 0 && Ve({ decoderConfig: t.decoderConfig }, e._codec), t.primingPacket !== void 0) {
|
|
4200
|
+
if (!(t.primingPacket instanceof z)) throw TypeError("metadata.primingPacket, when provided, must be an EncodedPacket.");
|
|
4201
|
+
if (t.decoderConfig === void 0) throw TypeError("metadata.primingPacket can only be provided alongside metadata.decoderConfig.");
|
|
4202
|
+
}
|
|
4203
|
+
let n = { ...t };
|
|
4204
|
+
return n.group ??= this.defaultTrackGroup, this._addTrack(new On(this.tracks.length + 1, this, e, n));
|
|
4205
|
+
}
|
|
4206
|
+
addAudioTrack(e, t = {}) {
|
|
4207
|
+
if (!(e instanceof xn)) throw TypeError("source must be an AudioSource.");
|
|
4208
|
+
if (Mn(t), t.decoderConfig !== void 0 && Ue({ decoderConfig: t.decoderConfig }, e._codec), t.primingPacket !== void 0) {
|
|
4209
|
+
if (!(t.primingPacket instanceof z)) throw TypeError("metadata.primingPacket, when provided, must be an EncodedPacket.");
|
|
4210
|
+
if (t.decoderConfig === void 0) throw TypeError("metadata.primingPacket can only be provided alongside metadata.decoderConfig.");
|
|
4211
|
+
}
|
|
4212
|
+
let n = { ...t };
|
|
4213
|
+
return n.group ??= this.defaultTrackGroup, this._addTrack(new kn(this.tracks.length + 1, this, e, n));
|
|
4214
|
+
}
|
|
4215
|
+
addSubtitleTrack(e, t = {}) {
|
|
4216
|
+
if (!(e instanceof Sn)) throw TypeError("source must be a SubtitleSource.");
|
|
4217
|
+
Mn(t);
|
|
4218
|
+
let n = { ...t };
|
|
4219
|
+
return n.group ??= this.defaultTrackGroup, this._addTrack(new An(this.tracks.length + 1, this, e, n));
|
|
4220
|
+
}
|
|
4221
|
+
setMetadataTags(e) {
|
|
4222
|
+
if (ve(e), this.state !== "pending") throw Error("Cannot set metadata tags after output has been started or canceled.");
|
|
4223
|
+
this._metadataTags = e;
|
|
4224
|
+
}
|
|
4225
|
+
_addTrack(e) {
|
|
4226
|
+
if (this.state !== "pending") throw Error("Cannot add track after output has been started or canceled.");
|
|
4227
|
+
if (e.source._connectedTrack) throw Error("Source is already used for a track.");
|
|
4228
|
+
let t = this.format.getSupportedTrackCounts(), n = this.tracks.reduce((t, n) => t + +(n.type === e.type), 0), r = t[e.type].max;
|
|
4229
|
+
if (n === r) throw Error(r === 0 ? `${this.format._name} does not support ${e.type} tracks.` : `${this.format._name} does not support more than ${r} ${e.type} track${r === 1 ? "" : "s"}.`);
|
|
4230
|
+
let i = t.total.max;
|
|
4231
|
+
if (this.tracks.length === i) throw Error(`${this.format._name} does not support more than ${i} tracks${i === 1 ? "" : "s"} in total.`);
|
|
4232
|
+
if (e.isVideoTrack()) {
|
|
4233
|
+
let t = this.format.getSupportedVideoCodecs();
|
|
4234
|
+
if (t.length === 0) throw Error(`${this.format._name} does not support video tracks.` + this.format._codecUnsupportedHint(e.source._codec));
|
|
4235
|
+
if (!t.includes(e.source._codec)) throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${t.map((e) => `'${e}'`).join(", ")}.` + this.format._codecUnsupportedHint(e.source._codec));
|
|
4236
|
+
} else if (e.isAudioTrack()) {
|
|
4237
|
+
let t = this.format.getSupportedAudioCodecs();
|
|
4238
|
+
if (t.length === 0) throw Error(`${this.format._name} does not support audio tracks.` + this.format._codecUnsupportedHint(e.source._codec));
|
|
4239
|
+
if (!t.includes(e.source._codec)) throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${t.map((e) => `'${e}'`).join(", ")}.` + this.format._codecUnsupportedHint(e.source._codec));
|
|
4240
|
+
} else if (e.isSubtitleTrack()) {
|
|
4241
|
+
let t = this.format.getSupportedSubtitleCodecs();
|
|
4242
|
+
if (t.length === 0) throw Error(`${this.format._name} does not support subtitle tracks.` + this.format._codecUnsupportedHint(e.source._codec));
|
|
4243
|
+
if (!t.includes(e.source._codec)) throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${t.map((e) => `'${e}'`).join(", ")}.` + this.format._codecUnsupportedHint(e.source._codec));
|
|
4244
|
+
}
|
|
4245
|
+
return this.tracks.push(e), e.source._connectedTrack = e, e;
|
|
4246
|
+
}
|
|
4247
|
+
hasEnoughTracks() {
|
|
4248
|
+
let e = this.format.getSupportedTrackCounts();
|
|
4249
|
+
for (let t of En) if (this.tracks.reduce((e, n) => e + +(n.type === t), 0) < e[t].min) return !1;
|
|
4250
|
+
let t = e.total.min;
|
|
4251
|
+
return !(this.tracks.length < t);
|
|
4252
|
+
}
|
|
4253
|
+
async start() {
|
|
4254
|
+
let e = this.format.getSupportedTrackCounts();
|
|
4255
|
+
for (let t of En) {
|
|
4256
|
+
let n = this.tracks.reduce((e, n) => e + +(n.type === t), 0), r = e[t].min;
|
|
4257
|
+
if (n < r) throw Error(r === e[t].max ? `${this.format._name} requires exactly ${r} ${t} track${r === 1 ? "" : "s"}.` : `${this.format._name} requires at least ${r} ${t} track${r === 1 ? "" : "s"}.`);
|
|
4258
|
+
}
|
|
4259
|
+
let t = e.total.min;
|
|
4260
|
+
if (this.tracks.length < t) throw Error(t === e.total.max ? `${this.format._name} requires exactly ${t} track${t === 1 ? "" : "s"}.` : `${this.format._name} requires at least ${t} track${t === 1 ? "" : "s"}.`);
|
|
4261
|
+
if (this.state === "canceled") throw Error("Output has been canceled.");
|
|
4262
|
+
return this._startPromise ? (A._warn("Output has already been started."), this._startPromise) : this._startPromise = (async () => {
|
|
4263
|
+
this.state = "started";
|
|
4264
|
+
let e = this._mutex.acquire();
|
|
4265
|
+
try {
|
|
4266
|
+
await this._muxer.start();
|
|
4267
|
+
let e = this.tracks.map((e) => e.source._start());
|
|
4268
|
+
await Promise.all(e);
|
|
4269
|
+
} finally {
|
|
4270
|
+
(await e)();
|
|
4271
|
+
}
|
|
4272
|
+
})();
|
|
4273
|
+
}
|
|
4274
|
+
getMimeType() {
|
|
4275
|
+
return this._muxer.getMimeType();
|
|
4276
|
+
}
|
|
4277
|
+
async cancel() {
|
|
4278
|
+
if (this._cancelPromise) return A._warn("Output has already been canceled."), this._cancelPromise;
|
|
4279
|
+
if (this.state === "finalizing" || this.state === "finalized") {
|
|
4280
|
+
this.state === "finalized" && A._warn("Output has already been finalized.");
|
|
4281
|
+
return;
|
|
4282
|
+
}
|
|
4283
|
+
return this._cancelPromise = (async () => {
|
|
4284
|
+
this.state = "canceled";
|
|
4285
|
+
let e = await this._mutex.acquire();
|
|
4286
|
+
try {
|
|
4287
|
+
let e = this.tracks.map((e) => e.source._flushOrWaitForOngoingClose(!0));
|
|
4288
|
+
await Promise.all(e), await Promise.all([...this._unfinalizedTargets].map((e) => e._close())), this._unfinalizedTargets.clear();
|
|
4289
|
+
} finally {
|
|
4290
|
+
e();
|
|
4291
|
+
}
|
|
4292
|
+
})();
|
|
4293
|
+
}
|
|
4294
|
+
async finalize() {
|
|
4295
|
+
if (this.state === "pending") throw Error("Cannot finalize before starting.");
|
|
4296
|
+
if (this.state === "canceled") throw Error("Cannot finalize after canceling.");
|
|
4297
|
+
return this._finalizePromise ? (A._warn("Output has already been finalized."), this._finalizePromise) : this._finalizePromise = (async () => {
|
|
4298
|
+
this.state = "finalizing";
|
|
4299
|
+
let e = await this._mutex.acquire();
|
|
4300
|
+
try {
|
|
4301
|
+
let e = this.tracks.map((e) => e.source._flushOrWaitForOngoingClose(!1));
|
|
4302
|
+
if (await Promise.all(e), await this._muxer.finalize(), this._rootWriterPromise) {
|
|
4303
|
+
let e = await this._rootWriterPromise;
|
|
4304
|
+
e.finalized || (await e.flush(), await e.finalize());
|
|
4305
|
+
}
|
|
4306
|
+
this._onFinalize && await this._onFinalize(), this.state = "finalized";
|
|
4307
|
+
} finally {
|
|
4308
|
+
await Promise.all([...this._unfinalizedTargets].map((e) => e._close().catch(() => {}))), this._unfinalizedTargets.clear(), e();
|
|
4309
|
+
}
|
|
4310
|
+
})();
|
|
4311
|
+
}
|
|
4312
|
+
};
|
|
4313
|
+
//#endregion
|
|
4314
|
+
export { en as BufferTarget, bn as CanvasSource, Nn as Output, Tn as WebMOutputFormat };
|