@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.
Files changed (483) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +12 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/modules/css/BrowserCssResourceEmbedder.d.ts +5 -0
  8. package/dist/modules/css/BrowserCssResourceEmbedder.d.ts.map +1 -0
  9. package/dist/modules/css/BrowserCssResourceEmbedder.js +41 -0
  10. package/dist/modules/css/BrowserCssResourceEmbedder.js.map +1 -0
  11. package/dist/modules/css/CssMinifier.d.ts +12 -0
  12. package/dist/modules/css/CssMinifier.d.ts.map +1 -0
  13. package/dist/modules/css/CssMinifier.js +47 -0
  14. package/dist/modules/css/CssMinifier.js.map +1 -0
  15. package/dist/modules/css/CssResourceEmbedder.d.ts +4 -0
  16. package/dist/modules/css/CssResourceEmbedder.d.ts.map +1 -0
  17. package/dist/modules/css/CssResourceEmbedder.js +2 -0
  18. package/dist/modules/css/CssResourceEmbedder.js.map +1 -0
  19. package/dist/modules/css/CssScoper.d.ts +16 -0
  20. package/dist/modules/css/CssScoper.d.ts.map +1 -0
  21. package/dist/modules/css/CssScoper.js +109 -0
  22. package/dist/modules/css/CssScoper.js.map +1 -0
  23. package/dist/modules/css/NoopCssResourceEmbedder.d.ts +12 -0
  24. package/dist/modules/css/NoopCssResourceEmbedder.d.ts.map +1 -0
  25. package/dist/modules/css/NoopCssResourceEmbedder.js +13 -0
  26. package/dist/modules/css/NoopCssResourceEmbedder.js.map +1 -0
  27. package/dist/modules/css/index.d.ts +6 -0
  28. package/dist/modules/css/index.d.ts.map +1 -0
  29. package/dist/modules/css/index.js +5 -0
  30. package/dist/modules/css/index.js.map +1 -0
  31. package/dist/modules/document/CssVariable.d.ts +46 -0
  32. package/dist/modules/document/CssVariable.d.ts.map +1 -0
  33. package/dist/modules/document/CssVariable.js +47 -0
  34. package/dist/modules/document/CssVariable.js.map +1 -0
  35. package/dist/modules/document/Document.d.ts +43 -0
  36. package/dist/modules/document/Document.d.ts.map +1 -0
  37. package/dist/modules/document/Document.js +86 -0
  38. package/dist/modules/document/Document.js.map +1 -0
  39. package/dist/modules/document/DocumentEditor.d.ts +111 -0
  40. package/dist/modules/document/DocumentEditor.d.ts.map +1 -0
  41. package/dist/modules/document/DocumentEditor.js +555 -0
  42. package/dist/modules/document/DocumentEditor.js.map +1 -0
  43. package/dist/modules/document/Letter.d.ts +17 -0
  44. package/dist/modules/document/Letter.d.ts.map +1 -0
  45. package/dist/modules/document/Letter.js +17 -0
  46. package/dist/modules/document/Letter.js.map +1 -0
  47. package/dist/modules/document/Line.d.ts +31 -0
  48. package/dist/modules/document/Line.d.ts.map +1 -0
  49. package/dist/modules/document/Line.js +94 -0
  50. package/dist/modules/document/Line.js.map +1 -0
  51. package/dist/modules/document/LineState.d.ts +6 -0
  52. package/dist/modules/document/LineState.d.ts.map +1 -0
  53. package/dist/modules/document/LineState.js +7 -0
  54. package/dist/modules/document/LineState.js.map +1 -0
  55. package/dist/modules/document/NarrationPace.d.ts +20 -0
  56. package/dist/modules/document/NarrationPace.d.ts.map +1 -0
  57. package/dist/modules/document/NarrationPace.js +60 -0
  58. package/dist/modules/document/NarrationPace.js.map +1 -0
  59. package/dist/modules/document/Section.d.ts +45 -0
  60. package/dist/modules/document/Section.d.ts.map +1 -0
  61. package/dist/modules/document/Section.js +94 -0
  62. package/dist/modules/document/Section.js.map +1 -0
  63. package/dist/modules/document/Segment.d.ts +40 -0
  64. package/dist/modules/document/Segment.d.ts.map +1 -0
  65. package/dist/modules/document/Segment.js +85 -0
  66. package/dist/modules/document/Segment.js.map +1 -0
  67. package/dist/modules/document/Tag.d.ts +24 -0
  68. package/dist/modules/document/Tag.d.ts.map +1 -0
  69. package/dist/modules/document/Tag.js +37 -0
  70. package/dist/modules/document/Tag.js.map +1 -0
  71. package/dist/modules/document/TimeFragment.d.ts +11 -0
  72. package/dist/modules/document/TimeFragment.d.ts.map +1 -0
  73. package/dist/modules/document/TimeFragment.js +29 -0
  74. package/dist/modules/document/TimeFragment.js.map +1 -0
  75. package/dist/modules/document/Word.d.ts +40 -0
  76. package/dist/modules/document/Word.d.ts.map +1 -0
  77. package/dist/modules/document/Word.js +114 -0
  78. package/dist/modules/document/Word.js.map +1 -0
  79. package/dist/modules/document/WordState.d.ts +6 -0
  80. package/dist/modules/document/WordState.d.ts.map +1 -0
  81. package/dist/modules/document/WordState.js +7 -0
  82. package/dist/modules/document/WordState.js.map +1 -0
  83. package/dist/modules/document/index.d.ts +14 -0
  84. package/dist/modules/document/index.d.ts.map +1 -0
  85. package/dist/modules/document/index.js +14 -0
  86. package/dist/modules/document/index.js.map +1 -0
  87. package/dist/modules/effect/CarryQuotesEffect.d.ts +47 -0
  88. package/dist/modules/effect/CarryQuotesEffect.d.ts.map +1 -0
  89. package/dist/modules/effect/CarryQuotesEffect.js +181 -0
  90. package/dist/modules/effect/CarryQuotesEffect.js.map +1 -0
  91. package/dist/modules/effect/Effect.d.ts +16 -0
  92. package/dist/modules/effect/Effect.d.ts.map +1 -0
  93. package/dist/modules/effect/Effect.js +2 -0
  94. package/dist/modules/effect/Effect.js.map +1 -0
  95. package/dist/modules/effect/GapFreeEffect.d.ts +24 -0
  96. package/dist/modules/effect/GapFreeEffect.d.ts.map +1 -0
  97. package/dist/modules/effect/GapFreeEffect.js +67 -0
  98. package/dist/modules/effect/GapFreeEffect.js.map +1 -0
  99. package/dist/modules/effect/RemovePunctuationEffect.d.ts +21 -0
  100. package/dist/modules/effect/RemovePunctuationEffect.d.ts.map +1 -0
  101. package/dist/modules/effect/RemovePunctuationEffect.js +52 -0
  102. package/dist/modules/effect/RemovePunctuationEffect.js.map +1 -0
  103. package/dist/modules/effect/SmartLowercaseEffect.d.ts +21 -0
  104. package/dist/modules/effect/SmartLowercaseEffect.d.ts.map +1 -0
  105. package/dist/modules/effect/SmartLowercaseEffect.js +45 -0
  106. package/dist/modules/effect/SmartLowercaseEffect.js.map +1 -0
  107. package/dist/modules/effect/SmartPunctuationEffect.d.ts +25 -0
  108. package/dist/modules/effect/SmartPunctuationEffect.d.ts.map +1 -0
  109. package/dist/modules/effect/SmartPunctuationEffect.js +68 -0
  110. package/dist/modules/effect/SmartPunctuationEffect.js.map +1 -0
  111. package/dist/modules/effect/index.d.ts +7 -0
  112. package/dist/modules/effect/index.d.ts.map +1 -0
  113. package/dist/modules/effect/index.js +6 -0
  114. package/dist/modules/effect/index.js.map +1 -0
  115. package/dist/modules/pipeline/PipelineProgress.d.ts +30 -0
  116. package/dist/modules/pipeline/PipelineProgress.d.ts.map +1 -0
  117. package/dist/modules/pipeline/PipelineProgress.js +2 -0
  118. package/dist/modules/pipeline/PipelineProgress.js.map +1 -0
  119. package/dist/modules/pipeline/RenderPipeline.d.ts +105 -0
  120. package/dist/modules/pipeline/RenderPipeline.d.ts.map +1 -0
  121. package/dist/modules/pipeline/RenderPipeline.js +232 -0
  122. package/dist/modules/pipeline/RenderPipeline.js.map +1 -0
  123. package/dist/modules/pipeline/RenderPipelineBuilder.d.ts +143 -0
  124. package/dist/modules/pipeline/RenderPipelineBuilder.d.ts.map +1 -0
  125. package/dist/modules/pipeline/RenderPipelineBuilder.js +317 -0
  126. package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -0
  127. package/dist/modules/pipeline/index.d.ts +6 -0
  128. package/dist/modules/pipeline/index.d.ts.map +1 -0
  129. package/dist/modules/pipeline/index.js +3 -0
  130. package/dist/modules/pipeline/index.js.map +1 -0
  131. package/dist/modules/profiling/Profiler.d.ts +115 -0
  132. package/dist/modules/profiling/Profiler.d.ts.map +1 -0
  133. package/dist/modules/profiling/Profiler.js +316 -0
  134. package/dist/modules/profiling/Profiler.js.map +1 -0
  135. package/dist/modules/profiling/index.d.ts +2 -0
  136. package/dist/modules/profiling/index.d.ts.map +1 -0
  137. package/dist/modules/profiling/index.js +2 -0
  138. package/dist/modules/profiling/index.js.map +1 -0
  139. package/dist/modules/rendering/AlignmentConfig.d.ts +21 -0
  140. package/dist/modules/rendering/AlignmentConfig.d.ts.map +1 -0
  141. package/dist/modules/rendering/AlignmentConfig.js +2 -0
  142. package/dist/modules/rendering/AlignmentConfig.js.map +1 -0
  143. package/dist/modules/rendering/BoxEdges.d.ts +8 -0
  144. package/dist/modules/rendering/BoxEdges.d.ts.map +1 -0
  145. package/dist/modules/rendering/BoxEdges.js +2 -0
  146. package/dist/modules/rendering/BoxEdges.js.map +1 -0
  147. package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts +12 -0
  148. package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts.map +1 -0
  149. package/dist/modules/rendering/BrowserOverlayFrameRenderer.js +31 -0
  150. package/dist/modules/rendering/BrowserOverlayFrameRenderer.js.map +1 -0
  151. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts +57 -0
  152. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -0
  153. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +775 -0
  154. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -0
  155. package/dist/modules/rendering/ElementRenderOverrides.d.ts +15 -0
  156. package/dist/modules/rendering/ElementRenderOverrides.d.ts.map +1 -0
  157. package/dist/modules/rendering/ElementRenderOverrides.js +24 -0
  158. package/dist/modules/rendering/ElementRenderOverrides.js.map +1 -0
  159. package/dist/modules/rendering/InlineStyleMap.d.ts +9 -0
  160. package/dist/modules/rendering/InlineStyleMap.d.ts.map +1 -0
  161. package/dist/modules/rendering/InlineStyleMap.js +2 -0
  162. package/dist/modules/rendering/InlineStyleMap.js.map +1 -0
  163. package/dist/modules/rendering/LayeredSubtitleFrame.d.ts +20 -0
  164. package/dist/modules/rendering/LayeredSubtitleFrame.d.ts.map +1 -0
  165. package/dist/modules/rendering/LayeredSubtitleFrame.js +36 -0
  166. package/dist/modules/rendering/LayeredSubtitleFrame.js.map +1 -0
  167. package/dist/modules/rendering/OverlayFrameRenderer.d.ts +27 -0
  168. package/dist/modules/rendering/OverlayFrameRenderer.d.ts.map +1 -0
  169. package/dist/modules/rendering/OverlayFrameRenderer.js +2 -0
  170. package/dist/modules/rendering/OverlayFrameRenderer.js.map +1 -0
  171. package/dist/modules/rendering/RenderingConfig.d.ts +22 -0
  172. package/dist/modules/rendering/RenderingConfig.d.ts.map +1 -0
  173. package/dist/modules/rendering/RenderingConfig.js +2 -0
  174. package/dist/modules/rendering/RenderingConfig.js.map +1 -0
  175. package/dist/modules/rendering/ScopedRenderOverride.d.ts +19 -0
  176. package/dist/modules/rendering/ScopedRenderOverride.d.ts.map +1 -0
  177. package/dist/modules/rendering/ScopedRenderOverride.js +2 -0
  178. package/dist/modules/rendering/ScopedRenderOverride.js.map +1 -0
  179. package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts +41 -0
  180. package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts.map +1 -0
  181. package/dist/modules/rendering/SegmentPaintRegionResolver.js +47 -0
  182. package/dist/modules/rendering/SegmentPaintRegionResolver.js.map +1 -0
  183. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts +58 -0
  184. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts.map +1 -0
  185. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js +132 -0
  186. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js.map +1 -0
  187. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +111 -0
  188. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -0
  189. package/dist/modules/rendering/SubtitleFrameRenderer.js +2 -0
  190. package/dist/modules/rendering/SubtitleFrameRenderer.js.map +1 -0
  191. package/dist/modules/rendering/VideoFrameLayerClass.d.ts +21 -0
  192. package/dist/modules/rendering/VideoFrameLayerClass.d.ts.map +1 -0
  193. package/dist/modules/rendering/VideoFrameLayerClass.js +21 -0
  194. package/dist/modules/rendering/VideoFrameLayerClass.js.map +1 -0
  195. package/dist/modules/rendering/VideoFrameSource.d.ts +29 -0
  196. package/dist/modules/rendering/VideoFrameSource.d.ts.map +1 -0
  197. package/dist/modules/rendering/VideoFrameSource.js +2 -0
  198. package/dist/modules/rendering/VideoFrameSource.js.map +1 -0
  199. package/dist/modules/rendering/index.d.ts +14 -0
  200. package/dist/modules/rendering/index.d.ts.map +1 -0
  201. package/dist/modules/rendering/index.js +6 -0
  202. package/dist/modules/rendering/index.js.map +1 -0
  203. package/dist/modules/splitting/BalancedLineSplitter.d.ts +24 -0
  204. package/dist/modules/splitting/BalancedLineSplitter.d.ts.map +1 -0
  205. package/dist/modules/splitting/BalancedLineSplitter.js +81 -0
  206. package/dist/modules/splitting/BalancedLineSplitter.js.map +1 -0
  207. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts +31 -0
  208. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts.map +1 -0
  209. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js +99 -0
  210. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js.map +1 -0
  211. package/dist/modules/splitting/BoundarySegmentSplitter.d.ts +19 -0
  212. package/dist/modules/splitting/BoundarySegmentSplitter.d.ts.map +1 -0
  213. package/dist/modules/splitting/BoundarySegmentSplitter.js +38 -0
  214. package/dist/modules/splitting/BoundarySegmentSplitter.js.map +1 -0
  215. package/dist/modules/splitting/CompositeSegmentSplitter.d.ts +8 -0
  216. package/dist/modules/splitting/CompositeSegmentSplitter.d.ts.map +1 -0
  217. package/dist/modules/splitting/CompositeSegmentSplitter.js +12 -0
  218. package/dist/modules/splitting/CompositeSegmentSplitter.js.map +1 -0
  219. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts +56 -0
  220. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts.map +1 -0
  221. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js +197 -0
  222. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js.map +1 -0
  223. package/dist/modules/splitting/GraphemeWordSplitter.d.ts +11 -0
  224. package/dist/modules/splitting/GraphemeWordSplitter.d.ts.map +1 -0
  225. package/dist/modules/splitting/GraphemeWordSplitter.js +12 -0
  226. package/dist/modules/splitting/GraphemeWordSplitter.js.map +1 -0
  227. package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts +15 -0
  228. package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts.map +1 -0
  229. package/dist/modules/splitting/LimitByCharsSegmentSplitter.js +64 -0
  230. package/dist/modules/splitting/LimitByCharsSegmentSplitter.js.map +1 -0
  231. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts +30 -0
  232. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts.map +1 -0
  233. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js +66 -0
  234. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js.map +1 -0
  235. package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts +12 -0
  236. package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts.map +1 -0
  237. package/dist/modules/splitting/LimitByWordsSegmentSplitter.js +25 -0
  238. package/dist/modules/splitting/LimitByWordsSegmentSplitter.js.map +1 -0
  239. package/dist/modules/splitting/LineSplitter.d.ts +10 -0
  240. package/dist/modules/splitting/LineSplitter.d.ts.map +1 -0
  241. package/dist/modules/splitting/LineSplitter.js +2 -0
  242. package/dist/modules/splitting/LineSplitter.js.map +1 -0
  243. package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts +24 -0
  244. package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts.map +1 -0
  245. package/dist/modules/splitting/PauseBasedSegmentSplitter.js +43 -0
  246. package/dist/modules/splitting/PauseBasedSegmentSplitter.js.map +1 -0
  247. package/dist/modules/splitting/SegmentSplitter.d.ts +10 -0
  248. package/dist/modules/splitting/SegmentSplitter.d.ts.map +1 -0
  249. package/dist/modules/splitting/SegmentSplitter.js +2 -0
  250. package/dist/modules/splitting/SegmentSplitter.js.map +1 -0
  251. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts +17 -0
  252. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts.map +1 -0
  253. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js +46 -0
  254. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js.map +1 -0
  255. package/dist/modules/splitting/TextMeasurer.d.ts +15 -0
  256. package/dist/modules/splitting/TextMeasurer.d.ts.map +1 -0
  257. package/dist/modules/splitting/TextMeasurer.js +2 -0
  258. package/dist/modules/splitting/TextMeasurer.js.map +1 -0
  259. package/dist/modules/splitting/WordSplitter.d.ts +8 -0
  260. package/dist/modules/splitting/WordSplitter.d.ts.map +1 -0
  261. package/dist/modules/splitting/WordSplitter.js +2 -0
  262. package/dist/modules/splitting/WordSplitter.js.map +1 -0
  263. package/dist/modules/splitting/index.d.ts +24 -0
  264. package/dist/modules/splitting/index.d.ts.map +1 -0
  265. package/dist/modules/splitting/index.js +12 -0
  266. package/dist/modules/splitting/index.js.map +1 -0
  267. package/dist/modules/svg-filter/SvgFilter.d.ts +16 -0
  268. package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -0
  269. package/dist/modules/svg-filter/SvgFilter.js +28 -0
  270. package/dist/modules/svg-filter/SvgFilter.js.map +1 -0
  271. package/dist/modules/svg-filter/SvgFilterBundle.d.ts +16 -0
  272. package/dist/modules/svg-filter/SvgFilterBundle.d.ts.map +1 -0
  273. package/dist/modules/svg-filter/SvgFilterBundle.js +20 -0
  274. package/dist/modules/svg-filter/SvgFilterBundle.js.map +1 -0
  275. package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts +16 -0
  276. package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts.map +1 -0
  277. package/dist/modules/svg-filter/SvgFilterDefinitions.js +25 -0
  278. package/dist/modules/svg-filter/SvgFilterDefinitions.js.map +1 -0
  279. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts +21 -0
  280. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts.map +1 -0
  281. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js +50 -0
  282. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js.map +1 -0
  283. package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts +17 -0
  284. package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts.map +1 -0
  285. package/dist/modules/svg-filter/SvgFilterLengthResolver.js +27 -0
  286. package/dist/modules/svg-filter/SvgFilterLengthResolver.js.map +1 -0
  287. package/dist/modules/svg-filter/SvgFilterScope.d.ts +18 -0
  288. package/dist/modules/svg-filter/SvgFilterScope.d.ts.map +1 -0
  289. package/dist/modules/svg-filter/SvgFilterScope.js +28 -0
  290. package/dist/modules/svg-filter/SvgFilterScope.js.map +1 -0
  291. package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts +52 -0
  292. package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts.map +1 -0
  293. package/dist/modules/svg-filter/SvgFilterScopeProvider.js +2 -0
  294. package/dist/modules/svg-filter/SvgFilterScopeProvider.js.map +1 -0
  295. package/dist/modules/svg-filter/SvgFilterScoper.d.ts +60 -0
  296. package/dist/modules/svg-filter/SvgFilterScoper.d.ts.map +1 -0
  297. package/dist/modules/svg-filter/SvgFilterScoper.js +58 -0
  298. package/dist/modules/svg-filter/SvgFilterScoper.js.map +1 -0
  299. package/dist/modules/svg-filter/index.d.ts +10 -0
  300. package/dist/modules/svg-filter/index.d.ts.map +1 -0
  301. package/dist/modules/svg-filter/index.js +8 -0
  302. package/dist/modules/svg-filter/index.js.map +1 -0
  303. package/dist/modules/tagging/RegexTagger.d.ts +11 -0
  304. package/dist/modules/tagging/RegexTagger.d.ts.map +1 -0
  305. package/dist/modules/tagging/RegexTagger.js +32 -0
  306. package/dist/modules/tagging/RegexTagger.js.map +1 -0
  307. package/dist/modules/tagging/SpanTagger.d.ts +25 -0
  308. package/dist/modules/tagging/SpanTagger.d.ts.map +1 -0
  309. package/dist/modules/tagging/SpanTagger.js +73 -0
  310. package/dist/modules/tagging/SpanTagger.js.map +1 -0
  311. package/dist/modules/tagging/StructureTagger.d.ts +20 -0
  312. package/dist/modules/tagging/StructureTagger.d.ts.map +1 -0
  313. package/dist/modules/tagging/StructureTagger.js +74 -0
  314. package/dist/modules/tagging/StructureTagger.js.map +1 -0
  315. package/dist/modules/tagging/Tagger.d.ts +5 -0
  316. package/dist/modules/tagging/Tagger.d.ts.map +1 -0
  317. package/dist/modules/tagging/Tagger.js +5 -0
  318. package/dist/modules/tagging/Tagger.js.map +1 -0
  319. package/dist/modules/tagging/WordlistTagger.d.ts +11 -0
  320. package/dist/modules/tagging/WordlistTagger.d.ts.map +1 -0
  321. package/dist/modules/tagging/WordlistTagger.js +31 -0
  322. package/dist/modules/tagging/WordlistTagger.js.map +1 -0
  323. package/dist/modules/tagging/index.d.ts +6 -0
  324. package/dist/modules/tagging/index.d.ts.map +1 -0
  325. package/dist/modules/tagging/index.js +6 -0
  326. package/dist/modules/tagging/index.js.map +1 -0
  327. package/dist/modules/transcription/AudioDecoder.d.ts +11 -0
  328. package/dist/modules/transcription/AudioDecoder.d.ts.map +1 -0
  329. package/dist/modules/transcription/AudioDecoder.js +2 -0
  330. package/dist/modules/transcription/AudioDecoder.js.map +1 -0
  331. package/dist/modules/transcription/BrowserAudioDecoder.d.ts +13 -0
  332. package/dist/modules/transcription/BrowserAudioDecoder.d.ts.map +1 -0
  333. package/dist/modules/transcription/BrowserAudioDecoder.js +34 -0
  334. package/dist/modules/transcription/BrowserAudioDecoder.js.map +1 -0
  335. package/dist/modules/transcription/PassthroughTranscriber.d.ts +20 -0
  336. package/dist/modules/transcription/PassthroughTranscriber.d.ts.map +1 -0
  337. package/dist/modules/transcription/PassthroughTranscriber.js +23 -0
  338. package/dist/modules/transcription/PassthroughTranscriber.js.map +1 -0
  339. package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts +12 -0
  340. package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts.map +1 -0
  341. package/dist/modules/transcription/PreDecodedAudioDecoder.js +14 -0
  342. package/dist/modules/transcription/PreDecodedAudioDecoder.js.map +1 -0
  343. package/dist/modules/transcription/SrtTranscriber.d.ts +33 -0
  344. package/dist/modules/transcription/SrtTranscriber.d.ts.map +1 -0
  345. package/dist/modules/transcription/SrtTranscriber.js +111 -0
  346. package/dist/modules/transcription/SrtTranscriber.js.map +1 -0
  347. package/dist/modules/transcription/Transcriber.d.ts +23 -0
  348. package/dist/modules/transcription/Transcriber.d.ts.map +1 -0
  349. package/dist/modules/transcription/Transcriber.js +2 -0
  350. package/dist/modules/transcription/Transcriber.js.map +1 -0
  351. package/dist/modules/transcription/WhisperTranscriber.d.ts +44 -0
  352. package/dist/modules/transcription/WhisperTranscriber.d.ts.map +1 -0
  353. package/dist/modules/transcription/WhisperTranscriber.js +162 -0
  354. package/dist/modules/transcription/WhisperTranscriber.js.map +1 -0
  355. package/dist/modules/transcription/index.d.ts +8 -0
  356. package/dist/modules/transcription/index.d.ts.map +1 -0
  357. package/dist/modules/transcription/index.js +6 -0
  358. package/dist/modules/transcription/index.js.map +1 -0
  359. package/dist/modules/video/RenderJob.d.ts +95 -0
  360. package/dist/modules/video/RenderJob.d.ts.map +1 -0
  361. package/dist/modules/video/RenderJob.js +2 -0
  362. package/dist/modules/video/RenderJob.js.map +1 -0
  363. package/dist/modules/video/VideoRenderer.d.ts +5 -0
  364. package/dist/modules/video/VideoRenderer.d.ts.map +1 -0
  365. package/dist/modules/video/VideoRenderer.js +2 -0
  366. package/dist/modules/video/VideoRenderer.js.map +1 -0
  367. package/dist/modules/video/index.d.ts +33 -0
  368. package/dist/modules/video/index.d.ts.map +1 -0
  369. package/dist/modules/video/index.js +17 -0
  370. package/dist/modules/video/index.js.map +1 -0
  371. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts +69 -0
  372. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts.map +1 -0
  373. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js +206 -0
  374. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js.map +1 -0
  375. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts +24 -0
  376. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts.map +1 -0
  377. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js +2 -0
  378. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js.map +1 -0
  379. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts +20 -0
  380. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts.map +1 -0
  381. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js +2 -0
  382. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js.map +1 -0
  383. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts +11 -0
  384. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts.map +1 -0
  385. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js +32 -0
  386. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js.map +1 -0
  387. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts +12 -0
  388. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts.map +1 -0
  389. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js +14 -0
  390. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js.map +1 -0
  391. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts +28 -0
  392. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts.map +1 -0
  393. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js +52 -0
  394. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js.map +1 -0
  395. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts +25 -0
  396. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts.map +1 -0
  397. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js +52 -0
  398. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js.map +1 -0
  399. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts +32 -0
  400. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts.map +1 -0
  401. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js +60 -0
  402. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js.map +1 -0
  403. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts +27 -0
  404. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts.map +1 -0
  405. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js +72 -0
  406. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js.map +1 -0
  407. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts +32 -0
  408. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts.map +1 -0
  409. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js +2 -0
  410. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js.map +1 -0
  411. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts +25 -0
  412. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts.map +1 -0
  413. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js +37 -0
  414. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js.map +1 -0
  415. package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts +32 -0
  416. package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts.map +1 -0
  417. package/dist/modules/video/mediabunny/codec/CodecPolicy.js +2 -0
  418. package/dist/modules/video/mediabunny/codec/CodecPolicy.js.map +1 -0
  419. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts +59 -0
  420. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts.map +1 -0
  421. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js +110 -0
  422. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js.map +1 -0
  423. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts +27 -0
  424. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts.map +1 -0
  425. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js +44 -0
  426. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js.map +1 -0
  427. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts +10 -0
  428. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts.map +1 -0
  429. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js +15 -0
  430. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js.map +1 -0
  431. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts +29 -0
  432. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts.map +1 -0
  433. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js +2 -0
  434. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js.map +1 -0
  435. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts +16 -0
  436. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts.map +1 -0
  437. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js +2 -0
  438. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js.map +1 -0
  439. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +25 -0
  440. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +1 -0
  441. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +74 -0
  442. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +1 -0
  443. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts +26 -0
  444. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts.map +1 -0
  445. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js +147 -0
  446. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js.map +1 -0
  447. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts +12 -0
  448. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts.map +1 -0
  449. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js +25 -0
  450. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js.map +1 -0
  451. package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts +30 -0
  452. package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts.map +1 -0
  453. package/dist/modules/video/mediabunny/frame/FrameCompositor.js +2 -0
  454. package/dist/modules/video/mediabunny/frame/FrameCompositor.js.map +1 -0
  455. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts +44 -0
  456. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts.map +1 -0
  457. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js +334 -0
  458. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js.map +1 -0
  459. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts +10 -0
  460. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts.map +1 -0
  461. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js +17 -0
  462. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js.map +1 -0
  463. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts +30 -0
  464. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts.map +1 -0
  465. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js +2 -0
  466. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js.map +1 -0
  467. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts +22 -0
  468. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts.map +1 -0
  469. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js +2 -0
  470. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js.map +1 -0
  471. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts +17 -0
  472. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts.map +1 -0
  473. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js +48 -0
  474. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js.map +1 -0
  475. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts +11 -0
  476. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts.map +1 -0
  477. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js +22 -0
  478. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js.map +1 -0
  479. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts +27 -0
  480. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts.map +1 -0
  481. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js +2 -0
  482. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js.map +1 -0
  483. 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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AAM,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,EA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
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
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=VideoTrackEncoder.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=VideoTrackEncoderFactory.js.map
@@ -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":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAElC,mEAAmE;IACnE,0CAA0C;IAClC,MAAM,CAAU,qBAAqB,GAAG,IAAI,CAAC;IAEpC,MAAM,CAAkB;IACxB,GAAG,CAAoC;IAChD,gBAAgB,GAAkB,IAAI,CAAC;IAE/C,YAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,SAAiB,EAAE,KAAwB;QACpD,IAAI,CAAC,gBAAgB,GAAG,S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M,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACjF,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;IAClF,CAAC;IAEO,aAAa,CAAC,IAAU;QAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;YACvD,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;YACnG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -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"}