@remotion/renderer 4.0.0-offthread.9 → 4.0.0-prefetch.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 (429) 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 +16 -12
  5. package/dist/assets/download-and-map-assets-to-file.js +145 -65
  6. package/dist/assets/download-file.d.ts +10 -5
  7. package/dist/assets/download-file.js +20 -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 +2 -3
  11. package/dist/assets/ffmpeg-volume-expression.js +2 -3
  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 +8 -0
  107. package/dist/codec-supports-media.js +56 -0
  108. package/dist/codec.d.ts +4 -0
  109. package/dist/codec.js +16 -0
  110. package/dist/combine-videos.d.ts +3 -2
  111. package/dist/combine-videos.js +17 -7
  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 +6 -2
  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 +1 -1
  124. package/dist/delay-render-embedded-stack.d.ts +1 -1
  125. package/dist/ensure-frames-in-order.d.ts +1 -1
  126. package/dist/ensure-frames-in-order.js +3 -2
  127. package/dist/ensure-presentation-timestamp.d.ts +2 -0
  128. package/dist/ensure-presentation-timestamp.js +69 -0
  129. package/dist/error-handling/handle-javascript-exception.d.ts +2 -2
  130. package/dist/error-handling/handle-javascript-exception.js +3 -4
  131. package/dist/error-handling/symbolicate-error.d.ts +1 -1
  132. package/dist/error-handling/symbolicateable-error.d.ts +1 -1
  133. package/dist/extract-frame-from-video.d.ts +8 -5
  134. package/dist/extract-frame-from-video.js +173 -55
  135. package/dist/ffmpeg-executable.d.ts +1 -0
  136. package/dist/ffmpeg-executable.js +2 -0
  137. package/dist/ffmpeg-filter-file.d.ts +2 -1
  138. package/dist/ffmpeg-filter-file.js +4 -6
  139. package/dist/frame-range.d.ts +2 -0
  140. package/dist/frame-range.js +49 -0
  141. package/dist/get-audio-codec-name.d.ts +1 -1
  142. package/dist/get-audio-codec-name.js +2 -2
  143. package/dist/get-browser-instance.d.ts +4 -3
  144. package/dist/get-browser-instance.js +2 -2
  145. package/dist/get-codec-name.d.ts +1 -1
  146. package/dist/get-codec-name.js +5 -2
  147. package/dist/get-compositions.d.ts +12 -4
  148. package/dist/get-compositions.js +18 -11
  149. package/dist/get-duration-from-frame-range.d.ts +1 -2
  150. package/dist/get-duration-from-frame-range.js +13 -9
  151. package/dist/get-extension-from-codec.d.ts +2 -2
  152. package/dist/get-extension-from-codec.js +5 -0
  153. package/dist/get-extension-of-filename.d.ts +1 -1
  154. package/dist/get-extension-of-filename.js +3 -0
  155. package/dist/get-frame-padded-index.d.ts +14 -0
  156. package/dist/get-frame-padded-index.js +33 -0
  157. package/dist/get-frame-to-render.d.ts +1 -1
  158. package/dist/get-local-browser-executable.d.ts +2 -1
  159. package/dist/get-local-browser-executable.js +7 -5
  160. package/dist/get-port.js +30 -37
  161. package/dist/get-prores-profile-name.d.ts +2 -1
  162. package/dist/get-video-info.d.ts +3 -0
  163. package/dist/get-video-info.js +49 -0
  164. package/dist/get-video-threads-flag.d.ts +1 -0
  165. package/dist/get-video-threads-flag.js +18 -0
  166. package/dist/guess-extension-for-media.d.ts +1 -0
  167. package/dist/guess-extension-for-media.js +27 -0
  168. package/dist/image-format.d.ts +6 -1
  169. package/dist/image-format.js +25 -1
  170. package/dist/index.d.ts +88 -14
  171. package/dist/index.js +91 -2
  172. package/dist/is-audio-codec.d.ts +2 -0
  173. package/dist/is-audio-codec.js +7 -0
  174. package/dist/is-beyond-last-frame.d.ts +3 -2
  175. package/dist/is-beyond-last-frame.js +5 -5
  176. package/dist/last-frame-from-video-cache.d.ts +9 -5
  177. package/dist/last-frame-from-video-cache.js +24 -21
  178. package/dist/log-level.d.ts +4 -0
  179. package/dist/log-level.js +15 -0
  180. package/dist/merge-audio-track.d.ts +3 -1
  181. package/dist/merge-audio-track.js +12 -6
  182. package/dist/mime-db.d.ts +6 -0
  183. package/dist/mime-db.js +8636 -0
  184. package/dist/mime-types.d.ts +3 -0
  185. package/dist/mime-types.js +94 -0
  186. package/dist/offthread-video-server.d.ts +9 -5
  187. package/dist/offthread-video-server.js +31 -10
  188. package/dist/open-browser.d.ts +5 -3
  189. package/dist/open-browser.js +15 -15
  190. package/dist/overwrite.d.ts +1 -0
  191. package/dist/overwrite.js +4 -0
  192. package/dist/perf.d.ts +5 -0
  193. package/dist/perf.js +35 -0
  194. package/dist/pixel-format.d.ts +5 -0
  195. package/dist/pixel-format.js +26 -0
  196. package/dist/prepare-server.d.ts +6 -4
  197. package/dist/prepare-server.js +21 -5
  198. package/dist/preprocess-audio-track.d.ts +5 -2
  199. package/dist/preprocess-audio-track.js +3 -3
  200. package/dist/prespawn-ffmpeg.d.ts +6 -2
  201. package/dist/prespawn-ffmpeg.js +10 -7
  202. package/dist/prestitcher-memory-usage.d.ts +12 -0
  203. package/dist/prestitcher-memory-usage.js +30 -0
  204. package/dist/prores-profile.d.ts +5 -0
  205. package/dist/prores-profile.js +23 -0
  206. package/dist/provide-screenshot.d.ts +4 -4
  207. package/dist/provide-screenshot.js +0 -1
  208. package/dist/puppeteer-evaluate.d.ts +1 -1
  209. package/dist/puppeteer-evaluate.js +3 -4
  210. package/dist/puppeteer-screenshot.d.ts +3 -3
  211. package/dist/puppeteer-screenshot.js +2 -4
  212. package/dist/quality.d.ts +1 -0
  213. package/dist/quality.js +21 -0
  214. package/dist/render-frames.d.ts +21 -9
  215. package/dist/render-frames.js +111 -82
  216. package/dist/render-media.d.ts +32 -10
  217. package/dist/render-media.js +83 -25
  218. package/dist/render-still.d.ts +18 -7
  219. package/dist/render-still.js +44 -16
  220. package/dist/screenshot-dom-element.d.ts +6 -8
  221. package/dist/screenshot-dom-element.js +3 -6
  222. package/dist/screenshot-task.d.ts +3 -3
  223. package/dist/screenshot-task.js +36 -23
  224. package/dist/seek-to-frame.d.ts +2 -2
  225. package/dist/seek-to-frame.js +2 -2
  226. package/dist/serve-handler/index.d.ts +4 -0
  227. package/dist/serve-handler/index.js +204 -0
  228. package/dist/serve-handler/is-path-inside.d.ts +1 -0
  229. package/dist/serve-handler/is-path-inside.js +27 -0
  230. package/dist/serve-handler/range-parser.d.ts +13 -0
  231. package/dist/serve-handler/range-parser.js +57 -0
  232. package/dist/serve-static.d.ts +5 -3
  233. package/dist/serve-static.js +19 -8
  234. package/dist/set-props-and-env.d.ts +4 -2
  235. package/dist/set-props-and-env.js +42 -11
  236. package/dist/stitch-frames-to-video.d.ts +16 -6
  237. package/dist/stitch-frames-to-video.js +112 -42
  238. package/dist/stringify-ffmpeg-filter.d.ts +2 -2
  239. package/dist/stringify-ffmpeg-filter.js +11 -9
  240. package/dist/symbolicate-stacktrace.d.ts +1 -1
  241. package/dist/symbolicate-stacktrace.js +3 -3
  242. package/dist/truthy.d.ts +3 -0
  243. package/dist/truthy.js +7 -0
  244. package/dist/types.d.ts +1 -1
  245. package/dist/validate-concurrency.d.ts +1 -0
  246. package/dist/validate-concurrency.js +24 -0
  247. package/dist/validate-even-dimensions-with-codec.d.ts +1 -1
  248. package/dist/validate-even-dimensions-with-codec.js +2 -2
  249. package/dist/validate-every-nth-frame.d.ts +1 -0
  250. package/dist/validate-every-nth-frame.js +21 -0
  251. package/dist/validate-ffmpeg.js +2 -3
  252. package/dist/validate-frame.d.ts +1 -0
  253. package/dist/validate-frame.js +24 -0
  254. package/dist/validate-opengl-renderer.d.ts +5 -0
  255. package/dist/validate-opengl-renderer.js +15 -0
  256. package/dist/validate-output-filename.d.ts +1 -1
  257. package/dist/validate-output-filename.js +5 -0
  258. package/dist/wait-for-symbolication-error-to-be-done.d.ts +3 -0
  259. package/dist/wait-for-symbolication-error-to-be-done.js +34 -0
  260. package/dist/ws/ws-types.d.ts +14 -0
  261. package/dist/ws/ws-types.js +10 -0
  262. package/package.json +13 -15
  263. package/tsconfig.json +2 -2
  264. package/types/ws/index.d.ts +509 -0
  265. package/vitest.config.ts +8 -0
  266. package/dist/assets/calculate-asset-positions.d.ts.map +0 -1
  267. package/dist/assets/calculate-asset-positions.js.map +0 -1
  268. package/dist/assets/calculate-atempo.d.ts.map +0 -1
  269. package/dist/assets/calculate-atempo.js.map +0 -1
  270. package/dist/assets/convert-assets-to-file-urls.d.ts.map +0 -1
  271. package/dist/assets/convert-assets-to-file-urls.js.map +0 -1
  272. package/dist/assets/download-and-map-assets-to-file.d.ts.map +0 -1
  273. package/dist/assets/download-and-map-assets-to-file.js.map +0 -1
  274. package/dist/assets/download-file.d.ts.map +0 -1
  275. package/dist/assets/download-file.js.map +0 -1
  276. package/dist/assets/ffmpeg-volume-expression.d.ts.map +0 -1
  277. package/dist/assets/ffmpeg-volume-expression.js.map +0 -1
  278. package/dist/assets/flatten-volume-array.d.ts.map +0 -1
  279. package/dist/assets/flatten-volume-array.js.map +0 -1
  280. package/dist/assets/get-audio-channels.d.ts.map +0 -1
  281. package/dist/assets/get-audio-channels.js.map +0 -1
  282. package/dist/assets/read-file.d.ts.map +0 -1
  283. package/dist/assets/read-file.js.map +0 -1
  284. package/dist/assets/round-volume-to-avoid-stack-overflow.d.ts.map +0 -1
  285. package/dist/assets/round-volume-to-avoid-stack-overflow.js.map +0 -1
  286. package/dist/assets/sanitize-filename.d.ts.map +0 -1
  287. package/dist/assets/sanitize-filename.js.map +0 -1
  288. package/dist/assets/sanitize-filepath.d.ts.map +0 -1
  289. package/dist/assets/sanitize-filepath.js.map +0 -1
  290. package/dist/assets/truncate-utf8-bytes.d.ts.map +0 -1
  291. package/dist/assets/truncate-utf8-bytes.js.map +0 -1
  292. package/dist/assets/types.d.ts.map +0 -1
  293. package/dist/assets/types.js.map +0 -1
  294. package/dist/browser-log.d.ts.map +0 -1
  295. package/dist/browser-log.js.map +0 -1
  296. package/dist/calculate-ffmpeg-filters.d.ts.map +0 -1
  297. package/dist/calculate-ffmpeg-filters.js.map +0 -1
  298. package/dist/can-use-parallel-encoding.d.ts.map +0 -1
  299. package/dist/can-use-parallel-encoding.js.map +0 -1
  300. package/dist/chunk.d.ts.map +0 -1
  301. package/dist/chunk.js.map +0 -1
  302. package/dist/combine-videos.d.ts.map +0 -1
  303. package/dist/combine-videos.js.map +0 -1
  304. package/dist/convert-to-pcm.d.ts.map +0 -1
  305. package/dist/convert-to-pcm.js.map +0 -1
  306. package/dist/create-ffmpeg-complex-filter.d.ts.map +0 -1
  307. package/dist/create-ffmpeg-complex-filter.js.map +0 -1
  308. package/dist/create-ffmpeg-merge-filter.d.ts.map +0 -1
  309. package/dist/create-ffmpeg-merge-filter.js.map +0 -1
  310. package/dist/create-silent-audio.d.ts.map +0 -1
  311. package/dist/create-silent-audio.js.map +0 -1
  312. package/dist/cycle-browser-tabs.d.ts.map +0 -1
  313. package/dist/cycle-browser-tabs.js.map +0 -1
  314. package/dist/delay-render-embedded-stack.d.ts.map +0 -1
  315. package/dist/delay-render-embedded-stack.js.map +0 -1
  316. package/dist/delete-directory.d.ts.map +0 -1
  317. package/dist/delete-directory.js.map +0 -1
  318. package/dist/ensure-frames-in-order.d.ts.map +0 -1
  319. package/dist/ensure-frames-in-order.js.map +0 -1
  320. package/dist/ensure-output-directory.d.ts.map +0 -1
  321. package/dist/ensure-output-directory.js.map +0 -1
  322. package/dist/error-handling/handle-javascript-exception.d.ts.map +0 -1
  323. package/dist/error-handling/handle-javascript-exception.js.map +0 -1
  324. package/dist/error-handling/symbolicate-error.d.ts.map +0 -1
  325. package/dist/error-handling/symbolicate-error.js.map +0 -1
  326. package/dist/error-handling/symbolicateable-error.d.ts.map +0 -1
  327. package/dist/error-handling/symbolicateable-error.js.map +0 -1
  328. package/dist/ffmpeg-filter-file.d.ts.map +0 -1
  329. package/dist/ffmpeg-filter-file.js.map +0 -1
  330. package/dist/ffmpeg-flags.d.ts.map +0 -1
  331. package/dist/ffmpeg-flags.js.map +0 -1
  332. package/dist/get-audio-codec-name.d.ts.map +0 -1
  333. package/dist/get-audio-codec-name.js.map +0 -1
  334. package/dist/get-browser-instance.d.ts.map +0 -1
  335. package/dist/get-browser-instance.js.map +0 -1
  336. package/dist/get-codec-name.d.ts.map +0 -1
  337. package/dist/get-codec-name.js.map +0 -1
  338. package/dist/get-compositions.d.ts.map +0 -1
  339. package/dist/get-compositions.js.map +0 -1
  340. package/dist/get-concurrency.d.ts.map +0 -1
  341. package/dist/get-concurrency.js.map +0 -1
  342. package/dist/get-duration-from-frame-range.d.ts.map +0 -1
  343. package/dist/get-duration-from-frame-range.js.map +0 -1
  344. package/dist/get-extension-from-codec.d.ts.map +0 -1
  345. package/dist/get-extension-from-codec.js.map +0 -1
  346. package/dist/get-frame-to-render.d.ts.map +0 -1
  347. package/dist/get-frame-to-render.js.map +0 -1
  348. package/dist/get-local-browser-executable.d.ts.map +0 -1
  349. package/dist/get-local-browser-executable.js.map +0 -1
  350. package/dist/get-port.d.ts.map +0 -1
  351. package/dist/get-port.js.map +0 -1
  352. package/dist/get-prores-profile-name.d.ts.map +0 -1
  353. package/dist/get-prores-profile-name.js.map +0 -1
  354. package/dist/image-format.d.ts.map +0 -1
  355. package/dist/image-format.js.map +0 -1
  356. package/dist/index.d.ts.map +0 -1
  357. package/dist/index.js.map +0 -1
  358. package/dist/is-serve-url.d.ts.map +0 -1
  359. package/dist/is-serve-url.js.map +0 -1
  360. package/dist/legacy-webpack-config.d.ts.map +0 -1
  361. package/dist/legacy-webpack-config.js.map +0 -1
  362. package/dist/make-assets-download-dir.d.ts +0 -1
  363. package/dist/make-assets-download-dir.d.ts.map +0 -1
  364. package/dist/make-assets-download-dir.js +0 -8
  365. package/dist/make-assets-download-dir.js.map +0 -1
  366. package/dist/merge-audio-track.d.ts.map +0 -1
  367. package/dist/merge-audio-track.js.map +0 -1
  368. package/dist/normalize-serve-url.d.ts.map +0 -1
  369. package/dist/normalize-serve-url.js.map +0 -1
  370. package/dist/open-browser.d.ts.map +0 -1
  371. package/dist/open-browser.js.map +0 -1
  372. package/dist/p-limit.d.ts.map +0 -1
  373. package/dist/p-limit.js.map +0 -1
  374. package/dist/parse-browser-error-stack.d.ts.map +0 -1
  375. package/dist/parse-browser-error-stack.js.map +0 -1
  376. package/dist/parse-ffmpeg-progress.d.ts.map +0 -1
  377. package/dist/parse-ffmpeg-progress.js.map +0 -1
  378. package/dist/pool.d.ts.map +0 -1
  379. package/dist/pool.js.map +0 -1
  380. package/dist/prepare-server.d.ts.map +0 -1
  381. package/dist/prepare-server.js.map +0 -1
  382. package/dist/preprocess-audio-track.d.ts.map +0 -1
  383. package/dist/preprocess-audio-track.js.map +0 -1
  384. package/dist/prespawn-ffmpeg.d.ts.map +0 -1
  385. package/dist/prespawn-ffmpeg.js.map +0 -1
  386. package/dist/provide-screenshot.d.ts.map +0 -1
  387. package/dist/provide-screenshot.js.map +0 -1
  388. package/dist/puppeteer-evaluate.d.ts.map +0 -1
  389. package/dist/puppeteer-evaluate.js.map +0 -1
  390. package/dist/puppeteer-screenshot.d.ts.map +0 -1
  391. package/dist/puppeteer-screenshot.js.map +0 -1
  392. package/dist/render-frames.d.ts.map +0 -1
  393. package/dist/render-frames.js.map +0 -1
  394. package/dist/render-media.d.ts.map +0 -1
  395. package/dist/render-media.js.map +0 -1
  396. package/dist/render-still.d.ts.map +0 -1
  397. package/dist/render-still.js.map +0 -1
  398. package/dist/resolve-asset-src.d.ts.map +0 -1
  399. package/dist/resolve-asset-src.js.map +0 -1
  400. package/dist/sample-rate.d.ts.map +0 -1
  401. package/dist/sample-rate.js.map +0 -1
  402. package/dist/screenshot-dom-element.d.ts.map +0 -1
  403. package/dist/screenshot-dom-element.js.map +0 -1
  404. package/dist/screenshot-task.d.ts.map +0 -1
  405. package/dist/screenshot-task.js.map +0 -1
  406. package/dist/seek-to-frame.d.ts.map +0 -1
  407. package/dist/seek-to-frame.js.map +0 -1
  408. package/dist/serve-static.d.ts.map +0 -1
  409. package/dist/serve-static.js.map +0 -1
  410. package/dist/set-props-and-env.d.ts.map +0 -1
  411. package/dist/set-props-and-env.js.map +0 -1
  412. package/dist/stitch-frames-to-video.d.ts.map +0 -1
  413. package/dist/stitch-frames-to-video.js.map +0 -1
  414. package/dist/stringify-ffmpeg-filter.d.ts.map +0 -1
  415. package/dist/stringify-ffmpeg-filter.js.map +0 -1
  416. package/dist/symbolicate-stacktrace.d.ts.map +0 -1
  417. package/dist/symbolicate-stacktrace.js.map +0 -1
  418. package/dist/tmp-dir.d.ts.map +0 -1
  419. package/dist/tmp-dir.js.map +0 -1
  420. package/dist/types.d.ts.map +0 -1
  421. package/dist/types.js.map +0 -1
  422. package/dist/validate-even-dimensions-with-codec.d.ts.map +0 -1
  423. package/dist/validate-even-dimensions-with-codec.js.map +0 -1
  424. package/dist/validate-ffmpeg.d.ts.map +0 -1
  425. package/dist/validate-ffmpeg.js.map +0 -1
  426. package/dist/validate-puppeteer-timeout.d.ts.map +0 -1
  427. package/dist/validate-puppeteer-timeout.js.map +0 -1
  428. package/dist/validate-scale.d.ts.map +0 -1
  429. 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,20 +1,24 @@
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 waitForAssetToBeDownloaded: (src: string, to: string) => Promise<void>;
6
- export declare const markAllAssetsAsDownloaded: () => void;
7
- 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, contentType, }: {
8
15
  src: string;
9
16
  downloadDir: string;
17
+ contentDisposition: string | null;
18
+ contentType: string | null;
10
19
  }) => string;
11
- export declare const downloadAndMapAssetsToFileUrl: ({ asset, downloadDir, onDownload, }: {
20
+ export declare const downloadAndMapAssetsToFileUrl: ({ asset, onDownload, downloadMap, }: {
12
21
  asset: TAsset;
13
- downloadDir: string;
14
22
  onDownload: RenderMediaOnDownload;
23
+ downloadMap: DownloadMap;
15
24
  }) => Promise<TAsset>;
16
- export declare const startDownloadForSrc: ({ src, downloadDir, onDownload, }: {
17
- src: string;
18
- downloadDir: string;
19
- onDownload: RenderMediaOnDownload;
20
- }) => Promise<string>;
@@ -1,50 +1,77 @@
1
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
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.startDownloadForSrc = exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = exports.waitForAssetToBeDownloaded = void 0;
29
+ exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = exports.downloadAsset = void 0;
7
30
  const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
31
+ const path_1 = __importStar(require("path"));
9
32
  const remotion_1 = require("remotion");
33
+ const compress_assets_1 = require("../compress-assets");
10
34
  const ensure_output_directory_1 = require("../ensure-output-directory");
35
+ const mime_types_1 = require("../mime-types");
11
36
  const download_file_1 = require("./download-file");
12
37
  const sanitize_filepath_1 = require("./sanitize-filepath");
13
- const isDownloadingMap = {};
14
- const hasBeenDownloadedMap = {};
15
- const listeners = {};
16
- const waitForAssetToBeDownloaded = (src, to) => {
17
- var _a;
18
- if ((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[to]) {
19
- return Promise.resolve();
38
+ const waitForAssetToBeDownloaded = ({ src, downloadDir, downloadMap, }) => {
39
+ var _a, _b;
40
+ if ((_a = downloadMap.hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
41
+ return Promise.resolve((_b = downloadMap.hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir]);
20
42
  }
21
- if (!listeners[src]) {
22
- listeners[src] = {};
43
+ if (!downloadMap.listeners[src]) {
44
+ downloadMap.listeners[src] = {};
23
45
  }
24
- if (!listeners[src][to]) {
25
- listeners[src][to] = [];
46
+ if (!downloadMap.listeners[src][downloadDir]) {
47
+ downloadMap.listeners[src][downloadDir] = [];
26
48
  }
27
49
  return new Promise((resolve) => {
28
- listeners[src][to].push(() => resolve());
50
+ downloadMap.listeners[src][downloadDir].push(() => {
51
+ const srcMap = downloadMap.hasBeenDownloadedMap[src];
52
+ if (!srcMap || !srcMap[downloadDir]) {
53
+ throw new Error('Expected file for ' + src + 'to be available in ' + downloadDir);
54
+ }
55
+ resolve(srcMap[downloadDir]);
56
+ });
29
57
  });
30
58
  };
31
- exports.waitForAssetToBeDownloaded = waitForAssetToBeDownloaded;
32
- const notifyAssetIsDownloaded = (src, to) => {
33
- if (!listeners[src]) {
34
- listeners[src] = {};
59
+ const notifyAssetIsDownloaded = ({ src, downloadDir, to, downloadMap, }) => {
60
+ if (!downloadMap.listeners[src]) {
61
+ downloadMap.listeners[src] = {};
35
62
  }
36
- if (!listeners[src][to]) {
37
- listeners[src][to] = [];
63
+ if (!downloadMap.listeners[src][downloadDir]) {
64
+ downloadMap.listeners[src][downloadDir] = [];
38
65
  }
39
- listeners[src][to].forEach((fn) => fn());
40
- if (!isDownloadingMap[src]) {
41
- isDownloadingMap[src] = {};
66
+ if (!downloadMap.isDownloadingMap[src]) {
67
+ downloadMap.isDownloadingMap[src] = {};
42
68
  }
43
- isDownloadingMap[src][to] = false;
44
- if (!hasBeenDownloadedMap[src]) {
45
- hasBeenDownloadedMap[src] = {};
69
+ downloadMap.isDownloadingMap[src][downloadDir] = false;
70
+ if (!downloadMap.hasBeenDownloadedMap[src]) {
71
+ downloadMap.hasBeenDownloadedMap[src] = {};
46
72
  }
47
- hasBeenDownloadedMap[src][to] = true;
73
+ downloadMap.hasBeenDownloadedMap[src][downloadDir] = to;
74
+ downloadMap.listeners[src][downloadDir].forEach((fn) => fn());
48
75
  };
49
76
  const validateMimeType = (mimeType, src) => {
50
77
  if (!mimeType.includes('/')) {
@@ -85,21 +112,42 @@ function validateBufferEncoding(potentialEncoding, dataUrl) {
85
112
  throw new TypeError(errMessage);
86
113
  }
87
114
  }
88
- const downloadAsset = async (src, to, onDownload) => {
89
- var _a, _b;
90
- if ((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[to]) {
91
- return;
115
+ const downloadAsset = async ({ src, onDownload, downloadMap, }) => {
116
+ var _a, _b, _c;
117
+ if ((0, compress_assets_1.isAssetCompressed)(src)) {
118
+ return src;
92
119
  }
93
- if ((_b = isDownloadingMap[src]) === null || _b === void 0 ? void 0 : _b[to]) {
94
- return (0, exports.waitForAssetToBeDownloaded)(src, to);
120
+ const { downloadDir } = downloadMap;
121
+ if ((_a = downloadMap.hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
122
+ const claimedDownloadLocation = (_b = downloadMap.hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir];
123
+ // 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
124
+ if (fs_1.default.existsSync(claimedDownloadLocation)) {
125
+ return claimedDownloadLocation;
126
+ }
127
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
128
+ downloadMap.hasBeenDownloadedMap[src][downloadDir] = null;
129
+ if (!downloadMap.isDownloadingMap[src]) {
130
+ downloadMap.isDownloadingMap[src] = {};
131
+ }
132
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
133
+ downloadMap.isDownloadingMap[src][downloadDir] = false;
95
134
  }
96
- if (!isDownloadingMap[src]) {
97
- isDownloadingMap[src] = {};
135
+ if ((_c = downloadMap.isDownloadingMap[src]) === null || _c === void 0 ? void 0 : _c[downloadDir]) {
136
+ return waitForAssetToBeDownloaded({ downloadMap, src, downloadDir });
98
137
  }
99
- isDownloadingMap[src][to] = true;
138
+ if (!downloadMap.isDownloadingMap[src]) {
139
+ downloadMap.isDownloadingMap[src] = {};
140
+ }
141
+ downloadMap.isDownloadingMap[src][downloadDir] = true;
100
142
  const onProgress = onDownload(src);
101
- (0, ensure_output_directory_1.ensureOutputDirectory)(to);
102
143
  if (src.startsWith('data:')) {
144
+ const output = (0, exports.getSanitizedFilenameForAssetUrl)({
145
+ contentDisposition: null,
146
+ downloadDir,
147
+ src,
148
+ contentType: null,
149
+ });
150
+ (0, ensure_output_directory_1.ensureOutputDirectory)(output);
103
151
  const [assetDetails, assetData] = src.substring('data:'.length).split(',');
104
152
  if (!assetDetails.includes(';')) {
105
153
  const errMessage = [
@@ -114,44 +162,84 @@ const downloadAsset = async (src, to, onDownload) => {
114
162
  validateMimeType(mimeType, src);
115
163
  validateBufferEncoding(encoding, src);
116
164
  const buff = Buffer.from(assetData, encoding);
117
- await fs_1.default.promises.writeFile(to, buff);
118
- notifyAssetIsDownloaded(src, to);
119
- return;
165
+ await fs_1.default.promises.writeFile(output, buff);
166
+ notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to: output });
167
+ return output;
120
168
  }
121
- await (0, download_file_1.downloadFile)(src, to, ({ progress }) => {
122
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
123
- percent: progress,
124
- });
169
+ const { to } = await (0, download_file_1.downloadFile)({
170
+ url: src,
171
+ onProgress: (progress) => {
172
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(progress);
173
+ },
174
+ to: (contentDisposition, contentType) => (0, exports.getSanitizedFilenameForAssetUrl)({
175
+ contentDisposition,
176
+ downloadDir,
177
+ src,
178
+ contentType,
179
+ }),
125
180
  });
126
- notifyAssetIsDownloaded(src, to);
181
+ notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to });
182
+ return to;
127
183
  };
128
- const markAllAssetsAsDownloaded = () => {
129
- Object.keys(hasBeenDownloadedMap).forEach((key) => {
130
- delete hasBeenDownloadedMap[key];
184
+ exports.downloadAsset = downloadAsset;
185
+ const markAllAssetsAsDownloaded = (downloadMap) => {
186
+ Object.keys(downloadMap.hasBeenDownloadedMap).forEach((key) => {
187
+ delete downloadMap.hasBeenDownloadedMap[key];
131
188
  });
132
- Object.keys(isDownloadingMap).forEach((key) => {
133
- delete isDownloadingMap[key];
189
+ Object.keys(downloadMap.isDownloadingMap).forEach((key) => {
190
+ delete downloadMap.isDownloadingMap[key];
134
191
  });
135
192
  };
136
193
  exports.markAllAssetsAsDownloaded = markAllAssetsAsDownloaded;
137
- const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, }) => {
138
- if (remotion_1.Internals.AssetCompression.isAssetCompressed(src)) {
139
- return src;
194
+ const getFilename = ({ contentDisposition, src, contentType, }) => {
195
+ const filenameProbe = 'filename=';
196
+ if (contentDisposition === null || contentDisposition === void 0 ? void 0 : contentDisposition.includes(filenameProbe)) {
197
+ const start = contentDisposition.indexOf(filenameProbe);
198
+ const onlyFromFileName = contentDisposition.substring(start + filenameProbe.length);
199
+ const hasSemi = onlyFromFileName.indexOf(';');
200
+ if (hasSemi === -1) {
201
+ return { pathname: onlyFromFileName.trim(), search: '' };
202
+ }
203
+ return {
204
+ search: '',
205
+ pathname: onlyFromFileName.substring(0, hasSemi).trim(),
206
+ };
140
207
  }
141
208
  const { pathname, search } = new URL(src);
209
+ const ext = (0, path_1.extname)(pathname);
210
+ // Has no file extension, check if we can derive it from contentType
211
+ if (!ext && contentType) {
212
+ const matchedExt = (0, mime_types_1.getExt)(contentType);
213
+ return {
214
+ pathname: `${pathname}.${matchedExt}`,
215
+ search,
216
+ };
217
+ }
218
+ return { pathname, search };
219
+ };
220
+ const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, contentDisposition, contentType, }) => {
221
+ if ((0, compress_assets_1.isAssetCompressed)(src)) {
222
+ return src;
223
+ }
224
+ const { pathname, search } = getFilename({
225
+ contentDisposition,
226
+ contentType,
227
+ src,
228
+ });
142
229
  const split = pathname.split('.');
143
230
  const fileExtension = split.length > 1 && split[split.length - 1]
144
231
  ? `.${split[split.length - 1]}`
145
232
  : '';
146
233
  const hashedFileName = String((0, remotion_1.random)(`${pathname}${search}`)).replace('0.', '');
147
- return path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(hashedFileName + fileExtension));
234
+ const filename = hashedFileName + fileExtension;
235
+ return path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(filename));
148
236
  };
149
237
  exports.getSanitizedFilenameForAssetUrl = getSanitizedFilenameForAssetUrl;
150
- const downloadAndMapAssetsToFileUrl = async ({ asset, downloadDir, onDownload, }) => {
151
- const newSrc = await (0, exports.startDownloadForSrc)({
238
+ const downloadAndMapAssetsToFileUrl = async ({ asset, onDownload, downloadMap, }) => {
239
+ const newSrc = await (0, exports.downloadAsset)({
152
240
  src: asset.src,
153
- downloadDir,
154
241
  onDownload,
242
+ downloadMap,
155
243
  });
156
244
  return {
157
245
  ...asset,
@@ -159,11 +247,3 @@ const downloadAndMapAssetsToFileUrl = async ({ asset, downloadDir, onDownload, }
159
247
  };
160
248
  };
161
249
  exports.downloadAndMapAssetsToFileUrl = downloadAndMapAssetsToFileUrl;
162
- const startDownloadForSrc = async ({ src, downloadDir, onDownload, }) => {
163
- const newSrc = (0, exports.getSanitizedFilenameForAssetUrl)({ downloadDir, src });
164
- if (!remotion_1.Internals.AssetCompression.isAssetCompressed(newSrc)) {
165
- await downloadAsset(src, newSrc, onDownload);
166
- }
167
- return newSrc;
168
- };
169
- exports.startDownloadForSrc = startDownloadForSrc;
@@ -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, contentType: 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,40 @@
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, _b;
12
+ const contentDisposition = (_a = res.headers['content-disposition']) !== null && _a !== void 0 ? _a : null;
13
+ const contentType = (_b = res.headers['content-type']) !== null && _b !== void 0 ? _b : null;
14
+ const to = toFn(contentDisposition, contentType);
15
+ (0, ensure_output_directory_1.ensureOutputDirectory)(to);
16
+ const sizeHeader = res.headers['content-length'];
17
+ const totalSize = typeof sizeHeader === 'undefined' ? null : Number(sizeHeader);
11
18
  const writeStream = (0, fs_1.createWriteStream)(to);
19
+ let downloaded = 0;
12
20
  // Listen to 'close' event instead of more
13
21
  // concise method to avoid this problem
14
22
  // https://github.com/remotion-dev/remotion/issues/384#issuecomment-844398183
15
- writeStream.on('close', () => resolve({ sizeInBytes: totalSize }));
23
+ writeStream.on('close', () => {
24
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
25
+ downloaded,
26
+ percent: 1,
27
+ totalSize: downloaded,
28
+ });
29
+ return resolve({ sizeInBytes: downloaded, to });
30
+ });
16
31
  writeStream.on('error', (err) => reject(err));
17
- let downloaded = 0;
32
+ res.on('error', (err) => reject(err));
18
33
  res.pipe(writeStream).on('error', (err) => reject(err));
19
34
  res.on('data', (d) => {
20
35
  downloaded += d.length;
21
36
  onProgress === null || onProgress === void 0 ? void 0 : onProgress({
22
37
  downloaded,
23
- progress: downloaded / totalSize,
38
+ percent: totalSize === null ? null : downloaded / totalSize,
24
39
  totalSize,
25
40
  });
26
41
  });
@@ -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,11 @@
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, trimLeft, }: {
7
+ export declare const ffmpegVolumeExpression: ({ volume, fps, trimLeft, }: {
8
8
  volume: AssetVolume;
9
- startInVideo: number;
10
9
  trimLeft: number;
11
10
  fps: number;
12
11
  }) => FfmpegVolumeExpression;
@@ -43,7 +43,7 @@ const ffmpegBuildVolumeExpression = (arr, delay, fps) => {
43
43
  const [volume, frames] = first;
44
44
  return ffmpegIfOrElse(ffmpegIsOneOfFrames({ frames, trimLeft: delay, fps }), String(volume), ffmpegBuildVolumeExpression(rest, delay, fps));
45
45
  };
46
- const ffmpegVolumeExpression = ({ volume, startInVideo, fps, trimLeft, }) => {
46
+ const ffmpegVolumeExpression = ({ volume, fps, trimLeft, }) => {
47
47
  // If it's a static volume, we return it and tell
48
48
  // FFMPEG it only has to evaluate it once
49
49
  if (typeof volume === 'number') {
@@ -55,7 +55,6 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, trimLeft, }) => {
55
55
  if ([...new Set(volume)].length === 1) {
56
56
  return (0, exports.ffmpegVolumeExpression)({
57
57
  volume: volume[0],
58
- startInVideo,
59
58
  fps,
60
59
  trimLeft,
61
60
  });
@@ -76,7 +75,7 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, trimLeft, }) => {
76
75
  if (!volumeMap[actualVolume]) {
77
76
  volumeMap[actualVolume] = [];
78
77
  }
79
- volumeMap[actualVolume].push(frame + startInVideo);
78
+ volumeMap[actualVolume].push(frame);
80
79
  });
81
80
  // Sort the map so that the most common volume is last
82
81
  // this is going to be the else statement so the expression is short
@@ -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>;