@remotion/renderer 4.0.0-fastlambda.8 → 4.0.0-forcepublish.7

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 (435) hide show
  1. package/dist/assets/calculate-asset-positions.d.ts +2 -2
  2. package/dist/assets/convert-assets-to-file-urls.d.ts +5 -4
  3. package/dist/assets/convert-assets-to-file-urls.js +2 -2
  4. package/dist/assets/download-and-map-assets-to-file.d.ts +15 -6
  5. package/dist/assets/download-and-map-assets-to-file.js +108 -44
  6. package/dist/assets/download-file.d.ts +10 -5
  7. package/dist/assets/download-file.js +18 -5
  8. package/dist/assets/download-map.d.ts +64 -0
  9. package/dist/assets/download-map.js +73 -0
  10. package/dist/assets/ffmpeg-volume-expression.d.ts +3 -3
  11. package/dist/assets/ffmpeg-volume-expression.js +16 -14
  12. package/dist/assets/flatten-volume-array.d.ts +1 -1
  13. package/dist/assets/get-audio-channels.d.ts +3 -4
  14. package/dist/assets/get-audio-channels.js +14 -4
  15. package/dist/assets/get-video-stream-duration.d.ts +4 -0
  16. package/dist/assets/get-video-stream-duration.js +59 -0
  17. package/dist/assets/read-file.js +4 -1
  18. package/dist/assets/types.d.ts +1 -1
  19. package/dist/browser/Browser.d.ts +60 -0
  20. package/dist/browser/Browser.js +218 -0
  21. package/dist/browser/BrowserConnector.d.ts +19 -0
  22. package/dist/browser/BrowserConnector.js +17 -0
  23. package/dist/browser/BrowserFetcher.d.ts +89 -0
  24. package/dist/browser/BrowserFetcher.js +510 -0
  25. package/dist/browser/BrowserPage.d.ts +74 -0
  26. package/dist/browser/BrowserPage.js +283 -0
  27. package/dist/browser/BrowserRunner.d.ts +39 -0
  28. package/dist/browser/BrowserRunner.js +308 -0
  29. package/dist/browser/Connection.d.ts +42 -0
  30. package/dist/browser/Connection.js +242 -0
  31. package/dist/browser/ConsoleMessage.d.ts +31 -0
  32. package/dist/browser/ConsoleMessage.js +48 -0
  33. package/dist/browser/DOMWorld.d.ts +52 -0
  34. package/dist/browser/DOMWorld.js +272 -0
  35. package/dist/browser/Errors.d.ts +25 -0
  36. package/dist/browser/Errors.js +35 -0
  37. package/dist/browser/EvalTypes.d.ts +27 -0
  38. package/dist/browser/EvalTypes.js +17 -0
  39. package/dist/browser/EventEmitter.d.ts +23 -0
  40. package/dist/browser/EventEmitter.js +53 -0
  41. package/dist/browser/ExecutionContext.d.ts +34 -0
  42. package/dist/browser/ExecutionContext.js +174 -0
  43. package/dist/browser/FrameManager.d.ts +93 -0
  44. package/dist/browser/FrameManager.js +496 -0
  45. package/dist/browser/HTTPRequest.d.ts +28 -0
  46. package/dist/browser/HTTPRequest.js +37 -0
  47. package/dist/browser/HTTPResponse.d.ts +21 -0
  48. package/dist/browser/HTTPResponse.js +41 -0
  49. package/dist/browser/JSHandle.d.ts +35 -0
  50. package/dist/browser/JSHandle.js +90 -0
  51. package/dist/browser/LaunchOptions.d.ts +37 -0
  52. package/dist/browser/LaunchOptions.js +17 -0
  53. package/dist/browser/Launcher.d.ts +9 -0
  54. package/dist/browser/Launcher.js +504 -0
  55. package/dist/browser/LifecycleWatcher.d.ts +29 -0
  56. package/dist/browser/LifecycleWatcher.js +180 -0
  57. package/dist/browser/NetworkEventManager.d.ts +33 -0
  58. package/dist/browser/NetworkEventManager.js +81 -0
  59. package/dist/browser/NetworkManager.d.ts +34 -0
  60. package/dist/browser/NetworkManager.js +231 -0
  61. package/dist/browser/NodeWebSocketTransport.d.ts +17 -0
  62. package/dist/browser/NodeWebSocketTransport.js +87 -0
  63. package/dist/browser/Product.d.ts +16 -0
  64. package/dist/browser/Product.js +17 -0
  65. package/dist/browser/PuppeteerNode.d.ts +40 -0
  66. package/dist/browser/PuppeteerNode.js +81 -0
  67. package/dist/browser/PuppeteerViewport.d.ts +5 -0
  68. package/dist/browser/PuppeteerViewport.js +2 -0
  69. package/dist/browser/ScreenshotOptions.d.ts +14 -0
  70. package/dist/browser/ScreenshotOptions.js +2 -0
  71. package/dist/browser/Target.d.ts +61 -0
  72. package/dist/browser/Target.js +146 -0
  73. package/dist/browser/TaskQueue.d.ts +20 -0
  74. package/dist/browser/TaskQueue.js +47 -0
  75. package/dist/browser/TimeoutSettings.d.ts +24 -0
  76. package/dist/browser/TimeoutSettings.js +62 -0
  77. package/dist/browser/assert.d.ts +1 -0
  78. package/dist/browser/assert.js +9 -0
  79. package/dist/browser/create-browser-fetcher.d.ts +17 -0
  80. package/dist/browser/create-browser-fetcher.js +119 -0
  81. package/dist/browser/devtools-commands.d.ts +270 -0
  82. package/dist/browser/devtools-commands.js +2 -0
  83. package/dist/browser/devtools-types.d.ts +1122 -0
  84. package/dist/browser/devtools-types.js +2 -0
  85. package/dist/browser/get-download-destination.d.ts +1 -0
  86. package/dist/browser/get-download-destination.js +38 -0
  87. package/dist/browser/mitt/index.d.ts +22 -0
  88. package/dist/browser/mitt/index.js +49 -0
  89. package/dist/browser/node.d.ts +2 -0
  90. package/dist/browser/node.js +9 -0
  91. package/dist/browser/revisions.d.ts +21 -0
  92. package/dist/browser/revisions.js +22 -0
  93. package/dist/browser/util.d.ts +47 -0
  94. package/dist/browser/util.js +169 -0
  95. package/dist/browser-executable.d.ts +1 -0
  96. package/dist/browser-executable.js +2 -0
  97. package/dist/browser-log.d.ts +1 -1
  98. package/dist/browser.d.ts +2 -0
  99. package/dist/browser.js +4 -0
  100. package/dist/calculate-ffmpeg-filters.d.ts +1 -1
  101. package/dist/calculate-ffmpeg-filters.js +2 -2
  102. package/dist/calculate-sar-dar-pixels.d.ts +9 -0
  103. package/dist/calculate-sar-dar-pixels.js +19 -0
  104. package/dist/can-use-parallel-encoding.d.ts +1 -1
  105. package/dist/can-use-parallel-encoding.js +2 -2
  106. package/dist/codec-supports-media.d.ts +7 -0
  107. package/dist/codec-supports-media.js +49 -0
  108. package/dist/codec.d.ts +4 -0
  109. package/dist/codec.js +16 -0
  110. package/dist/combine-videos.d.ts +4 -2
  111. package/dist/combine-videos.js +19 -5
  112. package/dist/compress-assets.d.ts +7 -0
  113. package/dist/compress-assets.js +25 -0
  114. package/dist/convert-number-of-gif-loops-to-ffmpeg.d.ts +1 -0
  115. package/dist/convert-number-of-gif-loops-to-ffmpeg.js +17 -0
  116. package/dist/convert-to-pcm.d.ts +1 -1
  117. package/dist/create-ffmpeg-complex-filter.d.ts +3 -5
  118. package/dist/create-ffmpeg-complex-filter.js +2 -11
  119. package/dist/create-ffmpeg-merge-filter.js +3 -3
  120. package/dist/create-silent-audio.d.ts +1 -1
  121. package/dist/crf.d.ts +5 -0
  122. package/dist/crf.js +64 -0
  123. package/dist/cycle-browser-tabs.d.ts +3 -2
  124. package/dist/cycle-browser-tabs.js +9 -2
  125. package/dist/delay-render-embedded-stack.d.ts +1 -1
  126. package/dist/ensure-frames-in-order.d.ts +1 -1
  127. package/dist/ensure-frames-in-order.js +3 -2
  128. package/dist/ensure-presentation-timestamp.d.ts +2 -0
  129. package/dist/ensure-presentation-timestamp.js +69 -0
  130. package/dist/error-handling/handle-javascript-exception.d.ts +2 -2
  131. package/dist/error-handling/handle-javascript-exception.js +3 -4
  132. package/dist/error-handling/symbolicate-error.d.ts +1 -1
  133. package/dist/error-handling/symbolicateable-error.d.ts +1 -1
  134. package/dist/extract-frame-from-video.d.ts +16 -0
  135. package/dist/extract-frame-from-video.js +254 -0
  136. package/dist/ffmpeg-executable.d.ts +1 -0
  137. package/dist/ffmpeg-executable.js +2 -0
  138. package/dist/ffmpeg-filter-file.d.ts +2 -1
  139. package/dist/ffmpeg-filter-file.js +4 -6
  140. package/dist/frame-range.d.ts +2 -0
  141. package/dist/frame-range.js +49 -0
  142. package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
  143. package/dist/frame-to-ffmpeg-timestamp.js +8 -0
  144. package/dist/get-audio-codec-name.d.ts +1 -1
  145. package/dist/get-audio-codec-name.js +2 -2
  146. package/dist/get-browser-instance.d.ts +4 -3
  147. package/dist/get-browser-instance.js +2 -2
  148. package/dist/get-codec-name.d.ts +1 -1
  149. package/dist/get-codec-name.js +5 -2
  150. package/dist/get-compositions.d.ts +15 -5
  151. package/dist/get-compositions.js +35 -11
  152. package/dist/get-duration-from-frame-range.d.ts +1 -2
  153. package/dist/get-duration-from-frame-range.js +13 -9
  154. package/dist/get-extension-from-codec.d.ts +2 -2
  155. package/dist/get-extension-from-codec.js +5 -0
  156. package/dist/get-extension-of-filename.d.ts +1 -1
  157. package/dist/get-extension-of-filename.js +3 -0
  158. package/dist/get-frame-padded-index.d.ts +14 -0
  159. package/dist/get-frame-padded-index.js +33 -0
  160. package/dist/get-frame-to-render.d.ts +1 -1
  161. package/dist/get-local-browser-executable.d.ts +2 -1
  162. package/dist/get-local-browser-executable.js +7 -5
  163. package/dist/get-port.js +30 -37
  164. package/dist/get-prores-profile-name.d.ts +2 -1
  165. package/dist/get-video-info.d.ts +3 -0
  166. package/dist/get-video-info.js +49 -0
  167. package/dist/get-video-threads-flag.d.ts +1 -0
  168. package/dist/get-video-threads-flag.js +18 -0
  169. package/dist/guess-extension-for-media.d.ts +1 -0
  170. package/dist/guess-extension-for-media.js +27 -0
  171. package/dist/image-format.d.ts +6 -1
  172. package/dist/image-format.js +25 -1
  173. package/dist/index.d.ts +95 -20
  174. package/dist/index.js +93 -6
  175. package/dist/is-audio-codec.d.ts +2 -0
  176. package/dist/is-audio-codec.js +7 -0
  177. package/dist/is-beyond-last-frame.d.ts +3 -0
  178. package/dist/is-beyond-last-frame.js +12 -0
  179. package/dist/last-frame-from-video-cache.d.ts +17 -0
  180. package/dist/last-frame-from-video-cache.js +55 -0
  181. package/dist/log-level.d.ts +4 -0
  182. package/dist/log-level.js +15 -0
  183. package/dist/make-cancel-signal.d.ts +7 -0
  184. package/dist/make-cancel-signal.js +25 -0
  185. package/dist/merge-audio-track.d.ts +3 -1
  186. package/dist/merge-audio-track.js +14 -8
  187. package/dist/mime-db.d.ts +6 -0
  188. package/dist/mime-db.js +8636 -0
  189. package/dist/mime-types.d.ts +2 -0
  190. package/dist/mime-types.js +89 -0
  191. package/dist/offthread-video-server.d.ts +17 -0
  192. package/dist/offthread-video-server.js +86 -0
  193. package/dist/open-browser.d.ts +10 -8
  194. package/dist/open-browser.js +37 -32
  195. package/dist/overwrite.d.ts +1 -0
  196. package/dist/overwrite.js +4 -0
  197. package/dist/perf.d.ts +5 -0
  198. package/dist/perf.js +35 -0
  199. package/dist/pixel-format.d.ts +5 -0
  200. package/dist/pixel-format.js +26 -0
  201. package/dist/prepare-server.d.ts +14 -2
  202. package/dist/prepare-server.js +38 -5
  203. package/dist/preprocess-audio-track.d.ts +5 -2
  204. package/dist/preprocess-audio-track.js +3 -3
  205. package/dist/prespawn-ffmpeg.d.ts +7 -1
  206. package/dist/prespawn-ffmpeg.js +20 -16
  207. package/dist/prestitcher-memory-usage.d.ts +12 -0
  208. package/dist/prestitcher-memory-usage.js +30 -0
  209. package/dist/prores-profile.d.ts +5 -0
  210. package/dist/prores-profile.js +23 -0
  211. package/dist/provide-screenshot.d.ts +5 -4
  212. package/dist/provide-screenshot.js +1 -2
  213. package/dist/puppeteer-evaluate.d.ts +1 -1
  214. package/dist/puppeteer-evaluate.js +3 -4
  215. package/dist/puppeteer-screenshot.d.ts +4 -2
  216. package/dist/puppeteer-screenshot.js +7 -5
  217. package/dist/quality.d.ts +1 -0
  218. package/dist/quality.js +21 -0
  219. package/dist/render-frames.d.ts +24 -8
  220. package/dist/render-frames.js +137 -63
  221. package/dist/render-media.d.ts +36 -9
  222. package/dist/render-media.js +191 -70
  223. package/dist/render-still.d.ts +25 -7
  224. package/dist/render-still.js +75 -24
  225. package/dist/screenshot-dom-element.d.ts +7 -7
  226. package/dist/screenshot-dom-element.js +3 -6
  227. package/dist/screenshot-task.d.ts +4 -2
  228. package/dist/screenshot-task.js +36 -23
  229. package/dist/seek-to-frame.d.ts +2 -2
  230. package/dist/seek-to-frame.js +2 -2
  231. package/dist/serve-handler/index.d.ts +4 -0
  232. package/dist/serve-handler/index.js +204 -0
  233. package/dist/serve-handler/is-path-inside.d.ts +1 -0
  234. package/dist/serve-handler/is-path-inside.js +27 -0
  235. package/dist/serve-handler/range-parser.d.ts +13 -0
  236. package/dist/serve-handler/range-parser.js +57 -0
  237. package/dist/serve-static.d.ts +11 -3
  238. package/dist/serve-static.js +37 -7
  239. package/dist/set-props-and-env.d.ts +6 -2
  240. package/dist/set-props-and-env.js +48 -12
  241. package/dist/stitch-frames-to-video.d.ts +17 -5
  242. package/dist/stitch-frames-to-video.js +129 -45
  243. package/dist/stringify-ffmpeg-filter.d.ts +2 -2
  244. package/dist/stringify-ffmpeg-filter.js +12 -7
  245. package/dist/symbolicate-stacktrace.d.ts +1 -1
  246. package/dist/symbolicate-stacktrace.js +3 -3
  247. package/dist/tmp-dir.js +5 -1
  248. package/dist/truthy.d.ts +3 -0
  249. package/dist/truthy.js +7 -0
  250. package/dist/types.d.ts +1 -1
  251. package/dist/validate-concurrency.d.ts +1 -0
  252. package/dist/validate-concurrency.js +24 -0
  253. package/dist/validate-even-dimensions-with-codec.d.ts +1 -1
  254. package/dist/validate-even-dimensions-with-codec.js +2 -2
  255. package/dist/validate-every-nth-frame.d.ts +1 -0
  256. package/dist/validate-every-nth-frame.js +21 -0
  257. package/dist/validate-ffmpeg.js +2 -3
  258. package/dist/validate-frame.d.ts +1 -0
  259. package/dist/validate-frame.js +24 -0
  260. package/dist/validate-opengl-renderer.d.ts +5 -0
  261. package/dist/validate-opengl-renderer.js +15 -0
  262. package/dist/validate-output-filename.d.ts +1 -1
  263. package/dist/validate-output-filename.js +5 -0
  264. package/dist/wait-for-symbolication-error-to-be-done.d.ts +3 -0
  265. package/dist/wait-for-symbolication-error-to-be-done.js +34 -0
  266. package/dist/ws/ws-types.d.ts +14 -0
  267. package/dist/ws/ws-types.js +10 -0
  268. package/package.json +13 -16
  269. package/tsconfig.json +2 -2
  270. package/types/ws/index.d.ts +509 -0
  271. package/vitest.config.ts +8 -0
  272. package/dist/assets/calculate-asset-positions.d.ts.map +0 -1
  273. package/dist/assets/calculate-asset-positions.js.map +0 -1
  274. package/dist/assets/calculate-atempo.d.ts.map +0 -1
  275. package/dist/assets/calculate-atempo.js.map +0 -1
  276. package/dist/assets/convert-assets-to-file-urls.d.ts.map +0 -1
  277. package/dist/assets/convert-assets-to-file-urls.js.map +0 -1
  278. package/dist/assets/download-and-map-assets-to-file.d.ts.map +0 -1
  279. package/dist/assets/download-and-map-assets-to-file.js.map +0 -1
  280. package/dist/assets/download-file.d.ts.map +0 -1
  281. package/dist/assets/download-file.js.map +0 -1
  282. package/dist/assets/ffmpeg-volume-expression.d.ts.map +0 -1
  283. package/dist/assets/ffmpeg-volume-expression.js.map +0 -1
  284. package/dist/assets/flatten-volume-array.d.ts.map +0 -1
  285. package/dist/assets/flatten-volume-array.js.map +0 -1
  286. package/dist/assets/get-audio-channels.d.ts.map +0 -1
  287. package/dist/assets/get-audio-channels.js.map +0 -1
  288. package/dist/assets/read-file.d.ts.map +0 -1
  289. package/dist/assets/read-file.js.map +0 -1
  290. package/dist/assets/round-volume-to-avoid-stack-overflow.d.ts.map +0 -1
  291. package/dist/assets/round-volume-to-avoid-stack-overflow.js.map +0 -1
  292. package/dist/assets/sanitize-filename.d.ts.map +0 -1
  293. package/dist/assets/sanitize-filename.js.map +0 -1
  294. package/dist/assets/sanitize-filepath.d.ts.map +0 -1
  295. package/dist/assets/sanitize-filepath.js.map +0 -1
  296. package/dist/assets/truncate-utf8-bytes.d.ts.map +0 -1
  297. package/dist/assets/truncate-utf8-bytes.js.map +0 -1
  298. package/dist/assets/types.d.ts.map +0 -1
  299. package/dist/assets/types.js.map +0 -1
  300. package/dist/browser-log.d.ts.map +0 -1
  301. package/dist/browser-log.js.map +0 -1
  302. package/dist/calculate-ffmpeg-filters.d.ts.map +0 -1
  303. package/dist/calculate-ffmpeg-filters.js.map +0 -1
  304. package/dist/can-use-parallel-encoding.d.ts.map +0 -1
  305. package/dist/can-use-parallel-encoding.js.map +0 -1
  306. package/dist/chunk.d.ts.map +0 -1
  307. package/dist/chunk.js.map +0 -1
  308. package/dist/combine-videos.d.ts.map +0 -1
  309. package/dist/combine-videos.js.map +0 -1
  310. package/dist/convert-to-pcm.d.ts.map +0 -1
  311. package/dist/convert-to-pcm.js.map +0 -1
  312. package/dist/create-ffmpeg-complex-filter.d.ts.map +0 -1
  313. package/dist/create-ffmpeg-complex-filter.js.map +0 -1
  314. package/dist/create-ffmpeg-merge-filter.d.ts.map +0 -1
  315. package/dist/create-ffmpeg-merge-filter.js.map +0 -1
  316. package/dist/create-silent-audio.d.ts.map +0 -1
  317. package/dist/create-silent-audio.js.map +0 -1
  318. package/dist/cycle-browser-tabs.d.ts.map +0 -1
  319. package/dist/cycle-browser-tabs.js.map +0 -1
  320. package/dist/delay-render-embedded-stack.d.ts.map +0 -1
  321. package/dist/delay-render-embedded-stack.js.map +0 -1
  322. package/dist/delete-directory.d.ts.map +0 -1
  323. package/dist/delete-directory.js.map +0 -1
  324. package/dist/ensure-frames-in-order.d.ts.map +0 -1
  325. package/dist/ensure-frames-in-order.js.map +0 -1
  326. package/dist/ensure-output-directory.d.ts.map +0 -1
  327. package/dist/ensure-output-directory.js.map +0 -1
  328. package/dist/error-handling/handle-javascript-exception.d.ts.map +0 -1
  329. package/dist/error-handling/handle-javascript-exception.js.map +0 -1
  330. package/dist/error-handling/symbolicate-error.d.ts.map +0 -1
  331. package/dist/error-handling/symbolicate-error.js.map +0 -1
  332. package/dist/error-handling/symbolicateable-error.d.ts.map +0 -1
  333. package/dist/error-handling/symbolicateable-error.js.map +0 -1
  334. package/dist/ffmpeg-filter-file.d.ts.map +0 -1
  335. package/dist/ffmpeg-filter-file.js.map +0 -1
  336. package/dist/ffmpeg-flags.d.ts.map +0 -1
  337. package/dist/ffmpeg-flags.js.map +0 -1
  338. package/dist/get-audio-codec-name.d.ts.map +0 -1
  339. package/dist/get-audio-codec-name.js.map +0 -1
  340. package/dist/get-browser-instance.d.ts.map +0 -1
  341. package/dist/get-browser-instance.js.map +0 -1
  342. package/dist/get-codec-name.d.ts.map +0 -1
  343. package/dist/get-codec-name.js.map +0 -1
  344. package/dist/get-compositions.d.ts.map +0 -1
  345. package/dist/get-compositions.js.map +0 -1
  346. package/dist/get-concurrency.d.ts.map +0 -1
  347. package/dist/get-concurrency.js.map +0 -1
  348. package/dist/get-duration-from-frame-range.d.ts.map +0 -1
  349. package/dist/get-duration-from-frame-range.js.map +0 -1
  350. package/dist/get-extension-from-codec.d.ts.map +0 -1
  351. package/dist/get-extension-from-codec.js.map +0 -1
  352. package/dist/get-frame-to-render.d.ts.map +0 -1
  353. package/dist/get-frame-to-render.js.map +0 -1
  354. package/dist/get-local-browser-executable.d.ts.map +0 -1
  355. package/dist/get-local-browser-executable.js.map +0 -1
  356. package/dist/get-port.d.ts.map +0 -1
  357. package/dist/get-port.js.map +0 -1
  358. package/dist/get-prores-profile-name.d.ts.map +0 -1
  359. package/dist/get-prores-profile-name.js.map +0 -1
  360. package/dist/image-format.d.ts.map +0 -1
  361. package/dist/image-format.js.map +0 -1
  362. package/dist/index.d.ts.map +0 -1
  363. package/dist/index.js.map +0 -1
  364. package/dist/is-serve-url.d.ts.map +0 -1
  365. package/dist/is-serve-url.js.map +0 -1
  366. package/dist/legacy-webpack-config.d.ts.map +0 -1
  367. package/dist/legacy-webpack-config.js.map +0 -1
  368. package/dist/make-assets-download-dir.d.ts +0 -1
  369. package/dist/make-assets-download-dir.d.ts.map +0 -1
  370. package/dist/make-assets-download-dir.js +0 -8
  371. package/dist/make-assets-download-dir.js.map +0 -1
  372. package/dist/merge-audio-track.d.ts.map +0 -1
  373. package/dist/merge-audio-track.js.map +0 -1
  374. package/dist/normalize-serve-url.d.ts.map +0 -1
  375. package/dist/normalize-serve-url.js.map +0 -1
  376. package/dist/open-browser.d.ts.map +0 -1
  377. package/dist/open-browser.js.map +0 -1
  378. package/dist/p-limit.d.ts.map +0 -1
  379. package/dist/p-limit.js.map +0 -1
  380. package/dist/parse-browser-error-stack.d.ts.map +0 -1
  381. package/dist/parse-browser-error-stack.js.map +0 -1
  382. package/dist/parse-ffmpeg-progress.d.ts.map +0 -1
  383. package/dist/parse-ffmpeg-progress.js.map +0 -1
  384. package/dist/pool.d.ts.map +0 -1
  385. package/dist/pool.js.map +0 -1
  386. package/dist/prepare-server.d.ts.map +0 -1
  387. package/dist/prepare-server.js.map +0 -1
  388. package/dist/preprocess-audio-track.d.ts.map +0 -1
  389. package/dist/preprocess-audio-track.js.map +0 -1
  390. package/dist/prespawn-ffmpeg.d.ts.map +0 -1
  391. package/dist/prespawn-ffmpeg.js.map +0 -1
  392. package/dist/provide-screenshot.d.ts.map +0 -1
  393. package/dist/provide-screenshot.js.map +0 -1
  394. package/dist/puppeteer-evaluate.d.ts.map +0 -1
  395. package/dist/puppeteer-evaluate.js.map +0 -1
  396. package/dist/puppeteer-screenshot.d.ts.map +0 -1
  397. package/dist/puppeteer-screenshot.js.map +0 -1
  398. package/dist/render-frames.d.ts.map +0 -1
  399. package/dist/render-frames.js.map +0 -1
  400. package/dist/render-media.d.ts.map +0 -1
  401. package/dist/render-media.js.map +0 -1
  402. package/dist/render-still.d.ts.map +0 -1
  403. package/dist/render-still.js.map +0 -1
  404. package/dist/resolve-asset-src.d.ts.map +0 -1
  405. package/dist/resolve-asset-src.js.map +0 -1
  406. package/dist/sample-rate.d.ts.map +0 -1
  407. package/dist/sample-rate.js.map +0 -1
  408. package/dist/screenshot-dom-element.d.ts.map +0 -1
  409. package/dist/screenshot-dom-element.js.map +0 -1
  410. package/dist/screenshot-task.d.ts.map +0 -1
  411. package/dist/screenshot-task.js.map +0 -1
  412. package/dist/seek-to-frame.d.ts.map +0 -1
  413. package/dist/seek-to-frame.js.map +0 -1
  414. package/dist/serve-static.d.ts.map +0 -1
  415. package/dist/serve-static.js.map +0 -1
  416. package/dist/set-props-and-env.d.ts.map +0 -1
  417. package/dist/set-props-and-env.js.map +0 -1
  418. package/dist/stitch-frames-to-video.d.ts.map +0 -1
  419. package/dist/stitch-frames-to-video.js.map +0 -1
  420. package/dist/stringify-ffmpeg-filter.d.ts.map +0 -1
  421. package/dist/stringify-ffmpeg-filter.js.map +0 -1
  422. package/dist/symbolicate-stacktrace.d.ts.map +0 -1
  423. package/dist/symbolicate-stacktrace.js.map +0 -1
  424. package/dist/tmp-dir.d.ts.map +0 -1
  425. package/dist/tmp-dir.js.map +0 -1
  426. package/dist/types.d.ts.map +0 -1
  427. package/dist/types.js.map +0 -1
  428. package/dist/validate-even-dimensions-with-codec.d.ts.map +0 -1
  429. package/dist/validate-even-dimensions-with-codec.js.map +0 -1
  430. package/dist/validate-ffmpeg.d.ts.map +0 -1
  431. package/dist/validate-ffmpeg.js.map +0 -1
  432. package/dist/validate-puppeteer-timeout.d.ts.map +0 -1
  433. package/dist/validate-puppeteer-timeout.js.map +0 -1
  434. package/dist/validate-scale.d.ts.map +0 -1
  435. package/dist/validate-scale.js.map +0 -1
@@ -1,3 +1,3 @@
1
- import { TAsset } from 'remotion';
2
- import { Assets } from './types';
1
+ import type { TAsset } from 'remotion';
2
+ import type { Assets } from './types';
3
3
  export declare const calculateAssetPositions: (frames: TAsset[][]) => Assets;
@@ -1,7 +1,8 @@
1
- import { TAsset } from 'remotion';
2
- import { RenderMediaOnDownload } from './download-and-map-assets-to-file';
3
- export declare const convertAssetsToFileUrls: ({ assets, downloadDir, onDownload, }: {
1
+ import type { TAsset } from 'remotion';
2
+ import type { RenderMediaOnDownload } from './download-and-map-assets-to-file';
3
+ import type { DownloadMap } from './download-map';
4
+ export declare const convertAssetsToFileUrls: ({ assets, onDownload, downloadMap, }: {
4
5
  assets: TAsset[][];
5
- downloadDir: string;
6
6
  onDownload: RenderMediaOnDownload;
7
+ downloadMap: DownloadMap;
7
8
  }) => Promise<TAsset[][]>;
@@ -9,7 +9,7 @@ const chunk = (input, size) => {
9
9
  : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
10
10
  }, []);
11
11
  };
12
- const convertAssetsToFileUrls = async ({ assets, downloadDir, onDownload, }) => {
12
+ const convertAssetsToFileUrls = async ({ assets, onDownload, downloadMap, }) => {
13
13
  const chunks = chunk(assets, 1000);
14
14
  const results = [];
15
15
  for (const ch of chunks) {
@@ -17,8 +17,8 @@ const convertAssetsToFileUrls = async ({ assets, downloadDir, onDownload, }) =>
17
17
  return Promise.all(assetsForFrame.map((a) => {
18
18
  return (0, download_and_map_assets_to_file_1.downloadAndMapAssetsToFileUrl)({
19
19
  asset: a,
20
- downloadDir,
21
20
  onDownload,
21
+ downloadMap,
22
22
  });
23
23
  }));
24
24
  }));
@@ -1,14 +1,23 @@
1
- import { TAsset } from 'remotion';
1
+ import type { TAsset } from 'remotion';
2
+ import type { DownloadMap } from './download-map';
2
3
  export declare type RenderMediaOnDownload = (src: string) => ((progress: {
3
- percent: number;
4
+ percent: number | null;
5
+ downloaded: number;
6
+ totalSize: number | null;
4
7
  }) => void) | undefined | void;
5
- export declare const markAllAssetsAsDownloaded: () => void;
6
- export declare const getSanitizedFilenameForAssetUrl: ({ src, downloadDir, }: {
8
+ export declare const downloadAsset: ({ src, onDownload, downloadMap, }: {
9
+ src: string;
10
+ onDownload: RenderMediaOnDownload;
11
+ downloadMap: DownloadMap;
12
+ }) => Promise<string>;
13
+ export declare const markAllAssetsAsDownloaded: (downloadMap: DownloadMap) => void;
14
+ export declare const getSanitizedFilenameForAssetUrl: ({ src, downloadDir, contentDisposition, }: {
7
15
  src: string;
8
16
  downloadDir: string;
17
+ contentDisposition: string | null;
9
18
  }) => string;
10
- export declare const downloadAndMapAssetsToFileUrl: ({ asset, downloadDir, onDownload, }: {
19
+ export declare const downloadAndMapAssetsToFileUrl: ({ asset, onDownload, downloadMap, }: {
11
20
  asset: TAsset;
12
- downloadDir: string;
13
21
  onDownload: RenderMediaOnDownload;
22
+ downloadMap: DownloadMap;
14
23
  }) => Promise<TAsset>;
@@ -3,31 +3,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = void 0;
6
+ exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = exports.downloadAsset = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const remotion_1 = require("remotion");
10
+ const compress_assets_1 = require("../compress-assets");
10
11
  const ensure_output_directory_1 = require("../ensure-output-directory");
11
12
  const download_file_1 = require("./download-file");
12
13
  const sanitize_filepath_1 = require("./sanitize-filepath");
13
- const isDownloadingMap = {};
14
- const hasBeenDownloadedMap = {};
15
- const listeners = {};
16
- const waitForAssetToBeDownloaded = (src) => {
17
- if (!listeners[src]) {
18
- listeners[src] = [];
14
+ const waitForAssetToBeDownloaded = ({ src, downloadDir, downloadMap, }) => {
15
+ var _a, _b;
16
+ if ((_a = downloadMap.hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
17
+ return Promise.resolve((_b = downloadMap.hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir]);
18
+ }
19
+ if (!downloadMap.listeners[src]) {
20
+ downloadMap.listeners[src] = {};
21
+ }
22
+ if (!downloadMap.listeners[src][downloadDir]) {
23
+ downloadMap.listeners[src][downloadDir] = [];
19
24
  }
20
25
  return new Promise((resolve) => {
21
- listeners[src].push(() => resolve());
26
+ downloadMap.listeners[src][downloadDir].push(() => {
27
+ const srcMap = downloadMap.hasBeenDownloadedMap[src];
28
+ if (!srcMap || !srcMap[downloadDir]) {
29
+ throw new Error('Expected file for ' + src + 'to be available in ' + downloadDir);
30
+ }
31
+ resolve(srcMap[downloadDir]);
32
+ });
22
33
  });
23
34
  };
24
- const notifyAssetIsDownloaded = (src) => {
25
- if (!listeners[src]) {
26
- listeners[src] = [];
35
+ const notifyAssetIsDownloaded = ({ src, downloadDir, to, downloadMap, }) => {
36
+ if (!downloadMap.listeners[src]) {
37
+ downloadMap.listeners[src] = {};
38
+ }
39
+ if (!downloadMap.listeners[src][downloadDir]) {
40
+ downloadMap.listeners[src][downloadDir] = [];
41
+ }
42
+ if (!downloadMap.isDownloadingMap[src]) {
43
+ downloadMap.isDownloadingMap[src] = {};
27
44
  }
28
- listeners[src].forEach((fn) => fn());
29
- isDownloadingMap[src] = false;
30
- hasBeenDownloadedMap[src] = true;
45
+ downloadMap.isDownloadingMap[src][downloadDir] = false;
46
+ if (!downloadMap.hasBeenDownloadedMap[src]) {
47
+ downloadMap.hasBeenDownloadedMap[src] = {};
48
+ }
49
+ downloadMap.hasBeenDownloadedMap[src][downloadDir] = to;
50
+ downloadMap.listeners[src][downloadDir].forEach((fn) => fn());
31
51
  };
32
52
  const validateMimeType = (mimeType, src) => {
33
53
  if (!mimeType.includes('/')) {
@@ -68,17 +88,41 @@ function validateBufferEncoding(potentialEncoding, dataUrl) {
68
88
  throw new TypeError(errMessage);
69
89
  }
70
90
  }
71
- const downloadAsset = async (src, to, onDownload) => {
72
- if (hasBeenDownloadedMap[src]) {
73
- return;
91
+ const downloadAsset = async ({ src, onDownload, downloadMap, }) => {
92
+ var _a, _b, _c;
93
+ if ((0, compress_assets_1.isAssetCompressed)(src)) {
94
+ return src;
95
+ }
96
+ const { downloadDir } = downloadMap;
97
+ if ((_a = downloadMap.hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
98
+ const claimedDownloadLocation = (_b = downloadMap.hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir];
99
+ // The OS might have deleted the file since even though we marked it as downloaded. In that case we reset the state and download it again
100
+ if (fs_1.default.existsSync(claimedDownloadLocation)) {
101
+ return claimedDownloadLocation;
102
+ }
103
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
104
+ downloadMap.hasBeenDownloadedMap[src][downloadDir] = null;
105
+ if (!downloadMap.isDownloadingMap[src]) {
106
+ downloadMap.isDownloadingMap[src] = {};
107
+ }
108
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
109
+ downloadMap.isDownloadingMap[src][downloadDir] = false;
74
110
  }
75
- if (isDownloadingMap[src]) {
76
- return waitForAssetToBeDownloaded(src);
111
+ if ((_c = downloadMap.isDownloadingMap[src]) === null || _c === void 0 ? void 0 : _c[downloadDir]) {
112
+ return waitForAssetToBeDownloaded({ downloadMap, src, downloadDir });
77
113
  }
78
- isDownloadingMap[src] = true;
114
+ if (!downloadMap.isDownloadingMap[src]) {
115
+ downloadMap.isDownloadingMap[src] = {};
116
+ }
117
+ downloadMap.isDownloadingMap[src][downloadDir] = true;
79
118
  const onProgress = onDownload(src);
80
- (0, ensure_output_directory_1.ensureOutputDirectory)(to);
81
119
  if (src.startsWith('data:')) {
120
+ const output = (0, exports.getSanitizedFilenameForAssetUrl)({
121
+ contentDisposition: null,
122
+ downloadDir,
123
+ src,
124
+ });
125
+ (0, ensure_output_directory_1.ensureOutputDirectory)(output);
82
126
  const [assetDetails, assetData] = src.substring('data:'.length).split(',');
83
127
  if (!assetDetails.includes(';')) {
84
128
  const errMessage = [
@@ -93,47 +137,67 @@ const downloadAsset = async (src, to, onDownload) => {
93
137
  validateMimeType(mimeType, src);
94
138
  validateBufferEncoding(encoding, src);
95
139
  const buff = Buffer.from(assetData, encoding);
96
- await fs_1.default.promises.writeFile(to, buff);
97
- notifyAssetIsDownloaded(src);
98
- return;
140
+ await fs_1.default.promises.writeFile(output, buff);
141
+ notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to: output });
142
+ return output;
99
143
  }
100
- await (0, download_file_1.downloadFile)(src, to, ({ progress }) => {
101
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
102
- percent: progress,
103
- });
144
+ const { to } = await (0, download_file_1.downloadFile)({
145
+ url: src,
146
+ onProgress: (progress) => {
147
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(progress);
148
+ },
149
+ to: (contentDisposition) => (0, exports.getSanitizedFilenameForAssetUrl)({ contentDisposition, downloadDir, src }),
104
150
  });
105
- notifyAssetIsDownloaded(src);
151
+ notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to });
152
+ return to;
106
153
  };
107
- const markAllAssetsAsDownloaded = () => {
108
- Object.keys(hasBeenDownloadedMap).forEach((key) => {
109
- delete hasBeenDownloadedMap[key];
154
+ exports.downloadAsset = downloadAsset;
155
+ const markAllAssetsAsDownloaded = (downloadMap) => {
156
+ Object.keys(downloadMap.hasBeenDownloadedMap).forEach((key) => {
157
+ delete downloadMap.hasBeenDownloadedMap[key];
110
158
  });
111
- Object.keys(isDownloadingMap).forEach((key) => {
112
- delete isDownloadingMap[key];
159
+ Object.keys(downloadMap.isDownloadingMap).forEach((key) => {
160
+ delete downloadMap.isDownloadingMap[key];
113
161
  });
114
162
  };
115
163
  exports.markAllAssetsAsDownloaded = markAllAssetsAsDownloaded;
116
- const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, }) => {
117
- if (remotion_1.Internals.AssetCompression.isAssetCompressed(src)) {
118
- return src;
164
+ const getFilename = ({ contentDisposition, src, }) => {
165
+ const filenameProbe = 'filename=';
166
+ if (contentDisposition === null || contentDisposition === void 0 ? void 0 : contentDisposition.includes(filenameProbe)) {
167
+ const start = contentDisposition.indexOf(filenameProbe);
168
+ const onlyFromFileName = contentDisposition.substring(start + filenameProbe.length);
169
+ const hasSemi = onlyFromFileName.indexOf(';');
170
+ if (hasSemi === -1) {
171
+ return { pathname: onlyFromFileName.trim(), search: '' };
172
+ }
173
+ return {
174
+ search: '',
175
+ pathname: onlyFromFileName.substring(0, hasSemi).trim(),
176
+ };
119
177
  }
120
178
  const { pathname, search } = new URL(src);
179
+ return { pathname, search };
180
+ };
181
+ const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, contentDisposition, }) => {
182
+ if ((0, compress_assets_1.isAssetCompressed)(src)) {
183
+ return src;
184
+ }
185
+ const { pathname, search } = getFilename({ contentDisposition, src });
121
186
  const split = pathname.split('.');
122
187
  const fileExtension = split.length > 1 && split[split.length - 1]
123
188
  ? `.${split[split.length - 1]}`
124
189
  : '';
125
190
  const hashedFileName = String((0, remotion_1.random)(`${pathname}${search}`)).replace('0.', '');
126
- return path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(hashedFileName + fileExtension));
191
+ const filename = hashedFileName + fileExtension;
192
+ return path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(filename));
127
193
  };
128
194
  exports.getSanitizedFilenameForAssetUrl = getSanitizedFilenameForAssetUrl;
129
- const downloadAndMapAssetsToFileUrl = async ({ asset, downloadDir, onDownload, }) => {
130
- const newSrc = (0, exports.getSanitizedFilenameForAssetUrl)({
195
+ const downloadAndMapAssetsToFileUrl = async ({ asset, onDownload, downloadMap, }) => {
196
+ const newSrc = await (0, exports.downloadAsset)({
131
197
  src: asset.src,
132
- downloadDir,
198
+ onDownload,
199
+ downloadMap,
133
200
  });
134
- if (!remotion_1.Internals.AssetCompression.isAssetCompressed(newSrc)) {
135
- await downloadAsset(asset.src, newSrc, onDownload);
136
- }
137
201
  return {
138
202
  ...asset,
139
203
  src: newSrc,
@@ -1,7 +1,12 @@
1
- export declare const downloadFile: (url: string, to: string, onProgress: ((progress: {
2
- progress: number;
3
- downloaded: number;
4
- totalSize: number;
5
- }) => void) | undefined) => Promise<{
1
+ export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
2
+ url: string;
3
+ to: (contentDisposition: string | null) => string;
4
+ onProgress: ((progress: {
5
+ percent: number | null;
6
+ downloaded: number;
7
+ totalSize: number | null;
8
+ }) => void) | undefined;
9
+ }) => Promise<{
6
10
  sizeInBytes: number;
11
+ to: string;
7
12
  }>;
@@ -2,25 +2,38 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.downloadFile = void 0;
4
4
  const fs_1 = require("fs");
5
+ const ensure_output_directory_1 = require("../ensure-output-directory");
5
6
  const read_file_1 = require("./read-file");
6
- const downloadFile = (url, to, onProgress) => {
7
+ const downloadFile = ({ onProgress, url, to: toFn, }) => {
7
8
  return new Promise((resolve, reject) => {
8
9
  (0, read_file_1.readFile)(url)
9
10
  .then((res) => {
10
- const totalSize = Number(res.headers['content-length']);
11
+ var _a;
12
+ const contentDisposition = (_a = res.headers['content-disposition']) !== null && _a !== void 0 ? _a : null;
13
+ const to = toFn(contentDisposition);
14
+ (0, ensure_output_directory_1.ensureOutputDirectory)(to);
15
+ const sizeHeader = res.headers['content-length'];
16
+ const totalSize = typeof sizeHeader === 'undefined' ? null : Number(sizeHeader);
11
17
  const writeStream = (0, fs_1.createWriteStream)(to);
18
+ let downloaded = 0;
12
19
  // Listen to 'close' event instead of more
13
20
  // concise method to avoid this problem
14
21
  // https://github.com/remotion-dev/remotion/issues/384#issuecomment-844398183
15
- writeStream.on('close', () => resolve({ sizeInBytes: totalSize }));
22
+ writeStream.on('close', () => {
23
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
24
+ downloaded,
25
+ percent: 1,
26
+ totalSize: downloaded,
27
+ });
28
+ return resolve({ sizeInBytes: downloaded, to });
29
+ });
16
30
  writeStream.on('error', (err) => reject(err));
17
- let downloaded = 0;
18
31
  res.pipe(writeStream).on('error', (err) => reject(err));
19
32
  res.on('data', (d) => {
20
33
  downloaded += d.length;
21
34
  onProgress === null || onProgress === void 0 ? void 0 : onProgress({
22
35
  downloaded,
23
- progress: downloaded / totalSize,
36
+ percent: totalSize === null ? null : downloaded / totalSize,
24
37
  totalSize,
25
38
  });
26
39
  });
@@ -0,0 +1,64 @@
1
+ /// <reference types="node" />
2
+ import type { TAsset } from 'remotion';
3
+ declare type EncodingStatus = {
4
+ type: 'encoding';
5
+ } | {
6
+ type: 'done';
7
+ src: string;
8
+ } | undefined;
9
+ export declare type SpecialVCodecForTransparency = 'vp9' | 'vp8' | 'none';
10
+ export declare type Vp9Result = {
11
+ specialVcodec: SpecialVCodecForTransparency;
12
+ needsResize: [number, number] | null;
13
+ };
14
+ export declare type VideoDurationResult = {
15
+ duration: number | null;
16
+ fps: number | null;
17
+ };
18
+ export declare type AudioChannelsAndDurationResultCache = {
19
+ channels: number;
20
+ duration: number | null;
21
+ };
22
+ export declare type DownloadMap = {
23
+ id: string;
24
+ isDownloadingMap: {
25
+ [src: string]: {
26
+ [downloadDir: string]: boolean;
27
+ } | undefined;
28
+ };
29
+ hasBeenDownloadedMap: {
30
+ [src: string]: {
31
+ [downloadDir: string]: string | null;
32
+ } | undefined;
33
+ };
34
+ listeners: {
35
+ [key: string]: {
36
+ [downloadDir: string]: (() => void)[];
37
+ };
38
+ };
39
+ lastFrameMap: Record<string, {
40
+ lastAccessed: number;
41
+ data: Buffer;
42
+ }>;
43
+ isBeyondLastFrameMap: Record<string, number>;
44
+ isVp9VideoCache: Record<string, Vp9Result>;
45
+ ensureFileHasPresentationTimestamp: Record<string, EncodingStatus>;
46
+ videoDurationResultCache: Record<string, VideoDurationResult>;
47
+ durationOfAssetCache: Record<string, AudioChannelsAndDurationResultCache>;
48
+ downloadDir: string;
49
+ preEncode: string;
50
+ audioMixing: string;
51
+ complexFilter: string;
52
+ audioPreprocessing: string;
53
+ stitchFrames: string;
54
+ assetDir: string;
55
+ };
56
+ export declare type RenderAssetInfo = {
57
+ assets: TAsset[][];
58
+ imageSequenceName: string;
59
+ firstFrameIndex: number;
60
+ downloadMap: DownloadMap;
61
+ };
62
+ export declare const makeDownloadMap: () => DownloadMap;
63
+ export declare const cleanDownloadMap: (downloadMap: DownloadMap) => Promise<void>;
64
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.cleanDownloadMap = exports.makeDownloadMap = void 0;
30
+ const fs_1 = __importStar(require("fs"));
31
+ const path_1 = __importDefault(require("path"));
32
+ const delete_directory_1 = require("../delete-directory");
33
+ const tmp_dir_1 = require("../tmp-dir");
34
+ const makeAndReturn = (dir, name) => {
35
+ const p = path_1.default.join(dir, name);
36
+ (0, fs_1.mkdirSync)(p);
37
+ return p;
38
+ };
39
+ const packageJsonPath = path_1.default.join(__dirname, '..', '..', 'package.json');
40
+ const packageJson = fs_1.default.existsSync(packageJsonPath)
41
+ ? JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
42
+ : null;
43
+ const makeDownloadMap = () => {
44
+ const dir = (0, tmp_dir_1.tmpDir)(packageJson
45
+ ? `remotion-v${packageJson.version.replace(/\./g, '-')}-assets`
46
+ : 'remotion-assets');
47
+ return {
48
+ isDownloadingMap: {},
49
+ hasBeenDownloadedMap: {},
50
+ listeners: {},
51
+ lastFrameMap: {},
52
+ isBeyondLastFrameMap: {},
53
+ ensureFileHasPresentationTimestamp: {},
54
+ isVp9VideoCache: {},
55
+ videoDurationResultCache: {},
56
+ durationOfAssetCache: {},
57
+ id: String(Math.random()),
58
+ assetDir: dir,
59
+ downloadDir: makeAndReturn(dir, 'remotion-assets-dir'),
60
+ complexFilter: makeAndReturn(dir, 'remotion-complex-filter'),
61
+ preEncode: makeAndReturn(dir, 'pre-encode'),
62
+ audioMixing: makeAndReturn(dir, 'remotion-audio-mixing'),
63
+ audioPreprocessing: makeAndReturn(dir, 'remotion-audio-preprocessing'),
64
+ stitchFrames: makeAndReturn(dir, 'remotion-stitch-temp-dir'),
65
+ };
66
+ };
67
+ exports.makeDownloadMap = makeDownloadMap;
68
+ const cleanDownloadMap = async (downloadMap) => {
69
+ await (0, delete_directory_1.deleteDirectory)(downloadMap.downloadDir);
70
+ await (0, delete_directory_1.deleteDirectory)(downloadMap.complexFilter);
71
+ await (0, delete_directory_1.deleteDirectory)(downloadMap.assetDir);
72
+ };
73
+ exports.cleanDownloadMap = cleanDownloadMap;
@@ -1,12 +1,12 @@
1
- import { AssetVolume } from './types';
1
+ import type { AssetVolume } from './types';
2
2
  declare type FfmpegEval = 'once' | 'frame';
3
3
  declare type FfmpegVolumeExpression = {
4
4
  eval: FfmpegEval;
5
5
  value: string;
6
6
  };
7
- export declare const ffmpegVolumeExpression: ({ volume, startInVideo, fps, }: {
7
+ export declare const ffmpegVolumeExpression: ({ volume, fps, trimLeft, }: {
8
8
  volume: AssetVolume;
9
- startInVideo: number;
9
+ trimLeft: number;
10
10
  fps: number;
11
11
  }) => FfmpegVolumeExpression;
12
12
  export {};
@@ -12,12 +12,12 @@ const FFMPEG_TIME_VARIABLE = 't';
12
12
  const ffmpegIfOrElse = (condition, then, elseDo) => {
13
13
  return `if(${condition},${then},${elseDo})`;
14
14
  };
15
- const ffmpegIsOneOfFrames = (frames, fps) => {
15
+ const ffmpegIsOneOfFrames = ({ frames, trimLeft, fps, }) => {
16
16
  const consecutiveArrays = [];
17
17
  for (let i = 0; i < frames.length; i++) {
18
18
  const previousFrame = frames[i - 1];
19
19
  const frame = frames[i];
20
- if (!previousFrame || frame !== previousFrame + 1) {
20
+ if (previousFrame === undefined || frame !== previousFrame + 1) {
21
21
  consecutiveArrays.push([]);
22
22
  }
23
23
  consecutiveArrays[consecutiveArrays.length - 1].push(frame);
@@ -28,25 +28,22 @@ const ffmpegIsOneOfFrames = (frames, fps) => {
28
28
  const lastFrame = f[f.length - 1];
29
29
  const before = (firstFrame - 0.5) / fps;
30
30
  const after = (lastFrame + 0.5) / fps;
31
- return `between(${FFMPEG_TIME_VARIABLE},${before.toFixed(4)},${after.toFixed(4)})`;
31
+ return `between(${FFMPEG_TIME_VARIABLE},${(before + trimLeft).toFixed(4)},${(after + trimLeft).toFixed(4)})`;
32
32
  })
33
33
  .join('+');
34
34
  };
35
- const ffmpegBuildVolumeExpression = (arr, fps) => {
35
+ const ffmpegBuildVolumeExpression = (arr, delay, fps) => {
36
36
  if (arr.length === 0) {
37
37
  throw new Error('Volume array expression should never have length 0');
38
38
  }
39
39
  if (arr.length === 1) {
40
- // FFMpeg tends to request volume for frames outside the range
41
- // where the audio actually plays.
42
- // If this is the case, we just return volume 0 to clip it.
43
- return ffmpegIfOrElse(ffmpegIsOneOfFrames(arr[0][1], fps), String(arr[0][0]), String(0));
40
+ return String(arr[0][0]);
44
41
  }
45
42
  const [first, ...rest] = arr;
46
43
  const [volume, frames] = first;
47
- return ffmpegIfOrElse(ffmpegIsOneOfFrames(frames, fps), String(volume), ffmpegBuildVolumeExpression(rest, fps));
44
+ return ffmpegIfOrElse(ffmpegIsOneOfFrames({ frames, trimLeft: delay, fps }), String(volume), ffmpegBuildVolumeExpression(rest, delay, fps));
48
45
  };
49
- const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
46
+ const ffmpegVolumeExpression = ({ volume, fps, trimLeft, }) => {
50
47
  // If it's a static volume, we return it and tell
51
48
  // FFMPEG it only has to evaluate it once
52
49
  if (typeof volume === 'number') {
@@ -58,22 +55,27 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
58
55
  if ([...new Set(volume)].length === 1) {
59
56
  return (0, exports.ffmpegVolumeExpression)({
60
57
  volume: volume[0],
61
- startInVideo,
62
58
  fps,
59
+ trimLeft,
63
60
  });
64
61
  }
62
+ // A 1 sec video with frames 0-29 would mean that
63
+ // frame 29 corresponds to timestamp 0.966666...
64
+ // but the audio is actually 1 sec long. For that reason we pad the last
65
+ // timestamp.
66
+ const paddedVolume = [...volume, volume[volume.length - 1]];
65
67
  // Otherwise, we construct an FFMPEG expression. First step:
66
68
  // Make a map of all possible volumes
67
69
  // {possibleVolume1} => [frame1, frame2]
68
70
  // {possibleVolume2} => [frame3, frame4]
69
71
  const volumeMap = {};
70
- volume.forEach((baseVolume, frame) => {
72
+ paddedVolume.forEach((baseVolume, frame) => {
71
73
  // Adjust volume based on how many other tracks have not yet finished
72
74
  const actualVolume = (0, round_volume_to_avoid_stack_overflow_1.roundVolumeToAvoidStackOverflow)(Math.min(1, baseVolume));
73
75
  if (!volumeMap[actualVolume]) {
74
76
  volumeMap[actualVolume] = [];
75
77
  }
76
- volumeMap[actualVolume].push(frame + startInVideo);
78
+ volumeMap[actualVolume].push(frame);
77
79
  });
78
80
  // Sort the map so that the most common volume is last
79
81
  // this is going to be the else statement so the expression is short
@@ -81,7 +83,7 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
81
83
  .map((key) => [Number(key), volumeMap[key]])
82
84
  .sort((a, b) => a[1].length - b[1].length);
83
85
  // Construct and tell FFMPEG it has to evaluate expression on each frame
84
- const expression = ffmpegBuildVolumeExpression(volumeArray, fps);
86
+ const expression = ffmpegBuildVolumeExpression(volumeArray, trimLeft, fps);
85
87
  return {
86
88
  eval: 'frame',
87
89
  value: `'${expression}'`,
@@ -1,3 +1,3 @@
1
- import { AssetVolume, MediaAsset } from './types';
1
+ import type { AssetVolume, MediaAsset } from './types';
2
2
  export declare const flattenVolumeArray: (volume: AssetVolume) => AssetVolume;
3
3
  export declare const convertAssetToFlattenedVolume: (asset: MediaAsset) => MediaAsset;
@@ -1,4 +1,3 @@
1
- export declare function getAudioChannelsAndDuration(path: string): Promise<{
2
- channels: number;
3
- duration: number | null;
4
- }>;
1
+ import type { FfmpegExecutable } from '../ffmpeg-executable';
2
+ import type { AudioChannelsAndDurationResultCache, DownloadMap } from './download-map';
3
+ export declare const getAudioChannelsAndDuration: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable) => Promise<AudioChannelsAndDurationResultCache>;
@@ -5,21 +5,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getAudioChannelsAndDuration = void 0;
7
7
  const execa_1 = __importDefault(require("execa"));
8
- async function getAudioChannelsAndDuration(path) {
8
+ const p_limit_1 = require("../p-limit");
9
+ const limit = (0, p_limit_1.pLimit)(1);
10
+ async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExecutable) {
11
+ if (downloadMap.durationOfAssetCache[src]) {
12
+ return downloadMap.durationOfAssetCache[src];
13
+ }
9
14
  const args = [
10
15
  ['-v', 'error'],
11
16
  ['-show_entries', 'stream=channels:format=duration'],
12
17
  ['-of', 'default=nw=1'],
13
- [path],
18
+ [src],
14
19
  ]
15
20
  .reduce((acc, val) => acc.concat(val), [])
16
21
  .filter(Boolean);
17
- const task = await (0, execa_1.default)('ffprobe', args);
22
+ const task = await (0, execa_1.default)(ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : 'ffprobe', args);
18
23
  const channels = task.stdout.match(/channels=([0-9]+)/);
19
24
  const duration = task.stdout.match(/duration=([0-9.]+)/);
20
- return {
25
+ const result = {
21
26
  channels: channels ? parseInt(channels[1], 10) : 0,
22
27
  duration: duration ? parseFloat(duration[1]) : null,
23
28
  };
29
+ downloadMap.durationOfAssetCache[src] = result;
30
+ return result;
24
31
  }
32
+ const getAudioChannelsAndDuration = (downloadMap, src, ffprobeExecutable) => {
33
+ return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExecutable));
34
+ };
25
35
  exports.getAudioChannelsAndDuration = getAudioChannelsAndDuration;
@@ -0,0 +1,4 @@
1
+ import type { FfmpegExecutable } from '../ffmpeg-executable';
2
+ import type { DownloadMap, VideoDurationResult } from './download-map';
3
+ export declare const parseVideoStreamDuration: (stdout: string) => VideoDurationResult;
4
+ export declare const getVideoStreamDuration: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable) => Promise<VideoDurationResult>;