@tscaps/engine 0.1.1
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/LICENSE +21 -0
- package/README.md +349 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.d.ts +5 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.d.ts.map +1 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.js +41 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.js.map +1 -0
- package/dist/modules/css/CssMinifier.d.ts +12 -0
- package/dist/modules/css/CssMinifier.d.ts.map +1 -0
- package/dist/modules/css/CssMinifier.js +47 -0
- package/dist/modules/css/CssMinifier.js.map +1 -0
- package/dist/modules/css/CssResourceEmbedder.d.ts +4 -0
- package/dist/modules/css/CssResourceEmbedder.d.ts.map +1 -0
- package/dist/modules/css/CssResourceEmbedder.js +2 -0
- package/dist/modules/css/CssResourceEmbedder.js.map +1 -0
- package/dist/modules/css/CssScoper.d.ts +16 -0
- package/dist/modules/css/CssScoper.d.ts.map +1 -0
- package/dist/modules/css/CssScoper.js +109 -0
- package/dist/modules/css/CssScoper.js.map +1 -0
- package/dist/modules/css/NoopCssResourceEmbedder.d.ts +12 -0
- package/dist/modules/css/NoopCssResourceEmbedder.d.ts.map +1 -0
- package/dist/modules/css/NoopCssResourceEmbedder.js +13 -0
- package/dist/modules/css/NoopCssResourceEmbedder.js.map +1 -0
- package/dist/modules/css/index.d.ts +6 -0
- package/dist/modules/css/index.d.ts.map +1 -0
- package/dist/modules/css/index.js +5 -0
- package/dist/modules/css/index.js.map +1 -0
- package/dist/modules/document/CssVariable.d.ts +46 -0
- package/dist/modules/document/CssVariable.d.ts.map +1 -0
- package/dist/modules/document/CssVariable.js +47 -0
- package/dist/modules/document/CssVariable.js.map +1 -0
- package/dist/modules/document/Document.d.ts +43 -0
- package/dist/modules/document/Document.d.ts.map +1 -0
- package/dist/modules/document/Document.js +86 -0
- package/dist/modules/document/Document.js.map +1 -0
- package/dist/modules/document/DocumentEditor.d.ts +111 -0
- package/dist/modules/document/DocumentEditor.d.ts.map +1 -0
- package/dist/modules/document/DocumentEditor.js +555 -0
- package/dist/modules/document/DocumentEditor.js.map +1 -0
- package/dist/modules/document/Letter.d.ts +17 -0
- package/dist/modules/document/Letter.d.ts.map +1 -0
- package/dist/modules/document/Letter.js +17 -0
- package/dist/modules/document/Letter.js.map +1 -0
- package/dist/modules/document/Line.d.ts +31 -0
- package/dist/modules/document/Line.d.ts.map +1 -0
- package/dist/modules/document/Line.js +94 -0
- package/dist/modules/document/Line.js.map +1 -0
- package/dist/modules/document/LineState.d.ts +6 -0
- package/dist/modules/document/LineState.d.ts.map +1 -0
- package/dist/modules/document/LineState.js +7 -0
- package/dist/modules/document/LineState.js.map +1 -0
- package/dist/modules/document/NarrationPace.d.ts +20 -0
- package/dist/modules/document/NarrationPace.d.ts.map +1 -0
- package/dist/modules/document/NarrationPace.js +60 -0
- package/dist/modules/document/NarrationPace.js.map +1 -0
- package/dist/modules/document/Section.d.ts +45 -0
- package/dist/modules/document/Section.d.ts.map +1 -0
- package/dist/modules/document/Section.js +94 -0
- package/dist/modules/document/Section.js.map +1 -0
- package/dist/modules/document/Segment.d.ts +40 -0
- package/dist/modules/document/Segment.d.ts.map +1 -0
- package/dist/modules/document/Segment.js +85 -0
- package/dist/modules/document/Segment.js.map +1 -0
- package/dist/modules/document/Tag.d.ts +24 -0
- package/dist/modules/document/Tag.d.ts.map +1 -0
- package/dist/modules/document/Tag.js +37 -0
- package/dist/modules/document/Tag.js.map +1 -0
- package/dist/modules/document/TimeFragment.d.ts +11 -0
- package/dist/modules/document/TimeFragment.d.ts.map +1 -0
- package/dist/modules/document/TimeFragment.js +29 -0
- package/dist/modules/document/TimeFragment.js.map +1 -0
- package/dist/modules/document/Word.d.ts +40 -0
- package/dist/modules/document/Word.d.ts.map +1 -0
- package/dist/modules/document/Word.js +114 -0
- package/dist/modules/document/Word.js.map +1 -0
- package/dist/modules/document/WordState.d.ts +6 -0
- package/dist/modules/document/WordState.d.ts.map +1 -0
- package/dist/modules/document/WordState.js +7 -0
- package/dist/modules/document/WordState.js.map +1 -0
- package/dist/modules/document/index.d.ts +14 -0
- package/dist/modules/document/index.d.ts.map +1 -0
- package/dist/modules/document/index.js +14 -0
- package/dist/modules/document/index.js.map +1 -0
- package/dist/modules/effect/CarryQuotesEffect.d.ts +47 -0
- package/dist/modules/effect/CarryQuotesEffect.d.ts.map +1 -0
- package/dist/modules/effect/CarryQuotesEffect.js +181 -0
- package/dist/modules/effect/CarryQuotesEffect.js.map +1 -0
- package/dist/modules/effect/Effect.d.ts +16 -0
- package/dist/modules/effect/Effect.d.ts.map +1 -0
- package/dist/modules/effect/Effect.js +2 -0
- package/dist/modules/effect/Effect.js.map +1 -0
- package/dist/modules/effect/GapFreeEffect.d.ts +24 -0
- package/dist/modules/effect/GapFreeEffect.d.ts.map +1 -0
- package/dist/modules/effect/GapFreeEffect.js +67 -0
- package/dist/modules/effect/GapFreeEffect.js.map +1 -0
- package/dist/modules/effect/RemovePunctuationEffect.d.ts +21 -0
- package/dist/modules/effect/RemovePunctuationEffect.d.ts.map +1 -0
- package/dist/modules/effect/RemovePunctuationEffect.js +52 -0
- package/dist/modules/effect/RemovePunctuationEffect.js.map +1 -0
- package/dist/modules/effect/SmartLowercaseEffect.d.ts +21 -0
- package/dist/modules/effect/SmartLowercaseEffect.d.ts.map +1 -0
- package/dist/modules/effect/SmartLowercaseEffect.js +45 -0
- package/dist/modules/effect/SmartLowercaseEffect.js.map +1 -0
- package/dist/modules/effect/SmartPunctuationEffect.d.ts +25 -0
- package/dist/modules/effect/SmartPunctuationEffect.d.ts.map +1 -0
- package/dist/modules/effect/SmartPunctuationEffect.js +68 -0
- package/dist/modules/effect/SmartPunctuationEffect.js.map +1 -0
- package/dist/modules/effect/index.d.ts +7 -0
- package/dist/modules/effect/index.d.ts.map +1 -0
- package/dist/modules/effect/index.js +6 -0
- package/dist/modules/effect/index.js.map +1 -0
- package/dist/modules/pipeline/PipelineProgress.d.ts +30 -0
- package/dist/modules/pipeline/PipelineProgress.d.ts.map +1 -0
- package/dist/modules/pipeline/PipelineProgress.js +2 -0
- package/dist/modules/pipeline/PipelineProgress.js.map +1 -0
- package/dist/modules/pipeline/RenderPipeline.d.ts +105 -0
- package/dist/modules/pipeline/RenderPipeline.d.ts.map +1 -0
- package/dist/modules/pipeline/RenderPipeline.js +232 -0
- package/dist/modules/pipeline/RenderPipeline.js.map +1 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.d.ts +143 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.d.ts.map +1 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.js +317 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -0
- package/dist/modules/pipeline/index.d.ts +6 -0
- package/dist/modules/pipeline/index.d.ts.map +1 -0
- package/dist/modules/pipeline/index.js +3 -0
- package/dist/modules/pipeline/index.js.map +1 -0
- package/dist/modules/profiling/Profiler.d.ts +115 -0
- package/dist/modules/profiling/Profiler.d.ts.map +1 -0
- package/dist/modules/profiling/Profiler.js +316 -0
- package/dist/modules/profiling/Profiler.js.map +1 -0
- package/dist/modules/profiling/index.d.ts +2 -0
- package/dist/modules/profiling/index.d.ts.map +1 -0
- package/dist/modules/profiling/index.js +2 -0
- package/dist/modules/profiling/index.js.map +1 -0
- package/dist/modules/rendering/AlignmentConfig.d.ts +21 -0
- package/dist/modules/rendering/AlignmentConfig.d.ts.map +1 -0
- package/dist/modules/rendering/AlignmentConfig.js +2 -0
- package/dist/modules/rendering/AlignmentConfig.js.map +1 -0
- package/dist/modules/rendering/BoxEdges.d.ts +8 -0
- package/dist/modules/rendering/BoxEdges.d.ts.map +1 -0
- package/dist/modules/rendering/BoxEdges.js +2 -0
- package/dist/modules/rendering/BoxEdges.js.map +1 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts +12 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.js +31 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts +57 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +775 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/ElementRenderOverrides.d.ts +15 -0
- package/dist/modules/rendering/ElementRenderOverrides.d.ts.map +1 -0
- package/dist/modules/rendering/ElementRenderOverrides.js +24 -0
- package/dist/modules/rendering/ElementRenderOverrides.js.map +1 -0
- package/dist/modules/rendering/InlineStyleMap.d.ts +9 -0
- package/dist/modules/rendering/InlineStyleMap.d.ts.map +1 -0
- package/dist/modules/rendering/InlineStyleMap.js +2 -0
- package/dist/modules/rendering/InlineStyleMap.js.map +1 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.d.ts +20 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.d.ts.map +1 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.js +36 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.js.map +1 -0
- package/dist/modules/rendering/OverlayFrameRenderer.d.ts +27 -0
- package/dist/modules/rendering/OverlayFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/OverlayFrameRenderer.js +2 -0
- package/dist/modules/rendering/OverlayFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/RenderingConfig.d.ts +22 -0
- package/dist/modules/rendering/RenderingConfig.d.ts.map +1 -0
- package/dist/modules/rendering/RenderingConfig.js +2 -0
- package/dist/modules/rendering/RenderingConfig.js.map +1 -0
- package/dist/modules/rendering/ScopedRenderOverride.d.ts +19 -0
- package/dist/modules/rendering/ScopedRenderOverride.d.ts.map +1 -0
- package/dist/modules/rendering/ScopedRenderOverride.js +2 -0
- package/dist/modules/rendering/ScopedRenderOverride.js.map +1 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts +41 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts.map +1 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.js +47 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.js.map +1 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts +58 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts.map +1 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js +132 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js.map +1 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +111 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.js +2 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/VideoFrameLayerClass.d.ts +21 -0
- package/dist/modules/rendering/VideoFrameLayerClass.d.ts.map +1 -0
- package/dist/modules/rendering/VideoFrameLayerClass.js +21 -0
- package/dist/modules/rendering/VideoFrameLayerClass.js.map +1 -0
- package/dist/modules/rendering/VideoFrameSource.d.ts +29 -0
- package/dist/modules/rendering/VideoFrameSource.d.ts.map +1 -0
- package/dist/modules/rendering/VideoFrameSource.js +2 -0
- package/dist/modules/rendering/VideoFrameSource.js.map +1 -0
- package/dist/modules/rendering/index.d.ts +14 -0
- package/dist/modules/rendering/index.d.ts.map +1 -0
- package/dist/modules/rendering/index.js +6 -0
- package/dist/modules/rendering/index.js.map +1 -0
- package/dist/modules/splitting/BalancedLineSplitter.d.ts +24 -0
- package/dist/modules/splitting/BalancedLineSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/BalancedLineSplitter.js +81 -0
- package/dist/modules/splitting/BalancedLineSplitter.js.map +1 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts +31 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js +99 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js.map +1 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.d.ts +19 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.js +38 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.d.ts +8 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.js +12 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts +56 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts.map +1 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js +197 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js.map +1 -0
- package/dist/modules/splitting/GraphemeWordSplitter.d.ts +11 -0
- package/dist/modules/splitting/GraphemeWordSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/GraphemeWordSplitter.js +12 -0
- package/dist/modules/splitting/GraphemeWordSplitter.js.map +1 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts +15 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.js +64 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts +30 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js +66 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts +12 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.js +25 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/LineSplitter.d.ts +10 -0
- package/dist/modules/splitting/LineSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LineSplitter.js +2 -0
- package/dist/modules/splitting/LineSplitter.js.map +1 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts +24 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.js +43 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/SegmentSplitter.d.ts +10 -0
- package/dist/modules/splitting/SegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/SegmentSplitter.js +2 -0
- package/dist/modules/splitting/SegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts +17 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js +46 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/TextMeasurer.d.ts +15 -0
- package/dist/modules/splitting/TextMeasurer.d.ts.map +1 -0
- package/dist/modules/splitting/TextMeasurer.js +2 -0
- package/dist/modules/splitting/TextMeasurer.js.map +1 -0
- package/dist/modules/splitting/WordSplitter.d.ts +8 -0
- package/dist/modules/splitting/WordSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/WordSplitter.js +2 -0
- package/dist/modules/splitting/WordSplitter.js.map +1 -0
- package/dist/modules/splitting/index.d.ts +24 -0
- package/dist/modules/splitting/index.d.ts.map +1 -0
- package/dist/modules/splitting/index.js +12 -0
- package/dist/modules/splitting/index.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilter.d.ts +16 -0
- package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilter.js +28 -0
- package/dist/modules/svg-filter/SvgFilter.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterBundle.d.ts +16 -0
- package/dist/modules/svg-filter/SvgFilterBundle.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterBundle.js +20 -0
- package/dist/modules/svg-filter/SvgFilterBundle.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts +16 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.js +25 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts +21 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js +50 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts +17 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.js +27 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScope.d.ts +18 -0
- package/dist/modules/svg-filter/SvgFilterScope.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScope.js +28 -0
- package/dist/modules/svg-filter/SvgFilterScope.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts +52 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.js +2 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScoper.d.ts +60 -0
- package/dist/modules/svg-filter/SvgFilterScoper.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScoper.js +58 -0
- package/dist/modules/svg-filter/SvgFilterScoper.js.map +1 -0
- package/dist/modules/svg-filter/index.d.ts +10 -0
- package/dist/modules/svg-filter/index.d.ts.map +1 -0
- package/dist/modules/svg-filter/index.js +8 -0
- package/dist/modules/svg-filter/index.js.map +1 -0
- package/dist/modules/tagging/RegexTagger.d.ts +11 -0
- package/dist/modules/tagging/RegexTagger.d.ts.map +1 -0
- package/dist/modules/tagging/RegexTagger.js +32 -0
- package/dist/modules/tagging/RegexTagger.js.map +1 -0
- package/dist/modules/tagging/SpanTagger.d.ts +25 -0
- package/dist/modules/tagging/SpanTagger.d.ts.map +1 -0
- package/dist/modules/tagging/SpanTagger.js +73 -0
- package/dist/modules/tagging/SpanTagger.js.map +1 -0
- package/dist/modules/tagging/StructureTagger.d.ts +20 -0
- package/dist/modules/tagging/StructureTagger.d.ts.map +1 -0
- package/dist/modules/tagging/StructureTagger.js +74 -0
- package/dist/modules/tagging/StructureTagger.js.map +1 -0
- package/dist/modules/tagging/Tagger.d.ts +5 -0
- package/dist/modules/tagging/Tagger.d.ts.map +1 -0
- package/dist/modules/tagging/Tagger.js +5 -0
- package/dist/modules/tagging/Tagger.js.map +1 -0
- package/dist/modules/tagging/WordlistTagger.d.ts +11 -0
- package/dist/modules/tagging/WordlistTagger.d.ts.map +1 -0
- package/dist/modules/tagging/WordlistTagger.js +31 -0
- package/dist/modules/tagging/WordlistTagger.js.map +1 -0
- package/dist/modules/tagging/index.d.ts +6 -0
- package/dist/modules/tagging/index.d.ts.map +1 -0
- package/dist/modules/tagging/index.js +6 -0
- package/dist/modules/tagging/index.js.map +1 -0
- package/dist/modules/transcription/AudioDecoder.d.ts +11 -0
- package/dist/modules/transcription/AudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/AudioDecoder.js +2 -0
- package/dist/modules/transcription/AudioDecoder.js.map +1 -0
- package/dist/modules/transcription/BrowserAudioDecoder.d.ts +13 -0
- package/dist/modules/transcription/BrowserAudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/BrowserAudioDecoder.js +34 -0
- package/dist/modules/transcription/BrowserAudioDecoder.js.map +1 -0
- package/dist/modules/transcription/PassthroughTranscriber.d.ts +20 -0
- package/dist/modules/transcription/PassthroughTranscriber.d.ts.map +1 -0
- package/dist/modules/transcription/PassthroughTranscriber.js +23 -0
- package/dist/modules/transcription/PassthroughTranscriber.js.map +1 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts +12 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.js +14 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.js.map +1 -0
- package/dist/modules/transcription/SrtTranscriber.d.ts +33 -0
- package/dist/modules/transcription/SrtTranscriber.d.ts.map +1 -0
- package/dist/modules/transcription/SrtTranscriber.js +111 -0
- package/dist/modules/transcription/SrtTranscriber.js.map +1 -0
- package/dist/modules/transcription/Transcriber.d.ts +23 -0
- package/dist/modules/transcription/Transcriber.d.ts.map +1 -0
- package/dist/modules/transcription/Transcriber.js +2 -0
- package/dist/modules/transcription/Transcriber.js.map +1 -0
- package/dist/modules/transcription/WhisperTranscriber.d.ts +44 -0
- package/dist/modules/transcription/WhisperTranscriber.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperTranscriber.js +162 -0
- package/dist/modules/transcription/WhisperTranscriber.js.map +1 -0
- package/dist/modules/transcription/index.d.ts +8 -0
- package/dist/modules/transcription/index.d.ts.map +1 -0
- package/dist/modules/transcription/index.js +6 -0
- package/dist/modules/transcription/index.js.map +1 -0
- package/dist/modules/video/RenderJob.d.ts +95 -0
- package/dist/modules/video/RenderJob.d.ts.map +1 -0
- package/dist/modules/video/RenderJob.js +2 -0
- package/dist/modules/video/RenderJob.js.map +1 -0
- package/dist/modules/video/VideoRenderer.d.ts +5 -0
- package/dist/modules/video/VideoRenderer.d.ts.map +1 -0
- package/dist/modules/video/VideoRenderer.js +2 -0
- package/dist/modules/video/VideoRenderer.js.map +1 -0
- package/dist/modules/video/index.d.ts +33 -0
- package/dist/modules/video/index.d.ts.map +1 -0
- package/dist/modules/video/index.js +17 -0
- package/dist/modules/video/index.js.map +1 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts +69 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js +206 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts +24 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js +2 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts +20 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js +2 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts +11 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js +32 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts +12 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js +14 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts +28 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js +52 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts +25 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js +52 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts +32 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js +60 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts +27 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js +72 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts +32 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js +2 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts +25 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js +37 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts +32 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.js +2 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.js.map +1 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts +59 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js +110 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts +27 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js +44 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts +10 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js +15 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts +29 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js +2 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts +16 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js +2 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +25 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +74 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts +26 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js +147 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts +12 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js +25 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts +30 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.js +2 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts +44 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js +334 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts +10 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js +17 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts +30 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js +2 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts +22 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js +2 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts +17 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js +48 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts +11 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js +22 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js.map +1 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts +27 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js +2 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CodecPolicy, VideoCodecResolution, VideoCodecResolutionRequest } from '../../../video/mediabunny/codec/CodecPolicy';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the video codec and encoder knobs for a render using a tiered
|
|
4
|
+
* approach: a baseline bitrate driven by output resolution, scaled by the
|
|
5
|
+
* codec's relative encoding efficiency, then scaled again by the chosen
|
|
6
|
+
* quality preset.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DefaultCodecPolicy implements CodecPolicy {
|
|
9
|
+
/**
|
|
10
|
+
* Linear scale applied to the base bitrate per quality preset. `high` is
|
|
11
|
+
* the reference (1.0); the other values are deliberate, not derived from
|
|
12
|
+
* a benchmark. They exist to give the caller a coarse knob to trade off
|
|
13
|
+
* file size against fidelity.
|
|
14
|
+
*/
|
|
15
|
+
private static readonly QUALITY_FACTORS;
|
|
16
|
+
/**
|
|
17
|
+
* Relative bitrate needed by each codec to reach an equivalent perceptual
|
|
18
|
+
* quality, with AVC/H.264 as the 1.0 reference.
|
|
19
|
+
*
|
|
20
|
+
* Numbers mirror mediabunny's own internal `codecEfficiencyFactors`
|
|
21
|
+
* table (see `mediabunny/dist/modules/src/encode.js`), which in turn
|
|
22
|
+
* follows widely-cited industry benchmarks: HEVC and VP9 deliver roughly
|
|
23
|
+
* 40-50% bitrate savings over AVC (Bossen et al., HEVC Performance
|
|
24
|
+
* Comparison, JCTVC-L1003), and AV1 around 30% over HEVC according to
|
|
25
|
+
* Google's and Netflix's AV1 testing.
|
|
26
|
+
*/
|
|
27
|
+
private static readonly CODEC_EFFICIENCY;
|
|
28
|
+
resolveVideo(request: VideoCodecResolutionRequest): Promise<VideoCodecResolution>;
|
|
29
|
+
private computeBitrate;
|
|
30
|
+
/**
|
|
31
|
+
* Baseline AVC bitrate in bits per second for the 30 fps SDR reference
|
|
32
|
+
* of the given pixel area. Tiers track YouTube's recommended upload
|
|
33
|
+
* bitrates for SDR 30 fps content, with a small headroom bump since
|
|
34
|
+
* burned subtitles need extra bits to preserve text legibility:
|
|
35
|
+
*
|
|
36
|
+
* YouTube recommendation: ours:
|
|
37
|
+
* 720p ~5 Mbps 6 Mbps
|
|
38
|
+
* 1080p ~8 Mbps 12 Mbps
|
|
39
|
+
* 1440p ~16 Mbps 18 Mbps
|
|
40
|
+
* 2160p ~35-45 Mbps 40 Mbps
|
|
41
|
+
*
|
|
42
|
+
* Source: https://support.google.com/youtube/answer/1722171
|
|
43
|
+
* (Recommended upload encoding settings → Bitrate.)
|
|
44
|
+
*/
|
|
45
|
+
private baselineBitrate;
|
|
46
|
+
/**
|
|
47
|
+
* Linear scale that turns the 30 fps baseline into the matching budget
|
|
48
|
+
* for the actual frame rate. YouTube's tables show ~×1.5 between 30 fps
|
|
49
|
+
* and 60 fps SDR at every resolution; the mapping below reproduces that
|
|
50
|
+
* ratio and degrades gracefully past 60 fps.
|
|
51
|
+
*
|
|
52
|
+
* fps ≤ 30: ×1.0
|
|
53
|
+
* fps = 45: ×1.25
|
|
54
|
+
* fps = 60: ×1.5
|
|
55
|
+
* fps = 120: ×2.5
|
|
56
|
+
*/
|
|
57
|
+
private fpsFactor;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=DefaultCodecPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultCodecPolicy.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/codec/DefaultCodecPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,6CAA6C,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IAEpD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAKrC;IAEF;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAMtC;IAEI,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAyBvF,OAAO,CAAC,cAAc;IActB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,eAAe;IAQvB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,SAAS;CAIlB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { getFirstEncodableVideoCodec } from 'mediabunny';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the video codec and encoder knobs for a render using a tiered
|
|
4
|
+
* approach: a baseline bitrate driven by output resolution, scaled by the
|
|
5
|
+
* codec's relative encoding efficiency, then scaled again by the chosen
|
|
6
|
+
* quality preset.
|
|
7
|
+
*/
|
|
8
|
+
export class DefaultCodecPolicy {
|
|
9
|
+
/**
|
|
10
|
+
* Linear scale applied to the base bitrate per quality preset. `high` is
|
|
11
|
+
* the reference (1.0); the other values are deliberate, not derived from
|
|
12
|
+
* a benchmark. They exist to give the caller a coarse knob to trade off
|
|
13
|
+
* file size against fidelity.
|
|
14
|
+
*/
|
|
15
|
+
static QUALITY_FACTORS = {
|
|
16
|
+
low: 0.5,
|
|
17
|
+
medium: 0.75,
|
|
18
|
+
high: 1.0,
|
|
19
|
+
'very-high': 1.5,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Relative bitrate needed by each codec to reach an equivalent perceptual
|
|
23
|
+
* quality, with AVC/H.264 as the 1.0 reference.
|
|
24
|
+
*
|
|
25
|
+
* Numbers mirror mediabunny's own internal `codecEfficiencyFactors`
|
|
26
|
+
* table (see `mediabunny/dist/modules/src/encode.js`), which in turn
|
|
27
|
+
* follows widely-cited industry benchmarks: HEVC and VP9 deliver roughly
|
|
28
|
+
* 40-50% bitrate savings over AVC (Bossen et al., HEVC Performance
|
|
29
|
+
* Comparison, JCTVC-L1003), and AV1 around 30% over HEVC according to
|
|
30
|
+
* Google's and Netflix's AV1 testing.
|
|
31
|
+
*/
|
|
32
|
+
static CODEC_EFFICIENCY = {
|
|
33
|
+
avc: 1.0,
|
|
34
|
+
hevc: 0.6,
|
|
35
|
+
vp9: 0.6,
|
|
36
|
+
av1: 0.4,
|
|
37
|
+
vp8: 1.2,
|
|
38
|
+
};
|
|
39
|
+
async resolveVideo(request) {
|
|
40
|
+
const codec = await getFirstEncodableVideoCodec(request.supportedCodecs, {
|
|
41
|
+
width: request.width,
|
|
42
|
+
height: request.height,
|
|
43
|
+
});
|
|
44
|
+
if (!codec) {
|
|
45
|
+
throw new Error('No video encoder available in this browser for the selected output format. ' +
|
|
46
|
+
'Try a different format or use a more recent version of Chrome, Firefox or Safari.');
|
|
47
|
+
}
|
|
48
|
+
const bitrate = this.computeBitrate(codec, request.width, request.height, request.fps, request.quality);
|
|
49
|
+
return {
|
|
50
|
+
codec,
|
|
51
|
+
bitrate,
|
|
52
|
+
bitrateMode: 'variable',
|
|
53
|
+
latencyMode: 'quality',
|
|
54
|
+
// High-contrast text overlays benefit from the encoder spending more
|
|
55
|
+
// bits on edge regions. Encoders that don't recognize this hint
|
|
56
|
+
// (currently Firefox and Safari for most codecs) ignore it harmlessly.
|
|
57
|
+
// See https://w3c.github.io/mst-content-hint/#video-content-hints
|
|
58
|
+
contentHint: 'text',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
computeBitrate(codec, width, height, fps, quality) {
|
|
62
|
+
const baseline = this.baselineBitrate(width, height);
|
|
63
|
+
const codecFactor = DefaultCodecPolicy.CODEC_EFFICIENCY[codec] ?? 1.0;
|
|
64
|
+
const qualityFactor = DefaultCodecPolicy.QUALITY_FACTORS[quality ?? 'high'];
|
|
65
|
+
const fpsFactor = this.fpsFactor(fps);
|
|
66
|
+
return Math.round(baseline * codecFactor * qualityFactor * fpsFactor);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Baseline AVC bitrate in bits per second for the 30 fps SDR reference
|
|
70
|
+
* of the given pixel area. Tiers track YouTube's recommended upload
|
|
71
|
+
* bitrates for SDR 30 fps content, with a small headroom bump since
|
|
72
|
+
* burned subtitles need extra bits to preserve text legibility:
|
|
73
|
+
*
|
|
74
|
+
* YouTube recommendation: ours:
|
|
75
|
+
* 720p ~5 Mbps 6 Mbps
|
|
76
|
+
* 1080p ~8 Mbps 12 Mbps
|
|
77
|
+
* 1440p ~16 Mbps 18 Mbps
|
|
78
|
+
* 2160p ~35-45 Mbps 40 Mbps
|
|
79
|
+
*
|
|
80
|
+
* Source: https://support.google.com/youtube/answer/1722171
|
|
81
|
+
* (Recommended upload encoding settings → Bitrate.)
|
|
82
|
+
*/
|
|
83
|
+
baselineBitrate(width, height) {
|
|
84
|
+
const pixels = width * height;
|
|
85
|
+
if (pixels <= 1280 * 720)
|
|
86
|
+
return 6_000_000;
|
|
87
|
+
if (pixels <= 1920 * 1080)
|
|
88
|
+
return 12_000_000;
|
|
89
|
+
if (pixels <= 2560 * 1440)
|
|
90
|
+
return 18_000_000;
|
|
91
|
+
return 40_000_000;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Linear scale that turns the 30 fps baseline into the matching budget
|
|
95
|
+
* for the actual frame rate. YouTube's tables show ~×1.5 between 30 fps
|
|
96
|
+
* and 60 fps SDR at every resolution; the mapping below reproduces that
|
|
97
|
+
* ratio and degrades gracefully past 60 fps.
|
|
98
|
+
*
|
|
99
|
+
* fps ≤ 30: ×1.0
|
|
100
|
+
* fps = 45: ×1.25
|
|
101
|
+
* fps = 60: ×1.5
|
|
102
|
+
* fps = 120: ×2.5
|
|
103
|
+
*/
|
|
104
|
+
fpsFactor(fps) {
|
|
105
|
+
if (!Number.isFinite(fps) || fps <= 30)
|
|
106
|
+
return 1;
|
|
107
|
+
return 1 + (fps - 30) / 60;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=DefaultCodecPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultCodecPolicy.js","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/codec/DefaultCodecPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAmB,MAAM,YAAY,CAAC;AAQ1E;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAE7B;;;;;OAKG;IACK,MAAM,CAAU,eAAe,GAAkC;QACvE,GAAG,EAAE,GAAG;QACR,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,GAAG;KACjB,CAAC;IAEF;;;;;;;;;;OAUG;IACK,MAAM,CAAU,gBAAgB,GAA2B;QACjE,GAAG,EAAE,GAAG;QACR,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;KACT,CAAC;IAEF,KAAK,CAAC,YAAY,CAAC,OAAoC;QACrD,MAAM,KAAK,GAAG,MAAM,2BAA2B,CAAC,OAAO,CAAC,eAAe,EAAE;YACvE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACb,6EAA6E;gBAC3E,mFAAmF,CACtF,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACxG,OAAO;YACL,KAAK;YACL,OAAO;YACP,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,SAAS;YACtB,qEAAqE;YACrE,gEAAgE;YAChE,uEAAuE;YACvE,kEAAkE;YAClE,WAAW,EAAE,MAAM;SACpB,CAAC;IACJ,CAAC;IAEO,cAAc,CACpB,KAAiB,EACjB,KAAa,EACb,MAAc,EACd,GAAW,EACX,OAAkC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC;QACtE,MAAM,aAAa,GAAG,kBAAkB,CAAC,eAAe,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC;QAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACK,eAAe,CAAC,KAAa,EAAE,MAAc;QACnD,MAAM,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;QAC9B,IAAI,MAAM,IAAI,IAAI,GAAG,GAAG;YAAE,OAAO,SAAS,CAAC;QAC3C,IAAI,MAAM,IAAI,IAAI,GAAG,IAAI;YAAE,OAAO,UAAU,CAAC;QAC7C,IAAI,MAAM,IAAI,IAAI,GAAG,IAAI;YAAE,OAAO,UAAU,CAAC;QAC7C,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACK,SAAS,CAAC,GAAW;QAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE;YAAE,OAAO,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Output, type VideoEncodingConfig } from 'mediabunny';
|
|
2
|
+
import type { PaintFrame, VideoTrackEncoder } from '../../../video/mediabunny/encoder/VideoTrackEncoder';
|
|
3
|
+
export interface MediaBunnyCanvasVideoTrackEncoderConfig {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
encoderConfig: VideoEncodingConfig;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Owns an {@link OffscreenCanvas} sized to the output, a high-quality 2D
|
|
10
|
+
* context, and a {@link CanvasSource} that snapshots the canvas on each
|
|
11
|
+
* {@link encode} call and pushes the result into the output's encoder
|
|
12
|
+
* pipeline.
|
|
13
|
+
*
|
|
14
|
+
* Hides the canvas: callers paint through the {@link PaintFrame} callback
|
|
15
|
+
* passed to `encode`, never against the underlying surface directly.
|
|
16
|
+
*/
|
|
17
|
+
export declare class MediaBunnyCanvasVideoTrackEncoder implements VideoTrackEncoder {
|
|
18
|
+
readonly width: number;
|
|
19
|
+
readonly height: number;
|
|
20
|
+
private readonly canvas;
|
|
21
|
+
private readonly context;
|
|
22
|
+
private readonly canvasSource;
|
|
23
|
+
constructor(config: MediaBunnyCanvasVideoTrackEncoderConfig);
|
|
24
|
+
attachTo(output: Output): void;
|
|
25
|
+
encode(timestamp: number, duration: number, paint: PaintFrame): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=MediaBunnyCanvasVideoTrackEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaBunnyCanvasVideoTrackEncoder.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAClB,MAAM,qDAAqD,CAAC;AAE7D,MAAM,WAAW,uCAAuC;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,mBAAmB,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,qBAAa,iCAAkC,YAAW,iBAAiB;IAEzE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;gBAEhC,MAAM,EAAE,uCAAuC;IAoB3D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIxB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAIpF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CanvasSource } from 'mediabunny';
|
|
2
|
+
/**
|
|
3
|
+
* Owns an {@link OffscreenCanvas} sized to the output, a high-quality 2D
|
|
4
|
+
* context, and a {@link CanvasSource} that snapshots the canvas on each
|
|
5
|
+
* {@link encode} call and pushes the result into the output's encoder
|
|
6
|
+
* pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Hides the canvas: callers paint through the {@link PaintFrame} callback
|
|
9
|
+
* passed to `encode`, never against the underlying surface directly.
|
|
10
|
+
*/
|
|
11
|
+
export class MediaBunnyCanvasVideoTrackEncoder {
|
|
12
|
+
width;
|
|
13
|
+
height;
|
|
14
|
+
canvas;
|
|
15
|
+
context;
|
|
16
|
+
canvasSource;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.width = config.width;
|
|
19
|
+
this.height = config.height;
|
|
20
|
+
this.canvas = new OffscreenCanvas(config.width, config.height);
|
|
21
|
+
// alpha:false — the compositor paints an opaque source frame first;
|
|
22
|
+
// imageSmoothingEnabled:false — compositor always draws at native
|
|
23
|
+
// size, so smoothing is a pure no-op cost.
|
|
24
|
+
const ctx = this.canvas.getContext('2d', {
|
|
25
|
+
alpha: false,
|
|
26
|
+
desynchronized: false,
|
|
27
|
+
willReadFrequently: false,
|
|
28
|
+
});
|
|
29
|
+
if (!ctx) {
|
|
30
|
+
throw new Error('Unable to acquire a 2D context on the offscreen canvas');
|
|
31
|
+
}
|
|
32
|
+
ctx.imageSmoothingEnabled = false;
|
|
33
|
+
this.context = ctx;
|
|
34
|
+
this.canvasSource = new CanvasSource(this.canvas, config.encoderConfig);
|
|
35
|
+
}
|
|
36
|
+
attachTo(output) {
|
|
37
|
+
output.addVideoTrack(this.canvasSource);
|
|
38
|
+
}
|
|
39
|
+
async encode(timestamp, duration, paint) {
|
|
40
|
+
paint(this.context);
|
|
41
|
+
await this.canvasSource.add(timestamp, duration);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=MediaBunnyCanvasVideoTrackEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaBunnyCanvasVideoTrackEncoder.js","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyC,MAAM,YAAY,CAAC;AAYjF;;;;;;;;GAQG;AACH,MAAM,OAAO,iCAAiC;IAEnC,KAAK,CAAS;IACd,MAAM,CAAS;IAEP,MAAM,CAAkB;IACxB,OAAO,CAAoC;IAC3C,YAAY,CAAe;IAE5C,YAAY,MAA+C;QACzD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/D,oEAAoE;QACpE,kEAAkE;QAClE,2CAA2C;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;YACvC,KAAK,EAAE,KAAK;YACZ,cAAc,EAAE,KAAK;YACrB,kBAAkB,EAAE,KAAK;SAC1B,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QACD,GAAG,CAAC,qBAAqB,GAAG,KAAK,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC1E,CAAC;IAED,QAAQ,CAAC,MAAc;QACrB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,QAAgB,EAAE,KAAiB;QACjE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VideoTrackEncoder } from '../../../video/mediabunny/encoder/VideoTrackEncoder';
|
|
2
|
+
import type { VideoTrackEncoderFactory, VideoTrackEncoderFactoryRequest } from '../../../video/mediabunny/encoder/VideoTrackEncoderFactory';
|
|
3
|
+
/**
|
|
4
|
+
* Produces canvas-backed encoders that wrap mediabunny's
|
|
5
|
+
* {@link CanvasSource}.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MediaBunnyCanvasVideoTrackEncoderFactory implements VideoTrackEncoderFactory {
|
|
8
|
+
create(request: VideoTrackEncoderFactoryRequest): VideoTrackEncoder;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=MediaBunnyCanvasVideoTrackEncoderFactory.d.ts.map
|
package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaBunnyCanvasVideoTrackEncoderFactory.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAC7F,OAAO,KAAK,EACV,wBAAwB,EACxB,+BAA+B,EAChC,MAAM,4DAA4D,CAAC;AAEpE;;;GAGG;AACH,qBAAa,wCAAyC,YAAW,wBAAwB;IAEvF,MAAM,CAAC,OAAO,EAAE,+BAA+B,GAAG,iBAAiB;CAOpE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MediaBunnyCanvasVideoTrackEncoder } from '../../../video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder';
|
|
2
|
+
/**
|
|
3
|
+
* Produces canvas-backed encoders that wrap mediabunny's
|
|
4
|
+
* {@link CanvasSource}.
|
|
5
|
+
*/
|
|
6
|
+
export class MediaBunnyCanvasVideoTrackEncoderFactory {
|
|
7
|
+
create(request) {
|
|
8
|
+
return new MediaBunnyCanvasVideoTrackEncoder({
|
|
9
|
+
width: request.width,
|
|
10
|
+
height: request.height,
|
|
11
|
+
encoderConfig: request.encoderConfig,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MediaBunnyCanvasVideoTrackEncoderFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaBunnyCanvasVideoTrackEncoderFactory.js","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qEAAqE,CAAC;AAOxH;;;GAGG;AACH,MAAM,OAAO,wCAAwC;IAEnD,MAAM,CAAC,OAAwC;QAC7C,OAAO,IAAI,iCAAiC,CAAC;YAC3C,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,aAAa,EAAE,OAAO,CAAC,aAAa;SACrC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Output } from 'mediabunny';
|
|
2
|
+
/** Callback the encoder runs against its own 2D context on every frame. */
|
|
3
|
+
export type PaintFrame = (target: OffscreenCanvasRenderingContext2D) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Encodes successive frames into a mediabunny {@link Output}. The
|
|
6
|
+
* encoder owns its underlying surface and never exposes it; callers
|
|
7
|
+
* describe what to paint via the {@link PaintFrame} callback passed
|
|
8
|
+
* to {@link encode}.
|
|
9
|
+
*
|
|
10
|
+
* Output dimensions are fixed at construction time.
|
|
11
|
+
*/
|
|
12
|
+
export interface VideoTrackEncoder {
|
|
13
|
+
readonly width: number;
|
|
14
|
+
readonly height: number;
|
|
15
|
+
/**
|
|
16
|
+
* Wires the encoder's source into the output. Must be called once
|
|
17
|
+
* before the output is started.
|
|
18
|
+
*/
|
|
19
|
+
attachTo(output: Output): void;
|
|
20
|
+
/**
|
|
21
|
+
* Runs `paint` against the encoder's internal surface, snapshots the
|
|
22
|
+
* result, and queues it for encoding at the given presentation
|
|
23
|
+
* timestamp and duration (both in seconds). The returned promise
|
|
24
|
+
* resolves once the encoder is ready to receive the next frame —
|
|
25
|
+
* await it to honor backpressure.
|
|
26
|
+
*/
|
|
27
|
+
encode(timestamp: number, duration: number, paint: PaintFrame): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=VideoTrackEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoTrackEncoder.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/VideoTrackEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,iCAAiC,KAAK,IAAI,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoTrackEncoder.js","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/VideoTrackEncoder.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VideoEncodingConfig } from 'mediabunny';
|
|
2
|
+
import type { VideoTrackEncoder } from '../../../video/mediabunny/encoder/VideoTrackEncoder';
|
|
3
|
+
export interface VideoTrackEncoderFactoryRequest {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
encoderConfig: VideoEncodingConfig;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Builds a {@link VideoTrackEncoder} sized to the requested output. The
|
|
10
|
+
* renderer asks the factory for a fresh encoder per render, once the
|
|
11
|
+
* input dimensions and resolved codec config are known.
|
|
12
|
+
*/
|
|
13
|
+
export interface VideoTrackEncoderFactory {
|
|
14
|
+
create(request: VideoTrackEncoderFactoryRequest): VideoTrackEncoder;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=VideoTrackEncoderFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoTrackEncoderFactory.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAE7F,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,mBAAmB,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,OAAO,EAAE,+BAA+B,GAAG,iBAAiB,CAAC;CACrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoTrackEncoderFactory.js","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { VideoFrameSource, VideoFrameRegion } from '../../../rendering/VideoFrameSource';
|
|
2
|
+
import type { DecodedVideoFrame } from '../../../video/mediabunny/frame/VideoFrameDecoder';
|
|
3
|
+
/**
|
|
4
|
+
* Single-slot `VideoFrameSource`. {@link setCurrent} stores one
|
|
5
|
+
* decoded frame at a timestamp; {@link getFrameAt} serves only that
|
|
6
|
+
* frame and only at that same timestamp. Querying any other
|
|
7
|
+
* timestamp throws.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CurrentFrameVideoSource implements VideoFrameSource {
|
|
10
|
+
private static readonly TIMESTAMP_TOLERANCE_S;
|
|
11
|
+
private readonly canvas;
|
|
12
|
+
private readonly ctx;
|
|
13
|
+
private currentTimestamp;
|
|
14
|
+
constructor(width: number, height: number);
|
|
15
|
+
/**
|
|
16
|
+
* Stores `frame` as the only frame `getFrameAt` will serve until
|
|
17
|
+
* the next `setCurrent`, keyed on `timestamp`.
|
|
18
|
+
*/
|
|
19
|
+
setCurrent(timestamp: number, frame: DecodedVideoFrame): void;
|
|
20
|
+
getFrameAt(timeSeconds: number, jpegQuality: number, region?: VideoFrameRegion): Promise<string>;
|
|
21
|
+
private encode;
|
|
22
|
+
private clipToCanvas;
|
|
23
|
+
private blobToDataUrl;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CurrentFrameVideoSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentFrameVideoSource.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/frame/CurrentFrameVideoSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAG3F;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAI9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAQ;IAErD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoC;IACxD,OAAO,CAAC,gBAAgB,CAAuB;gBAEnC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASzC;;;OAGG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAOvD,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBtG,OAAO,CAAC,MAAM;IAqBd,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;CAQtB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { profiler } from '../../../profiling/Profiler';
|
|
2
|
+
/**
|
|
3
|
+
* Single-slot `VideoFrameSource`. {@link setCurrent} stores one
|
|
4
|
+
* decoded frame at a timestamp; {@link getFrameAt} serves only that
|
|
5
|
+
* frame and only at that same timestamp. Querying any other
|
|
6
|
+
* timestamp throws.
|
|
7
|
+
*/
|
|
8
|
+
export class CurrentFrameVideoSource {
|
|
9
|
+
// Any mismatch beyond IEEE-754 noise is a coordination bug between
|
|
10
|
+
// the producer and the subtitle renderer.
|
|
11
|
+
static TIMESTAMP_TOLERANCE_S = 1e-6;
|
|
12
|
+
canvas;
|
|
13
|
+
ctx;
|
|
14
|
+
currentTimestamp = null;
|
|
15
|
+
constructor(width, height) {
|
|
16
|
+
this.canvas = new OffscreenCanvas(width, height);
|
|
17
|
+
const ctx = this.canvas.getContext('2d');
|
|
18
|
+
if (!ctx) {
|
|
19
|
+
throw new Error('OffscreenCanvas 2D context is not available in this environment.');
|
|
20
|
+
}
|
|
21
|
+
this.ctx = ctx;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Stores `frame` as the only frame `getFrameAt` will serve until
|
|
25
|
+
* the next `setCurrent`, keyed on `timestamp`.
|
|
26
|
+
*/
|
|
27
|
+
setCurrent(timestamp, frame) {
|
|
28
|
+
this.currentTimestamp = timestamp;
|
|
29
|
+
profiler.time('CurrentFrameVideoSource.draw', () => frame.draw(this.ctx, 0, 0, this.canvas.width, this.canvas.height));
|
|
30
|
+
}
|
|
31
|
+
async getFrameAt(timeSeconds, jpegQuality, region) {
|
|
32
|
+
if (this.currentTimestamp === null) {
|
|
33
|
+
throw new Error('CurrentFrameVideoSource.getFrameAt called before any setCurrent.');
|
|
34
|
+
}
|
|
35
|
+
if (Math.abs(this.currentTimestamp - timeSeconds) > CurrentFrameVideoSource.TIMESTAMP_TOLERANCE_S) {
|
|
36
|
+
throw new Error(`CurrentFrameVideoSource: requested timestamp ${timeSeconds}, ` +
|
|
37
|
+
`but the current slot holds ${this.currentTimestamp}.`);
|
|
38
|
+
}
|
|
39
|
+
const blob = await profiler.time('CurrentFrameVideoSource.convertToBlob', () => this.encode(region, jpegQuality));
|
|
40
|
+
return profiler.time('CurrentFrameVideoSource.blobToDataUrl', () => this.blobToDataUrl(blob));
|
|
41
|
+
}
|
|
42
|
+
encode(region, jpegQuality) {
|
|
43
|
+
if (!region) {
|
|
44
|
+
return this.canvas.convertToBlob({ type: 'image/jpeg', quality: jpegQuality });
|
|
45
|
+
}
|
|
46
|
+
const clipped = this.clipToCanvas(region);
|
|
47
|
+
if (clipped.width === 0 || clipped.height === 0) {
|
|
48
|
+
return this.canvas.convertToBlob({ type: 'image/jpeg', quality: jpegQuality });
|
|
49
|
+
}
|
|
50
|
+
const cropCanvas = new OffscreenCanvas(clipped.width, clipped.height);
|
|
51
|
+
const cropCtx = cropCanvas.getContext('2d');
|
|
52
|
+
if (!cropCtx) {
|
|
53
|
+
throw new Error('OffscreenCanvas 2D context is not available for cropping.');
|
|
54
|
+
}
|
|
55
|
+
cropCtx.drawImage(this.canvas, clipped.x, clipped.y, clipped.width, clipped.height, 0, 0, clipped.width, clipped.height);
|
|
56
|
+
return cropCanvas.convertToBlob({ type: 'image/jpeg', quality: jpegQuality });
|
|
57
|
+
}
|
|
58
|
+
clipToCanvas(region) {
|
|
59
|
+
const x = Math.max(0, Math.floor(region.x));
|
|
60
|
+
const y = Math.max(0, Math.floor(region.y));
|
|
61
|
+
const right = Math.min(this.canvas.width, Math.ceil(region.x + region.width));
|
|
62
|
+
const bottom = Math.min(this.canvas.height, Math.ceil(region.y + region.height));
|
|
63
|
+
return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
|
|
64
|
+
}
|
|
65
|
+
blobToDataUrl(blob) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const reader = new FileReader();
|
|
68
|
+
reader.onload = () => resolve(reader.result);
|
|
69
|
+
reader.onerror = () => reject(reader.error ?? new Error('FileReader failed to encode the frame.'));
|
|
70
|
+
reader.readAsDataURL(blob);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=CurrentFrameVideoSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentFrameVideoSource.js","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/frame/CurrentFrameVideoSource.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type InputVideoTrack } from 'mediabunny';
|
|
2
|
+
import type { DecodedVideoFrame, VideoFrameDecoder } from '../../../video/mediabunny/frame/VideoFrameDecoder';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a WebCodecs {@link VideoDecoder} directly off mediabunny's
|
|
5
|
+
* {@link EncodedPacketSink}. Going through `VideoSampleSink` introduces
|
|
6
|
+
* a per-frame serialization that dominates render time on Firefox
|
|
7
|
+
* (where WebCodecs has noticeably higher per-call latency than
|
|
8
|
+
* Chromium); feeding the decoder ourselves lets the pipeline stay
|
|
9
|
+
* saturated while frames are reordered internally for presentation.
|
|
10
|
+
*
|
|
11
|
+
* Packets are fed in decode order; frames are yielded in presentation
|
|
12
|
+
* order — the WebCodecs `VideoDecoder` handles B-frame reordering on
|
|
13
|
+
* the output side.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CustomWebCodecsVideoFrameDecoder implements VideoFrameDecoder {
|
|
16
|
+
private readonly track;
|
|
17
|
+
private closed;
|
|
18
|
+
private decoder;
|
|
19
|
+
constructor(track: InputVideoTrack);
|
|
20
|
+
samples(): AsyncIterable<DecodedVideoFrame>;
|
|
21
|
+
close(): void;
|
|
22
|
+
private iterate;
|
|
23
|
+
private waitForDequeue;
|
|
24
|
+
private wrap;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=CustomWebCodecsVideoFrameDecoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomWebCodecsVideoFrameDecoder.d.ts","sourceRoot":"","sources":["../../../../../src/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAc9G;;;;;;;;;;;GAWG;AACH,qBAAa,gCAAiC,YAAW,iBAAiB;IAK5D,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA6B;gBAEf,KAAK,EAAE,eAAe;IAEnD,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC;IAM3C,KAAK,IAAI,IAAI;IAQb,OAAO,CAAC,OAAO;IA+Ef,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,IAAI;CAQb"}
|