@open-take/compositor 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/dist/cdp-CzT5BKNY.js +3 -0
  2. package/dist/cdp-QXbQfXna.js +373 -0
  3. package/dist/cdp-QXbQfXna.js.map +1 -0
  4. package/dist/index.d.ts +4327 -195
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +26282 -160
  7. package/dist/index.js.map +1 -1
  8. package/dist/server-841PMF2H.js +163 -0
  9. package/dist/server-841PMF2H.js.map +1 -0
  10. package/dist/server-C2aVv4-t.js +3 -0
  11. package/kit/audio.mjs +2366 -0
  12. package/kit/camera.js +587 -0
  13. package/kit/cursor.js +264 -0
  14. package/kit/cut.js +427 -0
  15. package/kit/draw.js +346 -0
  16. package/kit/look.js +589 -0
  17. package/kit/map.js +170 -0
  18. package/kit/media.js +3568 -0
  19. package/kit/motion.js +1115 -0
  20. package/kit/seams.js +1006 -0
  21. package/kit/stage.js +923 -0
  22. package/kit/time.js +812 -0
  23. package/kit/world.js +1072 -0
  24. package/package.json +7 -3
  25. package/src/ffmpeg.ts +63 -0
  26. package/src/film/beats.ts +1285 -0
  27. package/src/film/carry.ts +221 -0
  28. package/src/film/changes.ts +330 -0
  29. package/src/film/check.ts +996 -0
  30. package/src/film/clock.ts +2530 -0
  31. package/src/film/components-probe.ts +809 -0
  32. package/src/film/components.ts +1566 -0
  33. package/src/film/frames.ts +389 -0
  34. package/src/film/gallery.ts +3276 -0
  35. package/src/film/kit.ts +515 -0
  36. package/src/film/layout.ts +701 -0
  37. package/src/film/listen.ts +1979 -0
  38. package/src/film/look.ts +3829 -0
  39. package/src/film/materials.ts +976 -0
  40. package/src/film/moving.ts +248 -0
  41. package/src/film/part-files.ts +729 -0
  42. package/src/film/picture.ts +74 -0
  43. package/src/film/probe-text.ts +843 -0
  44. package/src/film/probe.ts +3456 -0
  45. package/src/film/provenance.ts +596 -0
  46. package/src/film/render.ts +2447 -0
  47. package/src/film/report.ts +1631 -0
  48. package/src/film/sheet.ts +156 -0
  49. package/src/film/study-declared.ts +123 -0
  50. package/src/film/study-picture.ts +791 -0
  51. package/src/film/study-sound.ts +416 -0
  52. package/src/film/study.ts +864 -0
  53. package/src/film/tuning.ts +155 -0
  54. package/src/film/viewer.ts +174 -0
  55. package/src/html/cdp.ts +575 -0
  56. package/src/html/server.ts +208 -0
  57. package/src/index.ts +202 -0
  58. package/src/launch-render.ts +3 -2
  59. package/src/math.ts +3 -3
  60. package/src/mjpeg-matroska.ts +228 -0
  61. package/src/render.ts +6 -4
  62. package/src/state-diff.ts +215 -0
  63. package/src/state-index.ts +99 -0
  64. package/src/types.ts +59 -1
  65. package/starter/PLAN.md +84 -0
  66. package/starter/START.md +460 -0
  67. package/starter/lib/anim.js +760 -0
  68. package/starter/lib/devices.js +1402 -0
  69. package/starter/lib/handoff.js +421 -0
  70. package/starter/lib/hud.js +1879 -0
  71. package/starter/lib/measure.mjs +154 -0
  72. package/starter/lib/moves.js +1095 -0
  73. package/starter/lib/palette.mjs +803 -0
  74. package/starter/lib/physics-seeds.mjs +198 -0
  75. package/starter/lib/physics.js +738 -0
  76. package/starter/lib/sampler.mjs +242 -0
  77. package/starter/lib/solid.js +727 -0
  78. package/starter/lib/space.js +1227 -0
  79. package/starter/lib/swarm.js +1398 -0
  80. package/starter/reference/motion.md +276 -0
  81. package/starter/reference/structure.md +466 -0
  82. package/starter/reference/travel/motion.md +433 -0
  83. package/starter/reference/travel/sound.md +241 -0
  84. package/starter/reference/travel/structure.md +518 -0
  85. package/starter/samples/NOTICE.txt +55 -0
  86. package/starter/samples/celli/celli_24_1.opus +0 -0
  87. package/starter/samples/celli/celli_24_3.opus +0 -0
  88. package/starter/samples/celli/celli_28_1.opus +0 -0
  89. package/starter/samples/celli/celli_28_3.opus +0 -0
  90. package/starter/samples/celli/celli_31_1.opus +0 -0
  91. package/starter/samples/celli/celli_31_3.opus +0 -0
  92. package/starter/samples/celli/celli_35_1.opus +0 -0
  93. package/starter/samples/celli/celli_35_3.opus +0 -0
  94. package/starter/samples/celli/celli_38_1.opus +0 -0
  95. package/starter/samples/celli/celli_38_3.opus +0 -0
  96. package/starter/samples/celli/celli_41_1.opus +0 -0
  97. package/starter/samples/celli/celli_41_3.opus +0 -0
  98. package/starter/samples/celli/celli_45_1.opus +0 -0
  99. package/starter/samples/celli/celli_45_3.opus +0 -0
  100. package/starter/samples/celli/celli_48_1.opus +0 -0
  101. package/starter/samples/celli/celli_48_3.opus +0 -0
  102. package/starter/samples/celli/celli_52_1.opus +0 -0
  103. package/starter/samples/celli/celli_52_3.opus +0 -0
  104. package/starter/samples/celli/celli_55_1.opus +0 -0
  105. package/starter/samples/celli/celli_55_3.opus +0 -0
  106. package/starter/samples/celli/celli_59_1.opus +0 -0
  107. package/starter/samples/celli/celli_59_3.opus +0 -0
  108. package/starter/samples/celli/celli_62_1.opus +0 -0
  109. package/starter/samples/celli/celli_62_3.opus +0 -0
  110. package/starter/samples/celli/celli_65_1.opus +0 -0
  111. package/starter/samples/celli/celli_65_3.opus +0 -0
  112. package/starter/samples/crash/crash_f_1.flac +0 -0
  113. package/starter/samples/crash/crash_fff_1.flac +0 -0
  114. package/starter/samples/ebass/ebass_0_x.flac +0 -0
  115. package/starter/samples/ebass/ebass_10_x.flac +0 -0
  116. package/starter/samples/ebass/ebass_11_x.flac +0 -0
  117. package/starter/samples/ebass/ebass_1_x.flac +0 -0
  118. package/starter/samples/ebass/ebass_2_x.flac +0 -0
  119. package/starter/samples/ebass/ebass_3_x.flac +0 -0
  120. package/starter/samples/ebass/ebass_4_x.flac +0 -0
  121. package/starter/samples/ebass/ebass_5_x.flac +0 -0
  122. package/starter/samples/ebass/ebass_6_x.flac +0 -0
  123. package/starter/samples/ebass/ebass_7_x.flac +0 -0
  124. package/starter/samples/ebass/ebass_8_x.flac +0 -0
  125. package/starter/samples/ebass/ebass_9_x.flac +0 -0
  126. package/starter/samples/ek_clap/ek_clap_1_1.flac +0 -0
  127. package/starter/samples/ek_hat/ek_hat_1_1.flac +0 -0
  128. package/starter/samples/ek_hat/ek_hat_1_2.flac +0 -0
  129. package/starter/samples/ek_kick/ek_kick_1_1.flac +0 -0
  130. package/starter/samples/ek_kick/ek_kick_1_2.flac +0 -0
  131. package/starter/samples/glock/glock_67_x.flac +0 -0
  132. package/starter/samples/glock/glock_72_x.flac +0 -0
  133. package/starter/samples/glock/glock_79_x.flac +0 -0
  134. package/starter/samples/glock/glock_84_x.flac +0 -0
  135. package/starter/samples/glock/glock_91_x.flac +0 -0
  136. package/starter/samples/glock/glock_96_x.flac +0 -0
  137. package/starter/samples/harp/harp_101_f.opus +0 -0
  138. package/starter/samples/harp/harp_28_f.opus +0 -0
  139. package/starter/samples/harp/harp_31_mp.opus +0 -0
  140. package/starter/samples/harp/harp_35_mf.opus +0 -0
  141. package/starter/samples/harp/harp_38_mf.opus +0 -0
  142. package/starter/samples/harp/harp_41_mf.opus +0 -0
  143. package/starter/samples/harp/harp_45_mf.opus +0 -0
  144. package/starter/samples/harp/harp_48_mf.opus +0 -0
  145. package/starter/samples/harp/harp_52_mf.opus +0 -0
  146. package/starter/samples/harp/harp_55_mf.opus +0 -0
  147. package/starter/samples/harp/harp_59_mf.opus +0 -0
  148. package/starter/samples/harp/harp_62_mf.opus +0 -0
  149. package/starter/samples/harp/harp_65_mf.opus +0 -0
  150. package/starter/samples/harp/harp_69_mf.opus +0 -0
  151. package/starter/samples/harp/harp_72_mf.opus +0 -0
  152. package/starter/samples/harp/harp_76_mf.opus +0 -0
  153. package/starter/samples/harp/harp_79_mf.opus +0 -0
  154. package/starter/samples/harp/harp_83_mf.opus +0 -0
  155. package/starter/samples/harp/harp_86_mf.opus +0 -0
  156. package/starter/samples/harp/harp_89_mf.opus +0 -0
  157. package/starter/samples/harp/harp_93_mf.opus +0 -0
  158. package/starter/samples/harp/harp_95_mf.opus +0 -0
  159. package/starter/samples/harp/harp_98_f.opus +0 -0
  160. package/starter/samples/manifest.json +2951 -0
  161. package/starter/samples/marimba/marimba_29_x.flac +0 -0
  162. package/starter/samples/marimba/marimba_36_x.flac +0 -0
  163. package/starter/samples/marimba/marimba_43_x.flac +0 -0
  164. package/starter/samples/marimba/marimba_47_x.flac +0 -0
  165. package/starter/samples/marimba/marimba_53_x.flac +0 -0
  166. package/starter/samples/marimba/marimba_60_x.flac +0 -0
  167. package/starter/samples/marimba/marimba_67_x.flac +0 -0
  168. package/starter/samples/marimba/marimba_71_x.flac +0 -0
  169. package/starter/samples/marimba/marimba_77_x.flac +0 -0
  170. package/starter/samples/marimba/marimba_84_x.flac +0 -0
  171. package/starter/samples/piano/piano_102_12.opus +0 -0
  172. package/starter/samples/piano/piano_102_16.opus +0 -0
  173. package/starter/samples/piano/piano_102_4.opus +0 -0
  174. package/starter/samples/piano/piano_102_8.opus +0 -0
  175. package/starter/samples/piano/piano_105_12.opus +0 -0
  176. package/starter/samples/piano/piano_105_16.opus +0 -0
  177. package/starter/samples/piano/piano_105_4.opus +0 -0
  178. package/starter/samples/piano/piano_105_8.opus +0 -0
  179. package/starter/samples/piano/piano_108_12.opus +0 -0
  180. package/starter/samples/piano/piano_108_16.opus +0 -0
  181. package/starter/samples/piano/piano_108_4.opus +0 -0
  182. package/starter/samples/piano/piano_108_8.opus +0 -0
  183. package/starter/samples/piano/piano_21_12.opus +0 -0
  184. package/starter/samples/piano/piano_21_16.opus +0 -0
  185. package/starter/samples/piano/piano_21_4.opus +0 -0
  186. package/starter/samples/piano/piano_21_8.opus +0 -0
  187. package/starter/samples/piano/piano_24_12.opus +0 -0
  188. package/starter/samples/piano/piano_24_16.opus +0 -0
  189. package/starter/samples/piano/piano_24_4.opus +0 -0
  190. package/starter/samples/piano/piano_24_8.opus +0 -0
  191. package/starter/samples/piano/piano_27_12.opus +0 -0
  192. package/starter/samples/piano/piano_27_16.opus +0 -0
  193. package/starter/samples/piano/piano_27_4.opus +0 -0
  194. package/starter/samples/piano/piano_27_8.opus +0 -0
  195. package/starter/samples/piano/piano_30_12.opus +0 -0
  196. package/starter/samples/piano/piano_30_16.opus +0 -0
  197. package/starter/samples/piano/piano_30_4.opus +0 -0
  198. package/starter/samples/piano/piano_30_8.opus +0 -0
  199. package/starter/samples/piano/piano_33_12.opus +0 -0
  200. package/starter/samples/piano/piano_33_16.opus +0 -0
  201. package/starter/samples/piano/piano_33_4.opus +0 -0
  202. package/starter/samples/piano/piano_33_8.opus +0 -0
  203. package/starter/samples/piano/piano_36_12.opus +0 -0
  204. package/starter/samples/piano/piano_36_16.opus +0 -0
  205. package/starter/samples/piano/piano_36_4.opus +0 -0
  206. package/starter/samples/piano/piano_36_8.opus +0 -0
  207. package/starter/samples/piano/piano_39_12.opus +0 -0
  208. package/starter/samples/piano/piano_39_16.opus +0 -0
  209. package/starter/samples/piano/piano_39_4.opus +0 -0
  210. package/starter/samples/piano/piano_39_8.opus +0 -0
  211. package/starter/samples/piano/piano_42_12.opus +0 -0
  212. package/starter/samples/piano/piano_42_16.opus +0 -0
  213. package/starter/samples/piano/piano_42_4.opus +0 -0
  214. package/starter/samples/piano/piano_42_8.opus +0 -0
  215. package/starter/samples/piano/piano_45_12.opus +0 -0
  216. package/starter/samples/piano/piano_45_16.opus +0 -0
  217. package/starter/samples/piano/piano_45_4.opus +0 -0
  218. package/starter/samples/piano/piano_45_8.opus +0 -0
  219. package/starter/samples/piano/piano_48_12.opus +0 -0
  220. package/starter/samples/piano/piano_48_16.opus +0 -0
  221. package/starter/samples/piano/piano_48_4.opus +0 -0
  222. package/starter/samples/piano/piano_48_8.opus +0 -0
  223. package/starter/samples/piano/piano_51_12.opus +0 -0
  224. package/starter/samples/piano/piano_51_16.opus +0 -0
  225. package/starter/samples/piano/piano_51_4.opus +0 -0
  226. package/starter/samples/piano/piano_51_8.opus +0 -0
  227. package/starter/samples/piano/piano_54_12.opus +0 -0
  228. package/starter/samples/piano/piano_54_16.opus +0 -0
  229. package/starter/samples/piano/piano_54_4.opus +0 -0
  230. package/starter/samples/piano/piano_54_8.opus +0 -0
  231. package/starter/samples/piano/piano_57_12.opus +0 -0
  232. package/starter/samples/piano/piano_57_16.opus +0 -0
  233. package/starter/samples/piano/piano_57_4.opus +0 -0
  234. package/starter/samples/piano/piano_57_8.opus +0 -0
  235. package/starter/samples/piano/piano_60_12.opus +0 -0
  236. package/starter/samples/piano/piano_60_16.opus +0 -0
  237. package/starter/samples/piano/piano_60_4.opus +0 -0
  238. package/starter/samples/piano/piano_60_8.opus +0 -0
  239. package/starter/samples/piano/piano_63_12.opus +0 -0
  240. package/starter/samples/piano/piano_63_16.opus +0 -0
  241. package/starter/samples/piano/piano_63_4.opus +0 -0
  242. package/starter/samples/piano/piano_63_8.opus +0 -0
  243. package/starter/samples/piano/piano_66_12.opus +0 -0
  244. package/starter/samples/piano/piano_66_16.opus +0 -0
  245. package/starter/samples/piano/piano_66_4.opus +0 -0
  246. package/starter/samples/piano/piano_66_8.opus +0 -0
  247. package/starter/samples/piano/piano_69_12.opus +0 -0
  248. package/starter/samples/piano/piano_69_16.opus +0 -0
  249. package/starter/samples/piano/piano_69_4.opus +0 -0
  250. package/starter/samples/piano/piano_69_8.opus +0 -0
  251. package/starter/samples/piano/piano_72_12.opus +0 -0
  252. package/starter/samples/piano/piano_72_16.opus +0 -0
  253. package/starter/samples/piano/piano_72_4.opus +0 -0
  254. package/starter/samples/piano/piano_72_8.opus +0 -0
  255. package/starter/samples/piano/piano_75_12.opus +0 -0
  256. package/starter/samples/piano/piano_75_16.opus +0 -0
  257. package/starter/samples/piano/piano_75_4.opus +0 -0
  258. package/starter/samples/piano/piano_75_8.opus +0 -0
  259. package/starter/samples/piano/piano_78_12.opus +0 -0
  260. package/starter/samples/piano/piano_78_16.opus +0 -0
  261. package/starter/samples/piano/piano_78_4.opus +0 -0
  262. package/starter/samples/piano/piano_78_8.opus +0 -0
  263. package/starter/samples/piano/piano_81_12.opus +0 -0
  264. package/starter/samples/piano/piano_81_16.opus +0 -0
  265. package/starter/samples/piano/piano_81_4.opus +0 -0
  266. package/starter/samples/piano/piano_81_8.opus +0 -0
  267. package/starter/samples/piano/piano_84_12.opus +0 -0
  268. package/starter/samples/piano/piano_84_16.opus +0 -0
  269. package/starter/samples/piano/piano_84_4.opus +0 -0
  270. package/starter/samples/piano/piano_84_8.opus +0 -0
  271. package/starter/samples/piano/piano_87_12.opus +0 -0
  272. package/starter/samples/piano/piano_87_16.opus +0 -0
  273. package/starter/samples/piano/piano_87_4.opus +0 -0
  274. package/starter/samples/piano/piano_87_8.opus +0 -0
  275. package/starter/samples/piano/piano_90_12.opus +0 -0
  276. package/starter/samples/piano/piano_90_16.opus +0 -0
  277. package/starter/samples/piano/piano_90_4.opus +0 -0
  278. package/starter/samples/piano/piano_90_8.opus +0 -0
  279. package/starter/samples/piano/piano_93_12.opus +0 -0
  280. package/starter/samples/piano/piano_93_16.opus +0 -0
  281. package/starter/samples/piano/piano_93_4.opus +0 -0
  282. package/starter/samples/piano/piano_93_8.opus +0 -0
  283. package/starter/samples/piano/piano_96_12.opus +0 -0
  284. package/starter/samples/piano/piano_96_16.opus +0 -0
  285. package/starter/samples/piano/piano_96_4.opus +0 -0
  286. package/starter/samples/piano/piano_96_8.opus +0 -0
  287. package/starter/samples/piano/piano_99_12.opus +0 -0
  288. package/starter/samples/piano/piano_99_16.opus +0 -0
  289. package/starter/samples/piano/piano_99_4.opus +0 -0
  290. package/starter/samples/piano/piano_99_8.opus +0 -0
  291. package/starter/samples/piano/piano_rel_102_x.opus +0 -0
  292. package/starter/samples/piano/piano_rel_105_x.opus +0 -0
  293. package/starter/samples/piano/piano_rel_108_x.opus +0 -0
  294. package/starter/samples/piano/piano_rel_21_x.opus +0 -0
  295. package/starter/samples/piano/piano_rel_24_x.opus +0 -0
  296. package/starter/samples/piano/piano_rel_27_x.opus +0 -0
  297. package/starter/samples/piano/piano_rel_30_x.opus +0 -0
  298. package/starter/samples/piano/piano_rel_33_x.opus +0 -0
  299. package/starter/samples/piano/piano_rel_36_x.opus +0 -0
  300. package/starter/samples/piano/piano_rel_39_x.opus +0 -0
  301. package/starter/samples/piano/piano_rel_42_x.opus +0 -0
  302. package/starter/samples/piano/piano_rel_45_x.opus +0 -0
  303. package/starter/samples/piano/piano_rel_48_x.opus +0 -0
  304. package/starter/samples/piano/piano_rel_51_x.opus +0 -0
  305. package/starter/samples/piano/piano_rel_54_x.opus +0 -0
  306. package/starter/samples/piano/piano_rel_57_x.opus +0 -0
  307. package/starter/samples/piano/piano_rel_60_x.opus +0 -0
  308. package/starter/samples/piano/piano_rel_63_x.opus +0 -0
  309. package/starter/samples/piano/piano_rel_66_x.opus +0 -0
  310. package/starter/samples/piano/piano_rel_69_x.opus +0 -0
  311. package/starter/samples/piano/piano_rel_72_x.opus +0 -0
  312. package/starter/samples/piano/piano_rel_75_x.opus +0 -0
  313. package/starter/samples/piano/piano_rel_78_x.opus +0 -0
  314. package/starter/samples/piano/piano_rel_81_x.opus +0 -0
  315. package/starter/samples/piano/piano_rel_84_x.opus +0 -0
  316. package/starter/samples/piano/piano_rel_87_x.opus +0 -0
  317. package/starter/samples/piano/piano_rel_90_x.opus +0 -0
  318. package/starter/samples/piano/piano_rel_93_x.opus +0 -0
  319. package/starter/samples/piano/piano_rel_96_x.opus +0 -0
  320. package/starter/samples/piano/piano_rel_99_x.opus +0 -0
  321. package/starter/samples/pizz/pizz_24_2.flac +0 -0
  322. package/starter/samples/pizz/pizz_28_2.flac +0 -0
  323. package/starter/samples/pizz/pizz_31_2.flac +0 -0
  324. package/starter/samples/pizz/pizz_35_2.flac +0 -0
  325. package/starter/samples/pizz/pizz_38_2.flac +0 -0
  326. package/starter/samples/pizz/pizz_41_2.flac +0 -0
  327. package/starter/samples/pizz/pizz_45_2.flac +0 -0
  328. package/starter/samples/pizz/pizz_48_2.flac +0 -0
  329. package/starter/samples/pizz/pizz_52_2.flac +0 -0
  330. package/starter/samples/pizz/pizz_57_2.flac +0 -0
  331. package/starter/samples/pizz/pizz_60_2.flac +0 -0
  332. package/starter/samples/pizz/pizz_64_2.flac +0 -0
  333. package/starter/samples/pizz/pizz_67_2.flac +0 -0
  334. package/starter/samples/pizz/pizz_71_2.flac +0 -0
  335. package/starter/samples/pizz/pizz_74_2.flac +0 -0
  336. package/starter/samples/pk_hat/pk_hat_2_1.flac +0 -0
  337. package/starter/samples/pk_hat/pk_hat_2_2.flac +0 -0
  338. package/starter/samples/pk_hat/pk_hat_6_1.flac +0 -0
  339. package/starter/samples/pk_hat/pk_hat_6_2.flac +0 -0
  340. package/starter/samples/pk_kick/pk_kick_3_1.flac +0 -0
  341. package/starter/samples/pk_kick/pk_kick_3_2.flac +0 -0
  342. package/starter/samples/pk_kick/pk_kick_7_1.flac +0 -0
  343. package/starter/samples/pk_kick/pk_kick_7_2.flac +0 -0
  344. package/starter/samples/pk_ohat/pk_ohat_3_1.flac +0 -0
  345. package/starter/samples/pk_ohat/pk_ohat_3_2.flac +0 -0
  346. package/starter/samples/pk_ohat/pk_ohat_6_1.flac +0 -0
  347. package/starter/samples/pk_ohat/pk_ohat_6_2.flac +0 -0
  348. package/starter/samples/pk_rim/pk_rim_2_1.flac +0 -0
  349. package/starter/samples/pk_rim/pk_rim_2_2.flac +0 -0
  350. package/starter/samples/pk_rim/pk_rim_5_1.flac +0 -0
  351. package/starter/samples/pk_rim/pk_rim_5_2.flac +0 -0
  352. package/starter/samples/pk_snare/pk_snare_3_1.flac +0 -0
  353. package/starter/samples/pk_snare/pk_snare_3_2.flac +0 -0
  354. package/starter/samples/pk_snare/pk_snare_7_1.flac +0 -0
  355. package/starter/samples/pk_snare/pk_snare_7_2.flac +0 -0
  356. package/starter/samples/shaker/shaker_1_1.flac +0 -0
  357. package/starter/samples/shaker/shaker_2_1.flac +0 -0
  358. package/starter/samples/snap/snap_r_1.flac +0 -0
  359. package/starter/samples/snap/snap_r_2.flac +0 -0
  360. package/starter/samples/snap/snap_r_3.flac +0 -0
  361. package/starter/samples/snap/snap_r_4.flac +0 -0
  362. package/starter/samples/snap/snap_r_5.flac +0 -0
  363. package/starter/samples/snap/snap_r_6.flac +0 -0
  364. package/starter/samples/tom/tom_3_1.flac +0 -0
  365. package/starter/samples/tom/tom_3_2.flac +0 -0
  366. package/starter/samples/tom/tom_4_1.flac +0 -0
  367. package/starter/samples/tom/tom_4_2.flac +0 -0
  368. package/starter/samples/vibes/vibes_41_1.opus +0 -0
  369. package/starter/samples/vibes/vibes_41_2.opus +0 -0
  370. package/starter/samples/vibes/vibes_45_1.opus +0 -0
  371. package/starter/samples/vibes/vibes_45_2.opus +0 -0
  372. package/starter/samples/vibes/vibes_48_1.opus +0 -0
  373. package/starter/samples/vibes/vibes_48_2.opus +0 -0
  374. package/starter/samples/vibes/vibes_52_1.opus +0 -0
  375. package/starter/samples/vibes/vibes_52_2.opus +0 -0
  376. package/starter/samples/vibes/vibes_55_1.opus +0 -0
  377. package/starter/samples/vibes/vibes_55_2.opus +0 -0
  378. package/starter/samples/vibes/vibes_59_1.opus +0 -0
  379. package/starter/samples/vibes/vibes_59_2.opus +0 -0
  380. package/starter/samples/vibes/vibes_62_1.opus +0 -0
  381. package/starter/samples/vibes/vibes_62_2.opus +0 -0
  382. package/starter/samples/vibes/vibes_65_1.opus +0 -0
  383. package/starter/samples/vibes/vibes_65_2.opus +0 -0
  384. package/starter/samples/vibes/vibes_69_1.opus +0 -0
  385. package/starter/samples/vibes/vibes_69_2.opus +0 -0
  386. package/starter/samples/vibes/vibes_72_1.opus +0 -0
  387. package/starter/samples/vibes/vibes_72_2.opus +0 -0
  388. package/starter/samples/vibes/vibes_76_1.opus +0 -0
  389. package/starter/samples/vibes/vibes_76_2.opus +0 -0
  390. package/starter/samples/violas/violas_36_1.opus +0 -0
  391. package/starter/samples/violas/violas_36_2.opus +0 -0
  392. package/starter/samples/violas/violas_38_1.opus +0 -0
  393. package/starter/samples/violas/violas_38_2.opus +0 -0
  394. package/starter/samples/violas/violas_40_1.opus +0 -0
  395. package/starter/samples/violas/violas_40_2.opus +0 -0
  396. package/starter/samples/violas/violas_43_1.opus +0 -0
  397. package/starter/samples/violas/violas_43_2.opus +0 -0
  398. package/starter/samples/violas/violas_47_1.opus +0 -0
  399. package/starter/samples/violas/violas_47_2.opus +0 -0
  400. package/starter/samples/violas/violas_50_1.opus +0 -0
  401. package/starter/samples/violas/violas_50_2.opus +0 -0
  402. package/starter/samples/violas/violas_53_1.opus +0 -0
  403. package/starter/samples/violas/violas_53_2.opus +0 -0
  404. package/starter/samples/violas/violas_57_1.opus +0 -0
  405. package/starter/samples/violas/violas_57_2.opus +0 -0
  406. package/starter/samples/violas/violas_60_1.opus +0 -0
  407. package/starter/samples/violas/violas_60_2.opus +0 -0
  408. package/starter/samples/violas/violas_64_1.opus +0 -0
  409. package/starter/samples/violas/violas_64_2.opus +0 -0
  410. package/starter/samples/violas/violas_67_1.opus +0 -0
  411. package/starter/samples/violas/violas_67_2.opus +0 -0
  412. package/starter/samples/violas/violas_71_1.opus +0 -0
  413. package/starter/samples/violas/violas_71_2.opus +0 -0
  414. package/starter/samples/violas/violas_74_1.opus +0 -0
  415. package/starter/samples/violas/violas_74_2.opus +0 -0
  416. package/starter/samples/violins/violins_43_1.opus +0 -0
  417. package/starter/samples/violins/violins_43_2.opus +0 -0
  418. package/starter/samples/violins/violins_45_1.opus +0 -0
  419. package/starter/samples/violins/violins_45_2.opus +0 -0
  420. package/starter/samples/violins/violins_47_1.opus +0 -0
  421. package/starter/samples/violins/violins_47_2.opus +0 -0
  422. package/starter/samples/violins/violins_50_1.opus +0 -0
  423. package/starter/samples/violins/violins_50_2.opus +0 -0
  424. package/starter/samples/violins/violins_54_1.opus +0 -0
  425. package/starter/samples/violins/violins_54_2.opus +0 -0
  426. package/starter/samples/violins/violins_57_1.opus +0 -0
  427. package/starter/samples/violins/violins_57_2.opus +0 -0
  428. package/starter/samples/violins/violins_60_1.opus +0 -0
  429. package/starter/samples/violins/violins_60_2.opus +0 -0
  430. package/starter/samples/violins/violins_64_1.opus +0 -0
  431. package/starter/samples/violins/violins_64_2.opus +0 -0
  432. package/starter/samples/violins/violins_67_1.opus +0 -0
  433. package/starter/samples/violins/violins_67_2.opus +0 -0
  434. package/starter/samples/violins/violins_71_1.opus +0 -0
  435. package/starter/samples/violins/violins_71_2.opus +0 -0
  436. package/starter/samples/violins/violins_74_1.opus +0 -0
  437. package/starter/samples/violins/violins_74_2.opus +0 -0
  438. package/starter/samples/woodblock/woodblock_f_1.flac +0 -0
  439. package/starter/samples/woodblock/woodblock_f_2.flac +0 -0
@@ -0,0 +1,389 @@
1
+ // A video's frames, decoded once per render and served as images.
2
+ //
3
+ // The film clock shows a film-timed <video> as its frame at film time — the
4
+ // frame's image as the element's CSS `content` — instead of seeking the
5
+ // element: a video element composited under a slow push shimmers (its text
6
+ // moved 1.49 px from frame to frame at the 90th percentile, 0.15 px as
7
+ // images), and seeking it for every frame and for every motion probe was most
8
+ // of a recorded film's render (70 s against 8.4 s for 4 s of film).
9
+ //
10
+ // Each video the page serves is decoded once, every frame in presentation
11
+ // order with its own timestamp (a screen recording's frame rate varies), into
12
+ // a temporary folder the page's server mounts. Workers share it. A video with
13
+ // too many frames, or whose frames take too much disk or too long to decode,
14
+ // is not: the page seeks it, as before.
15
+
16
+ import { spawn } from "node:child_process";
17
+ import { existsSync } from "node:fs";
18
+ import { mkdir, mkdtemp, rm, stat, statfs } from "node:fs/promises";
19
+ import { tmpdir } from "node:os";
20
+ import { basename, dirname, join } from "node:path";
21
+ import { resolveFfmpeg, resolveFfprobe, runTool } from "../ffmpeg";
22
+ import { fileFor, type StaticServer } from "../html/server";
23
+
24
+ /** where a video's frames are served, when each one starts (seconds on the
25
+ * video's own timeline, as Chrome reads it), and whether they show the
26
+ * video brighter than it decodes (see colours) */
27
+ export type VideoFrames = { base: string; times: number[]; ext: "jpg" | "png"; bright: boolean };
28
+
29
+ /** What one video's frames may cost before the video is sought instead: how
30
+ * many there are, the disk they take, and how long decoding them takes. The
31
+ * page waits for the decoding inside a call the renderer gives 120 s, so it
32
+ * stops well before that (the page's own wait, in clock.ts, is 75 s). */
33
+ export type FrameBudget = { maxFrames?: number; maxBytes?: number; maxMs?: number };
34
+ // 18,000 frames: five minutes at 60 fps
35
+ const BUDGET = { maxFrames: 18_000, maxBytes: 4e9, maxMs: 60_000 };
36
+ /** decoding stops before it leaves less than this free on the disk */
37
+ const FREE_BYTES = 2e9;
38
+
39
+ export type FrameStore = {
40
+ /** the frames of the video the page loads from `src` (a URL on the page's
41
+ * own server); rejects for one it does not serve, ffmpeg cannot read, or
42
+ * that is over its budget */
43
+ frames(src: string): Promise<VideoFrames>;
44
+ /** remove every folder of frames */
45
+ clean(): Promise<void>;
46
+ };
47
+
48
+ export function frameStore(opts: { root: string; server: StaticServer }): FrameStore {
49
+ let work: Promise<string> | null = null;
50
+ const made = new Map<string, Promise<VideoFrames>>();
51
+ return {
52
+ frames(src) {
53
+ let url: URL;
54
+ try {
55
+ url = new URL(src);
56
+ } catch {
57
+ return Promise.reject(new Error(`not a URL: ${src}`));
58
+ }
59
+ if (url.origin !== new URL(opts.server.url).origin)
60
+ return Promise.reject(new Error(`not served by the film's server: ${src}`));
61
+ const file = fileFor(opts.root, url.pathname);
62
+ if (!file) return Promise.reject(new Error(`not a file the film serves: ${src}`));
63
+ let p = made.get(file);
64
+ if (!p) {
65
+ const k = made.size;
66
+ p = (async () => {
67
+ work ??= mkdtemp(join(tmpdir(), "open-take-frames-"));
68
+ const out = join(await work, String(k));
69
+ await mkdir(out);
70
+ try {
71
+ const { times, ext, bright } = await decodeFrames(file, out);
72
+ const base = `/__open-take/frames/${k}/`;
73
+ opts.server.mount(base, out);
74
+ return { base, times, ext, bright };
75
+ } catch (e) {
76
+ // what a refused video wrote goes now, not when the render ends
77
+ await rm(out, { recursive: true, force: true }).catch(() => {});
78
+ throw e;
79
+ }
80
+ })();
81
+ made.set(file, p);
82
+ }
83
+ return p;
84
+ },
85
+ async clean() {
86
+ if (work) await rm(await work, { recursive: true, force: true }).catch(() => {});
87
+ },
88
+ };
89
+ }
90
+
91
+ type Stream = {
92
+ width?: number;
93
+ height?: number;
94
+ pix_fmt?: string;
95
+ color_space?: string;
96
+ color_transfer?: string;
97
+ color_primaries?: string;
98
+ color_range?: string;
99
+ nb_frames?: string;
100
+ avg_frame_rate?: string;
101
+ duration?: string;
102
+ tags?: Record<string, string>;
103
+ };
104
+
105
+ /** Every frame of `file`'s first video stream, in presentation order, as
106
+ * `000000.jpg`… in `out` (PNG for a video with an alpha channel), and when
107
+ * each one starts. Rejects, stopping ffmpeg, when the video is over its
108
+ * budget. */
109
+ export async function decodeFrames(
110
+ file: string,
111
+ out: string,
112
+ budget: FrameBudget = {},
113
+ ): Promise<{ times: number[]; ext: "jpg" | "png"; bright: boolean }> {
114
+ const { maxFrames, maxBytes, maxMs } = { ...BUDGET, ...budget };
115
+ const deadline = Date.now() + maxMs;
116
+ const slow = () => new Error(`its frames take longer than ${maxMs / 1000} seconds to decode`);
117
+ /** what is left of the time to decode in, the probe's included */
118
+ const left = () => {
119
+ const ms = deadline - Date.now();
120
+ if (ms <= 0) throw slow();
121
+ return ms;
122
+ };
123
+ const ffprobe = await resolveFfprobe();
124
+ const probe = JSON.parse(
125
+ await runTool(
126
+ ffprobe,
127
+ [
128
+ "-v",
129
+ "error",
130
+ "-select_streams",
131
+ "v:0",
132
+ "-show_streams",
133
+ "-show_format",
134
+ "-of",
135
+ "json",
136
+ file,
137
+ ],
138
+ { timeoutMs: left() },
139
+ ).catch((e: Error) => {
140
+ throw Date.now() >= deadline ? slow() : e;
141
+ }),
142
+ ) as { streams?: Stream[]; format?: { start_time?: string; duration?: string } };
143
+ const s = probe.streams?.[0];
144
+ if (!s) throw new Error(`ffmpeg found no picture in ${file}`);
145
+ // a WebM's alpha travels beside the picture, and ffmpeg's own decoder drops
146
+ // it: such a video is shown by seeking it, transparent as the page made it
147
+ if (Object.entries(s.tags ?? {}).some(([k, v]) => k.toLowerCase() === "alpha_mode" && v === "1"))
148
+ throw new Error("its alpha channel would be lost as frames");
149
+ const [rn, rd] = (s.avg_frame_rate ?? "").split("/").map(Number);
150
+ const count =
151
+ Number(s.nb_frames) ||
152
+ Math.round(Number(s.duration ?? probe.format?.duration) * (rd ? rn! / rd : 0));
153
+ if (count > maxFrames)
154
+ throw new Error(`it has ${count} frames, more than ${maxFrames} to decode`);
155
+ const alpha = /^(yuva|rgba|argb|abgr|bgra|gbrap|ya)/.test(s.pix_fmt ?? "");
156
+ const ext = alpha ? "png" : "jpg";
157
+ // a take the runtime recorded before it named sRGB's curve named BT.709's
158
+ // for the same sRGB values: its frames are those values, as a take
159
+ // recorded now shows, and as the page's saved states show the same screen
160
+ const { vf, bright } = colours(
161
+ s.color_transfer === "bt709" && takeRecording(file)
162
+ ? { ...s, color_transfer: "iec61966-2-1" }
163
+ : s,
164
+ alpha,
165
+ );
166
+ // Chrome keeps a picture that starts late where it starts; one that starts
167
+ // before 0 it moves to 0 (ffmpeg's -copyts keeps them as they are)
168
+ const start = Number(probe.format?.start_time);
169
+ const shift = start < 0 ? -start : 0;
170
+
171
+ const frame = (i: number) => join(out, `${String(i).padStart(6, "0")}.${ext}`);
172
+ const ffmpeg = await resolveFfmpeg();
173
+ left();
174
+ return new Promise((ok, fail) => {
175
+ const p = spawn(
176
+ ffmpeg,
177
+ [
178
+ "-hide_banner",
179
+ "-nostdin",
180
+ "-nostats",
181
+ "-copyts",
182
+ "-i",
183
+ file,
184
+ "-map",
185
+ "0:v:0",
186
+ "-an",
187
+ "-sn",
188
+ "-dn",
189
+ "-fps_mode",
190
+ "passthrough",
191
+ // each frame's own timestamp is read first (showinfo, in the stream's
192
+ // time base); the files are numbered, so the encoder gets 1 ms apart
193
+ // instead: its default time base (one over the average rate) would
194
+ // give two close frames of a varying rate the same, and refuse them
195
+ "-enc_time_base",
196
+ "1:1000",
197
+ "-vf",
198
+ `showinfo=checksum=0,settb=1/1000,setpts=N,${vf}`,
199
+ ...(alpha ? [] : ["-q:v", "2"]),
200
+ "-start_number",
201
+ "0",
202
+ join(out, `%06d.${ext}`),
203
+ ],
204
+ { stdio: ["ignore", "ignore", "pipe"] },
205
+ );
206
+ let refused: Error | null = null;
207
+ const stop = (e: Error) => {
208
+ refused ??= e;
209
+ p.kill("SIGKILL");
210
+ };
211
+ const timer = setTimeout(() => stop(slow()), deadline - Date.now());
212
+
213
+ // showinfo's lines as they come: the time base, then each frame's pts
214
+ let base: [number, number] | null = null;
215
+ const pts: number[] = [];
216
+ const seconds: number[] = [];
217
+ const said: string[] = [];
218
+ let rest = "";
219
+ p.stderr.on("data", (d: Buffer) => {
220
+ const lines = (rest + d.toString()).split("\n");
221
+ rest = lines.pop()!;
222
+ for (const l of lines) {
223
+ if (!l.includes("Parsed_showinfo")) {
224
+ said.push(l);
225
+ if (said.length > 3) said.shift();
226
+ continue;
227
+ }
228
+ const tb = /config in time_base:\s*(\d+)\/(\d+)/.exec(l);
229
+ if (tb) base ??= [Number(tb[1]), Number(tb[2])];
230
+ const f = /\bn:\s*\d+\s+pts:\s*(-?\d+)\s+pts_time:\s*(\S+)/.exec(l);
231
+ if (!f) continue;
232
+ pts.push(Number(f[1]));
233
+ seconds.push(Number(f[2]));
234
+ if (pts.length > maxFrames)
235
+ stop(new Error(`it has more than ${maxFrames} frames to decode`));
236
+ }
237
+ });
238
+
239
+ // the disk the frames take, counted as they are written: a frame is
240
+ // whole once the next one is begun
241
+ let bytes = 0;
242
+ let counted = 0;
243
+ const tally = async (all: boolean) => {
244
+ while (existsSync(frame(all ? counted : counted + 1))) {
245
+ bytes += (await stat(frame(counted))).size;
246
+ counted++;
247
+ }
248
+ };
249
+ const tooBig = () => new Error(`its frames would take more than ${size(maxBytes)} of disk`);
250
+ let looking = false;
251
+ const watch = setInterval(async () => {
252
+ if (looking) return;
253
+ looking = true;
254
+ try {
255
+ await tally(false);
256
+ if (bytes > maxBytes) return stop(tooBig());
257
+ const disk = await statfs(out);
258
+ if (disk.bavail * disk.bsize < FREE_BYTES)
259
+ stop(new Error(`its frames would leave less than ${size(FREE_BYTES)} of disk free`));
260
+ } catch {
261
+ // a frame removed under it: the render is over
262
+ } finally {
263
+ looking = false;
264
+ }
265
+ }, 250);
266
+
267
+ p.on("error", (e) => {
268
+ clearTimeout(timer);
269
+ clearInterval(watch);
270
+ fail(e);
271
+ });
272
+ p.on("close", (code) => {
273
+ clearTimeout(timer);
274
+ clearInterval(watch);
275
+ (async () => {
276
+ if (refused) throw refused;
277
+ if (code !== 0) throw new Error(`ffmpeg failed (${code}): ${said.join(" ").trim()}`);
278
+ await tally(true);
279
+ if (bytes > maxBytes) throw tooBig();
280
+ if (!pts.length) throw new Error(`ffmpeg found no frames in ${file}`);
281
+ // exact, from the integer timestamps: a 29.97 fps frame starts at
282
+ // 1001/30000 s, which pts_time rounds to 0.0333667
283
+ const times = base
284
+ ? pts.map((t) => (t * base![0]) / base![1] + shift)
285
+ : seconds.map((t) => t + shift);
286
+ if (times.some((t) => !Number.isFinite(t)))
287
+ throw new Error("its frames have no timestamps");
288
+ return { times, ext, bright } as const;
289
+ })().then(ok, fail);
290
+ });
291
+ });
292
+ }
293
+
294
+ /** a take's recording, as the runtime writes it: capture.mp4 with the
295
+ * take's capture.json beside it */
296
+ const takeRecording = (file: string) =>
297
+ basename(file) === "capture.mp4" && existsSync(join(dirname(file), "capture.json"));
298
+
299
+ const size = (n: number) =>
300
+ n >= 1e9
301
+ ? `${(n / 1e9).toFixed(1)} GB`
302
+ : n >= 1e6
303
+ ? `${Math.round(n / 1e6)} MB`
304
+ : `${Math.ceil(n / 1e3)} KB`;
305
+
306
+ /** a stream's colour matrix, as swscale names it */
307
+ const MATRIX: Record<string, string> = {
308
+ bt709: "bt709",
309
+ smpte170m: "bt601",
310
+ bt470bg: "bt601",
311
+ fcc: "fcc",
312
+ smpte240m: "smpte240m",
313
+ bt2020nc: "bt2020",
314
+ bt2020c: "bt2020",
315
+ };
316
+ /** the primaries of a picture Chrome shows as it decodes: BT.709's and
317
+ * BT.601's, or none named. Others (Display P3, DCI-P3, BT.2020, film…) it
318
+ * maps to the screen itself */
319
+ const SHOWN_AS_DECODED = new Set([
320
+ "",
321
+ "unknown",
322
+ "unspecified",
323
+ "reserved",
324
+ "bt709",
325
+ "bt470bg",
326
+ "smpte170m",
327
+ "smpte240m",
328
+ ]);
329
+ /** the curves Chrome on macOS shows through Apple's gamma: BT.709's */
330
+ const APPLE_CURVES = new Set(["bt709", "smpte170m", "bt2020-10", "bt2020-12"]);
331
+ /** a channel of such a video as Chrome on macOS shows it: through Apple's
332
+ * gamma (1.961) to light, then the sRGB curve back (clock.ts undoes it) */
333
+ const LIGHT = "pow(val/maxval,1.961)";
334
+ const APPLE = `if(lte(${LIGHT},0.0031308),12.92*${LIGHT},1.055*pow(val/maxval,1.961/2.4)-0.055)*maxval`;
335
+
336
+ /** The filters that write a frame as Chrome shows the video; a JPEG decodes
337
+ * as BT.601 full range, so that is what the frames are written in. Chrome
338
+ * decodes a picture with the matrix its tags name, BT.709 when they name
339
+ * none. On macOS (measured on Chrome for Testing: H.264, HEVC, VP9, AV1) it
340
+ * shows a picture with BT.709's curve, or none named, brighter — through
341
+ * Apple's gamma onto the sRGB screen — except a recording's: BT.601 named
342
+ * with no curve, as ffmpeg tags a video of JPEG screenshots, which it shows
343
+ * as it decodes, taking the matrix for BT.709 from 720 high. Below that
344
+ * size, and up to 640×480 for a picture that names nothing (which it takes
345
+ * for BT.601), it also moves the colours from SMPTE-C primaries, by up to 5
346
+ * of 255: left out. Elsewhere Chrome takes BT.709's curve for sRGB's: the
347
+ * picture as it decodes. HDR and wide gamut — any primaries but BT.709's
348
+ * and BT.601's — Chrome maps itself: such a video is sought. */
349
+ function colours(s: Stream, alpha: boolean): { vf: string; bright: boolean } {
350
+ const curve = s.color_transfer ?? "";
351
+ if (curve === "smpte2084" || curve === "arib-std-b67")
352
+ throw new Error("its colours are HDR, which Chrome maps itself");
353
+ if (!SHOWN_AS_DECODED.has(s.color_primaries ?? ""))
354
+ throw new Error(`its colours are in ${s.color_primaries} primaries, which Chrome maps itself`);
355
+ const named = !!curve && !["unknown", "unspecified", "reserved"].includes(curve);
356
+ const rgb = /^(a?rgb|a?bgr|gbr|0rgb|0bgr|x2|gray|ya|pal)/.test(s.pix_fmt ?? "");
357
+ let matrix = MATRIX[s.color_space ?? ""] ?? "bt709";
358
+ let bright = false;
359
+ if (process.platform === "darwin" && !rgb) {
360
+ const [w, h] = [s.width ?? 0, s.height ?? 0];
361
+ if (named) bright = APPLE_CURVES.has(curve);
362
+ else if (s.color_space === "bt470bg") matrix = h >= 720 ? "bt709" : "bt601";
363
+ else {
364
+ bright = true;
365
+ if (!MATRIX[s.color_space ?? ""] && w <= 640 && h <= 480) matrix = "bt601";
366
+ }
367
+ }
368
+ const range = s.color_range === "pc" || s.pix_fmt?.startsWith("yuvj") ? "pc" : "tv";
369
+ // square pixels, as the page draws the video: its frame image has the
370
+ // video's own width and height
371
+ const square = "scale=w=iw*sar:h=ih";
372
+ // already what a JPEG decodes to (a recording, on most machines): as it is
373
+ if (!alpha && !bright && matrix === "bt601" && range === "pc")
374
+ return {
375
+ vf: s.pix_fmt?.startsWith("yuvj")
376
+ ? `${square},setsar=1`
377
+ : `${square}:in_range=pc:out_range=pc,setsar=1,format=yuvj420p`,
378
+ bright,
379
+ };
380
+ // through RGB, which every ffmpeg converts to and from with the matrix asked
381
+ const filters = [
382
+ `${square}:in_color_matrix=${matrix}:in_range=${range}`,
383
+ "setsar=1",
384
+ `format=${alpha ? "rgba" : "rgb24"}`,
385
+ ];
386
+ if (bright) filters.push(`lutrgb=r='${APPLE}':g='${APPLE}':b='${APPLE}'`);
387
+ if (!alpha) filters.push("scale=out_color_matrix=bt601:out_range=pc", "format=yuvj420p");
388
+ return { vf: filters.join(","), bright };
389
+ }