hyperframes 0.8.222 → 0.8.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-6MPLIWVP.js → add-JEPKJ2F4.js} +15 -15
- package/dist/{agentPromptGenerator-X7SQPCXZ.js → agentPromptGenerator-ZBNWLX5D.js} +7 -7
- package/dist/{animatedGifPrep-ESOJ4FQ7.js → animatedGifPrep-43LLMTN5.js} +7 -7
- package/dist/api.d.ts +5 -3
- package/dist/api.js +33 -22
- package/dist/{asset-Y735VQV6.js → asset-M6SH6PUW.js} +5 -5
- package/dist/{assetCataloger-AOJAUEZW.js → assetCataloger-BLQ7UVJ5.js} +8 -8
- package/dist/{audio-VMMCGPOV.js → audio-J3QREJK4.js} +150 -1158
- package/dist/{auth-BD5NHYRA.js → auth-7TRCBCKA.js} +5 -5
- package/dist/{autoUpdate-VTMNHOAJ.js → autoUpdate-WTFSYLTK.js} +4 -4
- package/dist/{backgroundChecks-SUDYQZSW.js → backgroundChecks-YZW7AMMJ.js} +5 -5
- package/dist/backgroundChecksWorker.js +5 -5
- package/dist/{batchRender-4NR7RMT7.js → batchRender-LDZ6NO2X.js} +11 -11
- package/dist/{beats-PKEHQHBY.js → beats-JWUADKHV.js} +14 -14
- package/dist/{benchmark-K55DDFHG.js → benchmark-QOQZ7UGD.js} +13 -13
- package/dist/billing-3GVNEE56.js +86 -0
- package/dist/{browser-G2WFWJJ3.js → browser-4HNCSPUR.js} +8 -8
- package/dist/{bundleWithLocalizedFonts-MNG2UVH3.js → bundleWithLocalizedFonts-GTKHB45M.js} +2 -2
- package/dist/{capture-24PIC3TZ.js → capture-5OYZNIOR.js} +31 -31
- package/dist/{capture-U3EEAPI6.js → capture-XSRWYHAM.js} +7 -7
- package/dist/{captureCompositionFrame-KL4V6ORD.js → captureCompositionFrame-4F7PPQKB.js} +17 -17
- package/dist/{captureTimeout-RIMG6IYH.js → captureTimeout-7Y2RUBCU.js} +3 -1
- package/dist/{catalog-J3BU4TFW.js → catalog-4FVQSID5.js} +16 -16
- package/dist/{catch-up-LDGNMEGL.js → catch-up-KQVK2QZC.js} +8 -8
- package/dist/{check-J6HG6EKE.js → check-3YHLB6FM.js} +47 -46
- package/dist/{checkAudio-MAX7JUYG.js → checkAudio-7ZSZVBSJ.js} +15 -15
- package/dist/{checkBrowser-3W74WJ26.js → checkBrowser-VX5CHNQS.js} +40 -39
- package/dist/{chunk-L55LAERP.js → chunk-2KDHJCH2.js} +2 -2
- package/dist/{chunk-CVY6OIKN.js → chunk-2M6B2JKZ.js} +73 -39
- package/dist/{chunk-OROHGC7W.js → chunk-2QQO3J3B.js} +7 -7
- package/dist/chunk-2WVQ3CCN.js +113 -0
- package/dist/{chunk-RRPO44PE.js → chunk-34GAW4GO.js} +5 -5
- package/dist/{chunk-WWT6ETQA.js → chunk-35NDLXHZ.js} +50 -55
- package/dist/{chunk-YHL4CVTF.js → chunk-3NHCTTLP.js} +15 -15
- package/dist/chunk-3ZDOAVZM.js +570 -0
- package/dist/{chunk-6ZLDIMPL.js → chunk-4H4DR36N.js} +2 -2
- package/dist/{chunk-IB7UYGXR.js → chunk-4ZAOAPWP.js} +17 -11
- package/dist/{chunk-GOWU3NCE.js → chunk-52B3AOIV.js} +1 -1
- package/dist/{chunk-F6QV5N3A.js → chunk-53JEHQBW.js} +2 -2
- package/dist/{chunk-YEKJOA47.js → chunk-53TKUWDX.js} +3 -3
- package/dist/{chunk-6MUI2H6P.js → chunk-54Q3H2UQ.js} +5 -2
- package/dist/chunk-5KAGTSLY.js +205 -0
- package/dist/{chunk-5ZBMHUY2.js → chunk-5LOZWO2M.js} +1 -1
- package/dist/{chunk-DSHFKKSZ.js → chunk-5N5FYE5K.js} +2 -2
- package/dist/{chunk-ZBNK6X5O.js → chunk-652ERUZD.js} +2 -2
- package/dist/{chunk-DP5LF7GF.js → chunk-66W5IWLO.js} +12 -0
- package/dist/{chunk-JQWITWVC.js → chunk-6QIYQ43G.js} +2 -2
- package/dist/chunk-6UWSEXQ3.js +5030 -0
- package/dist/{chunk-35JKCWYI.js → chunk-7HSV5SJ4.js} +3 -3
- package/dist/{chunk-3RXZZIDQ.js → chunk-7RTPHNOO.js} +2 -2
- package/dist/{chunk-6CFBFWLF.js → chunk-A25SCSOK.js} +1 -1
- package/dist/{chunk-SJGE5I5F.js → chunk-ADVVQX4I.js} +1 -1
- package/dist/{chunk-GHEYGMKD.js → chunk-AMQFGICP.js} +1 -1
- package/dist/chunk-BAXL3U3T.js +312 -0
- package/dist/{chunk-YSTBSLWY.js → chunk-BEMGUGGJ.js} +1 -1
- package/dist/chunk-BTK3T4HJ.js +250 -0
- package/dist/{chunk-UBDO4EHA.js → chunk-C5JKRCSG.js} +1 -1
- package/dist/{chunk-ZLXWRYOO.js → chunk-CGX4EOGT.js} +3 -3
- package/dist/{chunk-ZPTNLDOB.js → chunk-D4M37ATV.js} +2 -2
- package/dist/chunk-DY7PQLIE.js +248 -0
- package/dist/{chunk-DNTPNSH5.js → chunk-E2ZY4GWH.js} +5 -5
- package/dist/{chunk-QYRMR45H.js → chunk-E47ZWDMH.js} +1 -1
- package/dist/{chunk-EGJ4UECR.js → chunk-EHZESMRB.js} +8 -2
- package/dist/{chunk-VJVVWYP6.js → chunk-EQFDOQTG.js} +1 -1
- package/dist/{chunk-42Q3VX34.js → chunk-F34GYYXO.js} +5 -5
- package/dist/{chunk-7IH3RSSG.js → chunk-F3CTUCFD.js} +12 -12
- package/dist/chunk-F7T57BZZ.js +95 -0
- package/dist/{chunk-BDZSH6P3.js → chunk-FJ3KUOUZ.js} +1 -1
- package/dist/{chunk-7KBS6ZLB.js → chunk-FPR57WRR.js} +2 -2
- package/dist/{chunk-BPIY5LB3.js → chunk-G45NYKSM.js} +39 -4
- package/dist/{chunk-AXVTL7B6.js → chunk-GE4ABM5K.js} +2 -2
- package/dist/{chunk-HQDHMAUI.js → chunk-GLTSINRP.js} +1 -1
- package/dist/chunk-GQ2QER6M.js +70 -0
- package/dist/{chunk-Y7IV5MAK.js → chunk-H6APAFKE.js} +2 -2
- package/dist/{chunk-5GSEM63G.js → chunk-HANNA5JJ.js} +1 -1
- package/dist/{chunk-RIGSGNDQ.js → chunk-HDPW7THH.js} +30 -21
- package/dist/{chunk-L37AZWB2.js → chunk-HIPW4JXL.js} +3 -3
- package/dist/{chunk-VQMHDS2V.js → chunk-HT3D5AKG.js} +52 -12
- package/dist/{chunk-K5UCRKUK.js → chunk-IORJ42GY.js} +2 -2
- package/dist/{chunk-OAXWHPNS.js → chunk-IYYQRNIZ.js} +1 -1
- package/dist/{chunk-G675S644.js → chunk-J7FVF73D.js} +33 -31
- package/dist/{chunk-S2HWGG5O.js → chunk-JHOPRAJN.js} +1 -1
- package/dist/{chunk-WJYFJGYT.js → chunk-JIF347PW.js} +3 -3
- package/dist/{chunk-XHD7RKEZ.js → chunk-JK2KNL6F.js} +2 -2
- package/dist/{chunk-CZOC7WY7.js → chunk-JKLWWGE6.js} +1 -1
- package/dist/{chunk-SKCS4SUZ.js → chunk-JMP52GTN.js} +44 -19
- package/dist/chunk-JUF43Q7Q.js +59 -0
- package/dist/chunk-K3QT232E.js +71 -0
- package/dist/chunk-KEDN4LSV.js +1048 -0
- package/dist/{chunk-G2EY3MVW.js → chunk-L4ULTWCD.js} +1 -1
- package/dist/{chunk-7D2LTSNV.js → chunk-LRS4FV5W.js} +3 -3
- package/dist/{chunk-VMRQDPFL.js → chunk-M336YVCP.js} +1 -1
- package/dist/{chunk-6W3DY5BP.js → chunk-MA5AQK7T.js} +2 -2
- package/dist/{chunk-EQGKUPBJ.js → chunk-MCDNAIFF.js} +1 -1
- package/dist/{chunk-EOUKB53E.js → chunk-MOXNAVCW.js} +1 -1
- package/dist/{chunk-AIXH3V5A.js → chunk-NFUR6NNT.js} +20 -5
- package/dist/{chunk-AN4USOFT.js → chunk-NI35PAVN.js} +2 -2
- package/dist/{chunk-E5IIR67Q.js → chunk-O2VKGYSK.js} +1 -1
- package/dist/chunk-ODJ2WBZX.js +288 -0
- package/dist/{chunk-52VXA3SC.js → chunk-OZMZFJDW.js} +1 -1
- package/dist/{chunk-EE7YWKDY.js → chunk-PKMAWQUI.js} +4 -4
- package/dist/{chunk-D6LGD472.js → chunk-POOLZTMZ.js} +6 -4
- package/dist/chunk-QK6ZNEBW.js +46 -0
- package/dist/{chunk-NUE44RN2.js → chunk-QOI46C6F.js} +17 -4
- package/dist/{chunk-MESSJFK3.js → chunk-QOYZ3U6G.js} +39 -29
- package/dist/{chunk-ZAJQFY5Q.js → chunk-QU5OYMTB.js} +15 -2
- package/dist/{chunk-HOTXWVVP.js → chunk-R2C5EON5.js} +2 -6
- package/dist/{chunk-FMKI7ZLM.js → chunk-RR5QE7DB.js} +2 -2
- package/dist/{chunk-OQLYKDL5.js → chunk-RU7KMDFL.js} +1 -1
- package/dist/{chunk-ONMTNYGR.js → chunk-RXJUMVCA.js} +1 -1
- package/dist/chunk-RZ6CXJ56.js +24 -0
- package/dist/{chunk-GODT7QDZ.js → chunk-SGMCQAYU.js} +3 -3
- package/dist/{chunk-QOZPWIYV.js → chunk-THL3N377.js} +19 -16
- package/dist/{chunk-IGBOFU2Y.js → chunk-UCPEABYK.js} +2 -2
- package/dist/{chunk-AOHG22HQ.js → chunk-UZ5AWZCA.js} +6 -6
- package/dist/{chunk-4VEXJTUT.js → chunk-VCJE7IMY.js} +2 -2
- package/dist/{chunk-Z5VQBRU2.js → chunk-VPMHRLJH.js} +3 -3
- package/dist/{chunk-FT3CNACL.js → chunk-VXRBPWVW.js} +144 -41
- package/dist/{chunk-537WSYHU.js → chunk-W7MJPKBJ.js} +1 -1
- package/dist/{chunk-26AQTUU4.js → chunk-WJD3GVAA.js} +1 -1
- package/dist/{chunk-DS372VSV.js → chunk-WW7Z2W73.js} +2 -2
- package/dist/{chunk-DC26QLB7.js → chunk-X5BSSPC2.js} +1 -1
- package/dist/{chunk-DIXTEVWQ.js → chunk-Y5HVDK7X.js} +3 -3
- package/dist/{chunk-EHSBBBR2.js → chunk-YGGZ23BB.js} +2 -0
- package/dist/{chunk-NHXGFQWQ.js → chunk-Z7GIHPAZ.js} +1 -1
- package/dist/{chunk-XC3BGWCJ.js → chunk-ZFQSXMX6.js} +1 -1
- package/dist/{chunk-P5M3AXEP.js → chunk-ZGQC6IU7.js} +1 -1
- package/dist/{chunk-KEY2VA65.js → chunk-ZLZXGJ63.js} +6 -20
- package/dist/{clean-K6IM3LC4.js → clean-SXEI6FT4.js} +24 -24
- package/dist/cli.js +73 -63
- package/dist/{cloud-OV7EA4BJ.js → cloud-SKN6FWAZ.js} +4 -4
- package/dist/{cloudrun-ZEMODIOP.js → cloudrun-RHPVVXCR.js} +9 -9
- package/dist/{compare-MJZ3D3HA.js → compare-RTXF2NSK.js} +36 -36
- package/dist/{compiler-6KKETX77.js → compiler-SKRY6FPA.js} +4 -4
- package/dist/{component-EVXMYIP3.js → component-2NPF5PA6.js} +6 -6
- package/dist/{compositions-PZ7FQ7WN.js → compositions-AZRVHGBT.js} +17 -17
- package/dist/curve-QSFEGBUH.js +329 -0
- package/dist/cuts-6AWEJH2H.js +123 -0
- package/dist/{delete-DL3XA4QV.js → delete-NOHFVICL.js} +9 -9
- package/dist/{deploy-VEYP3IP5.js → deploy-UFRADJOA.js} +10 -10
- package/dist/describeProject-F43LI3YQ.js +56 -0
- package/dist/{destroy-BQ5R7LUF.js → destroy-IQLGADZM.js} +6 -6
- package/dist/diff-3WS6NMSE.js +1825 -0
- package/dist/{dist-SHMQOKMF.js → dist-24QQO5IL.js} +2 -2
- package/dist/{dist-M77KFAYW.js → dist-YEYUGCOR.js} +2 -2
- package/dist/{docs-VAF5NM5B.js → docs-IB3KETC6.js} +1 -1
- package/dist/{doctor-JM2WHH7Y.js → doctor-F4VJYQXC.js} +13 -13
- package/dist/energy-BN3QD6Y7.js +134 -0
- package/dist/events-5W7ETFWR.js +221 -0
- package/dist/{events-GW5I5RCG.js → events-PZH4C7VA.js} +5 -5
- package/dist/{events-S7KVBRSL.js → events-YJ3XSIPL.js} +6 -6
- package/dist/extract-S34DWGAD.js +309 -0
- package/dist/face-3SCJADG4.js +171 -0
- package/dist/{feedback-7OR5FVTX.js → feedback-3K6NSKIC.js} +16 -16
- package/dist/{ffmpeg-A7CSIX3U.js → ffmpeg-2RBDDMHU.js} +7 -7
- package/dist/{figma-444HKFX5.js → figma-NWAJYMAI.js} +3 -3
- package/dist/fontLocalizeCli.js +10 -10
- package/dist/frames-6UARLPLK.js +352 -0
- package/dist/generate-KBVWFVXN.js +74 -0
- package/dist/{get-6UTF3225.js → get-SEZZMLQ3.js} +8 -8
- package/dist/{gpuPolicy-ORPUS5Z2.js → gpuPolicy-VIZAJ3GY.js} +7 -7
- package/dist/{grade-compare-UCTAYN3B.js → grade-compare-PMAK4PJD.js} +40 -37
- package/dist/{heifImagePrep-ED6V6RFN.js → heifImagePrep-6NYIR7WN.js} +8 -8
- package/dist/{help-HZR32XWP.js → help-4UPSHWI2.js} +7 -1
- package/dist/{history-TQ56MZIA.js → history-VNAZEQDE.js} +11 -11
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +70 -70
- package/dist/hyperframes-player.global.js +3 -3
- package/dist/index-gen-OPMQ5WSN.js +61 -0
- package/dist/{info-RPIIP7RN.js → info-OREET5PM.js} +11 -11
- package/dist/{init-ONAWKHFW.js → init-K7AEJBAL.js} +33 -32
- package/dist/{inspect-A75PYOWJ.js → inspect-STME5DNY.js} +37 -36
- package/dist/{installer-ISMCCFBZ.js → installer-NQA4KXRP.js} +4 -4
- package/dist/{keyframes-2I75DP3O.js → keyframes-JQWZ235Q.js} +10 -10
- package/dist/{lambda-4QIHGPGJ.js → lambda-RJNLW2EO.js} +21 -21
- package/dist/{layout-GW7WE7RT.js → layout-MTZWBPNZ.js} +37 -36
- package/dist/{lint-OWP72OZQ.js → lint-AQWTSL75.js} +12 -12
- package/dist/{lintProject-XYQ5L7RQ.js → lintProject-6H64SX3V.js} +2 -2
- package/dist/{list-WVK7ZCPW.js → list-ZEBZ5DB5.js} +9 -9
- package/dist/{localPage-IQWHN7BH.js → localPage-CQ3H4N2N.js} +7 -7
- package/dist/{login-Q5CNHYWU.js → login-VHCZHENV.js} +17 -11
- package/dist/{logout-6VFJ7WMW.js → logout-LHTQV2BZ.js} +3 -3
- package/dist/look-25TSRPSV.js +180 -0
- package/dist/{manager-JCYVNEWH.js → manager-57SX7D5G.js} +9 -8
- package/dist/manifest-QSJYVERU.js +49 -0
- package/dist/measure-Y2R3G5OJ.js +46 -0
- package/dist/{media-treatment-M5IUP7H4.js → media-treatment-3G2IVS64.js} +20 -20
- package/dist/{media-use-ZNTB7W6N.js → media-use-LUAOZJNV.js} +10 -6
- package/dist/{models-CFXKDYZ3.js → models-NT56FKRG.js} +15 -15
- package/dist/{motionShot-CWUEI4ZM.js → motionShot-P4NTFKYS.js} +20 -20
- package/dist/{normalize-QJVXFMWO.js → normalize-MBNGRVQA.js} +2 -1
- package/dist/{normalize-audio-FASY33LR.js → normalize-audio-2DUTZ6QK.js} +12 -12
- package/dist/{open-KOVVESYN.js → open-OATYOOR7.js} +15 -15
- package/dist/{parakeetRunner-E4IP5SL4.js → parakeetRunner-UASHW3A4.js} +13 -12
- package/dist/{pipeline-C6EZVV43.js → pipeline-GGAYP5Q6.js} +11 -11
- package/dist/{play-MZJI6SMH.js → play-GHXBJS3T.js} +28 -28
- package/dist/{policies-J5BWAZHM.js → policies-EERREOZJ.js} +6 -4
- package/dist/{preflight-K4SPUWXP.js → preflight-6VOP3IOI.js} +8 -8
- package/dist/{present-7L7ZTG7F.js → present-M7UYHVEZ.js} +23 -23
- package/dist/{preview-QGDVMR3X.js → preview-YWT5WA3W.js} +26 -26
- package/dist/probe-CQAGZJLP.js +178 -0
- package/dist/{producer-EJPNNY3E.js → producer-OU2BCMLY.js} +1 -1
- package/dist/{progress-X3QFO3FE.js → progress-STSH2JRY.js} +2 -2
- package/dist/{projectConfig-EEF6OPXO.js → projectConfig-UI4NZDN7.js} +6 -6
- package/dist/{prompts-VAO7RDKX.js → prompts-ZEVFT7US.js} +2 -2
- package/dist/{publication-5KF44AKQ.js → publication-VPJZQCLA.js} +2 -2
- package/dist/{publish-SSKWZ5TE.js → publish-7RA2MK2M.js} +18 -18
- package/dist/{refresh-I6ITGHKL.js → refresh-AM2ULRRV.js} +3 -3
- package/dist/{remove-background-PCL6I5SZ.js → remove-background-A5KJUH6W.js} +14 -14
- package/dist/{render-UPRWOGLS.js → render-EMW4I6C6.js} +45 -45
- package/dist/{render-DH4UA7KW.js → render-IYV73CG6.js} +10 -10
- package/dist/{render-DRWQ6F37.js → render-Z5IS4AUP.js} +39 -39
- package/dist/{render-batch-EBW5WHB5.js → render-batch-IN2ZXPS7.js} +10 -10
- package/dist/renderSetupWorker.js +2 -2
- package/dist/{resolver-ZSZXNRFP.js → resolver-DIXFK5ZR.js} +4 -4
- package/dist/run-MCVU7AZX.js +31 -0
- package/dist/{sam-QA7JT7IM.js → sam-EGFXZF56.js} +2 -2
- package/dist/{screenshotCapture-4THETOMD.js → screenshotCapture-RUDON2HB.js} +2 -2
- package/dist/{sherpa-IKVUCBOW.js → sherpa-SAY3I7PK.js} +12 -11
- package/dist/{sites-MTLVMYJ6.js → sites-EAGXQOKI.js} +2 -2
- package/dist/skills/hyperframes-cli/SKILL.md +4 -4
- package/dist/skills/hyperframes-cli/references/cloud.md +3 -1
- package/dist/skills/hyperframes-cli/references/preview-render.md +1 -1
- package/dist/skills/media-use/SKILL.md +20 -21
- package/dist/skills/media-use/audio/scripts/lib/heygen.mjs +26 -1
- package/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +33 -0
- package/dist/skills/media-use/references/heygen.md +58 -0
- package/dist/skills/media-use/references/operations.md +9 -6
- package/dist/skills/media-use/references/setup-providers.md +11 -12
- package/dist/skills/media-use/scripts/lib/index-gen.d.mts +1 -0
- package/dist/skills/media-use/scripts/lib/manifest.d.mts +21 -0
- package/dist/{skills-ZREHX3TU.js → skills-YWQ5XKH6.js} +9 -9
- package/dist/{skillsUpdateCheck-PPJ5NGAL.js → skillsUpdateCheck-ST5ZFEET.js} +5 -5
- package/dist/{snapshot-KPFLZNEL.js → snapshot-57YYYE5J.js} +43 -42
- package/dist/{src-QRV3466B.js → src-7MEBCSTP.js} +9 -9
- package/dist/{src-EPOGDJTT.js → src-LNSJHD25.js} +10 -6
- package/dist/{state-6QHNNHDA.js → state-W3AS6O2J.js} +2 -2
- package/dist/{staticProjectServer-ERKLMZVM.js → staticProjectServer-TTJSAB2Q.js} +19 -19
- package/dist/{status-4AAPTTRW.js → status-FGXBUX2T.js} +36 -11
- package/dist/studio/assets/hyperframes-player-Bzcd9O2g.js +478 -0
- package/dist/studio/assets/{index-C8VIUiGz.js → index-CZI-XmnO.js} +119 -119
- package/dist/studio/assets/{index-CVPNbydK.js → index-LW6kxYVF.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-7WFZIIPL.js → studio-api-57E36S5N.js} +15 -15
- package/dist/{studioServer-3XZTLI26.js → studioServer-2AIRUNBA.js} +55 -55
- package/dist/sync-52GUXEYZ.js +115 -0
- package/dist/{telemetry-BMLI4TMC.js → telemetry-RVY6RSCD.js} +6 -6
- package/dist/{telemetry-QHYJJAJU.js → telemetry-T73TKZOL.js} +1 -1
- package/dist/{timeline-EDCDO2ZR.js → timeline-MMZF4AX3.js} +31 -27
- package/dist/{tokens-2ZFLFO3K.js → tokens-WGWCYFTY.js} +5 -5
- package/dist/{transcribe-Y2LPBT7I.js → transcribe-6BF5FFPV.js} +39 -22
- package/dist/{transcribe-3WMH62HH.js → transcribe-YYDHXRQW.js} +11 -10
- package/dist/{tts-BVTJEP72.js → tts-ZLNNIS6W.js} +5 -5
- package/dist/{updateCheck-5LFZGC3P.js → updateCheck-AAR5LLUF.js} +4 -4
- package/dist/{upgrade-X7QVSEKP.js → upgrade-Y7CIRL4B.js} +5 -5
- package/dist/{urlDownloader-TYD6ROKL.js → urlDownloader-KZOD7EWX.js} +6 -6
- package/dist/{validate-26KQ5VX7.js → validate-K3PHAA2E.js} +30 -30
- package/dist/{video-BPKLZIJK.js → video-Z6EBVCAT.js} +9 -9
- package/dist/warmCheck.js +47 -46
- package/package.json +1 -1
- package/dist/chunk-LL3VMDAC.js +0 -5013
- package/dist/studio/assets/hyperframes-player-Dka6e1BG.js +0 -478
- package/dist/{chunk-NOH32H42.js → chunk-HBAUU3IK.js} +124 -124
- package/dist/{synthesize-4JC74JW5.js → synthesize-DIT2SR3D.js} +5 -5
|
@@ -0,0 +1,1825 @@
|
|
|
1
|
+
import { createRequire as __hf_createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname as __hf_dirname } from "node:path";
|
|
4
|
+
var require = __hf_createRequire(import.meta.url);
|
|
5
|
+
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __hf_dirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
compareEnergy,
|
|
9
|
+
energyCurve
|
|
10
|
+
} from "./chunk-QK6ZNEBW.js";
|
|
11
|
+
import {
|
|
12
|
+
compareLook,
|
|
13
|
+
look,
|
|
14
|
+
sameLook
|
|
15
|
+
} from "./chunk-GQ2QER6M.js";
|
|
16
|
+
import {
|
|
17
|
+
faceBoxes
|
|
18
|
+
} from "./chunk-ODJ2WBZX.js";
|
|
19
|
+
import {
|
|
20
|
+
avSync
|
|
21
|
+
} from "./chunk-2WVQ3CCN.js";
|
|
22
|
+
import {
|
|
23
|
+
parseMask,
|
|
24
|
+
repeated
|
|
25
|
+
} from "./chunk-3ZDOAVZM.js";
|
|
26
|
+
import {
|
|
27
|
+
confirmsCut,
|
|
28
|
+
cutsIn,
|
|
29
|
+
frameChanges,
|
|
30
|
+
signatures
|
|
31
|
+
} from "./chunk-K3QT232E.js";
|
|
32
|
+
import "./chunk-F7T57BZZ.js";
|
|
33
|
+
import "./chunk-NO6F7CLR.js";
|
|
34
|
+
import "./chunk-5KAGTSLY.js";
|
|
35
|
+
import "./chunk-JUF43Q7Q.js";
|
|
36
|
+
import {
|
|
37
|
+
Fix,
|
|
38
|
+
decode,
|
|
39
|
+
formatJson,
|
|
40
|
+
frameAt,
|
|
41
|
+
outDir,
|
|
42
|
+
parseNumbers,
|
|
43
|
+
parseRange,
|
|
44
|
+
pearson,
|
|
45
|
+
probeVideo,
|
|
46
|
+
round,
|
|
47
|
+
runFfmpeg,
|
|
48
|
+
videoClip,
|
|
49
|
+
writeImage
|
|
50
|
+
} from "./chunk-BTK3T4HJ.js";
|
|
51
|
+
import "./chunk-BEMGUGGJ.js";
|
|
52
|
+
import "./chunk-QOYZ3U6G.js";
|
|
53
|
+
import "./chunk-RZ6CXJ56.js";
|
|
54
|
+
import "./chunk-HANNA5JJ.js";
|
|
55
|
+
import "./chunk-A4ZTSQLW.js";
|
|
56
|
+
import "./chunk-VLA6UJGH.js";
|
|
57
|
+
import {
|
|
58
|
+
defineCommand
|
|
59
|
+
} from "./chunk-DL4OD7IA.js";
|
|
60
|
+
import "./chunk-S3S4TGEH.js";
|
|
61
|
+
import {
|
|
62
|
+
c
|
|
63
|
+
} from "./chunk-2GICKZ3I.js";
|
|
64
|
+
import "./chunk-NFUR6NNT.js";
|
|
65
|
+
import "./chunk-Z5J67X44.js";
|
|
66
|
+
import "./chunk-5S7W3TUO.js";
|
|
67
|
+
import "./chunk-D3MUHMFG.js";
|
|
68
|
+
import "./chunk-7RTPHNOO.js";
|
|
69
|
+
import "./chunk-YWRUQ7XZ.js";
|
|
70
|
+
import "./chunk-FJ3KUOUZ.js";
|
|
71
|
+
import "./chunk-MEJH7VEA.js";
|
|
72
|
+
import "./chunk-6UWSEXQ3.js";
|
|
73
|
+
import "./chunk-VC76R6W2.js";
|
|
74
|
+
import "./chunk-OFQWTKPW.js";
|
|
75
|
+
import "./chunk-RQVDTPGD.js";
|
|
76
|
+
import "./chunk-3GXQPCJC.js";
|
|
77
|
+
import "./chunk-TK7THLRO.js";
|
|
78
|
+
import "./chunk-FXMKHHPO.js";
|
|
79
|
+
import "./chunk-X6JUUQCM.js";
|
|
80
|
+
import "./chunk-KGPLIH7B.js";
|
|
81
|
+
import "./chunk-K4MJX7SR.js";
|
|
82
|
+
import "./chunk-WE42NVH7.js";
|
|
83
|
+
import "./chunk-HT3D5AKG.js";
|
|
84
|
+
import "./chunk-HYRPH6LL.js";
|
|
85
|
+
import "./chunk-AKMY4QVI.js";
|
|
86
|
+
import "./chunk-CZGHFATT.js";
|
|
87
|
+
import "./chunk-C2KEGBR3.js";
|
|
88
|
+
import "./chunk-T5ELONXY.js";
|
|
89
|
+
import "./chunk-FR7YBU3H.js";
|
|
90
|
+
import "./chunk-DPVXBVLL.js";
|
|
91
|
+
import "./chunk-GWTIFRF5.js";
|
|
92
|
+
import "./chunk-2RY2LWAA.js";
|
|
93
|
+
import "./chunk-EPQC3FGZ.js";
|
|
94
|
+
import "./chunk-WC4MTXGN.js";
|
|
95
|
+
import "./chunk-FBN2M2HK.js";
|
|
96
|
+
import {
|
|
97
|
+
withMeta
|
|
98
|
+
} from "./chunk-2KDHJCH2.js";
|
|
99
|
+
import "./chunk-BR2JQQC5.js";
|
|
100
|
+
import "./chunk-BLBMPEBX.js";
|
|
101
|
+
import "./chunk-ISN5GRYI.js";
|
|
102
|
+
import "./chunk-ADVVQX4I.js";
|
|
103
|
+
import {
|
|
104
|
+
failCommand,
|
|
105
|
+
setCommandExitCode
|
|
106
|
+
} from "./chunk-66W5IWLO.js";
|
|
107
|
+
import "./chunk-J3RXEDR2.js";
|
|
108
|
+
import "./chunk-QBXDU24O.js";
|
|
109
|
+
import "./chunk-MA5AQK7T.js";
|
|
110
|
+
import {
|
|
111
|
+
normalizeErrorMessage
|
|
112
|
+
} from "./chunk-E63BDV4Z.js";
|
|
113
|
+
import "./chunk-G7VEYUZ2.js";
|
|
114
|
+
import "./chunk-XT6MXC7A.js";
|
|
115
|
+
import "./chunk-7KDQAD2W.js";
|
|
116
|
+
import "./chunk-M2WBOQ2Q.js";
|
|
117
|
+
|
|
118
|
+
// src/commands/diff.ts
|
|
119
|
+
import { basename as basename2, extname, join as join4, resolve as resolve2 } from "path";
|
|
120
|
+
|
|
121
|
+
// src/measure/diff.ts
|
|
122
|
+
import {
|
|
123
|
+
copyFileSync,
|
|
124
|
+
existsSync as existsSync2,
|
|
125
|
+
mkdirSync,
|
|
126
|
+
mkdtempSync as mkdtempSync3,
|
|
127
|
+
readdirSync,
|
|
128
|
+
readFileSync as readFileSync3,
|
|
129
|
+
rmSync as rmSync3,
|
|
130
|
+
statSync,
|
|
131
|
+
writeFileSync
|
|
132
|
+
} from "fs";
|
|
133
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
134
|
+
import { basename, dirname, join as join3, resolve } from "path";
|
|
135
|
+
|
|
136
|
+
// src/measure/drawn.ts
|
|
137
|
+
import { mkdtempSync, readFileSync, rmSync } from "fs";
|
|
138
|
+
import { tmpdir } from "os";
|
|
139
|
+
import { join } from "path";
|
|
140
|
+
var DRAWN_MIN_MEAN = 0.8;
|
|
141
|
+
var DRAWN_MIN_P05 = 0.65;
|
|
142
|
+
var INK_CONTRAST = 60;
|
|
143
|
+
var MATCH_COLOUR = 45;
|
|
144
|
+
var ALIGN = 3;
|
|
145
|
+
var MIN_INK = 30;
|
|
146
|
+
var MAX_FPS = 10;
|
|
147
|
+
function contrast(px, w, h) {
|
|
148
|
+
const bs = Math.max(4, Math.floor(Math.max(8, Math.floor(h / 2)) / 2));
|
|
149
|
+
const [gw, gh] = [Math.ceil(w / bs), Math.ceil(h / bs)];
|
|
150
|
+
const med = new Float32Array(gw * gh * 3);
|
|
151
|
+
const hist = new Uint32Array(256);
|
|
152
|
+
for (let by = 0; by < gh; by++)
|
|
153
|
+
for (let bx = 0; bx < gw; bx++) {
|
|
154
|
+
const [x0, x1] = [Math.max(0, (bx - 1) * bs), Math.min(w, (bx + 2) * bs)];
|
|
155
|
+
const [y0, y1] = [Math.max(0, (by - 1) * bs), Math.min(h, (by + 2) * bs)];
|
|
156
|
+
const half = (x1 - x0) * (y1 - y0) / 2;
|
|
157
|
+
for (let c2 = 0; c2 < 3; c2++) {
|
|
158
|
+
hist.fill(0);
|
|
159
|
+
for (let y = y0; y < y1; y++)
|
|
160
|
+
for (let x = x0; x < x1; x++) hist[px[(y * w + x) * 3 + c2]]++;
|
|
161
|
+
let [v, seen] = [0, 0];
|
|
162
|
+
while (v < 255 && seen + hist[v] < half) seen += hist[v++];
|
|
163
|
+
med[(by * gw + bx) * 3 + c2] = v;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const out = new Float32Array(w * h);
|
|
167
|
+
for (let y = 0; y < h; y++)
|
|
168
|
+
for (let x = 0; x < w; x++) {
|
|
169
|
+
const [o, m] = [(y * w + x) * 3, (Math.floor(y / bs) * gw + Math.floor(x / bs)) * 3];
|
|
170
|
+
out[y * w + x] = Math.hypot(
|
|
171
|
+
px[o] - med[m],
|
|
172
|
+
px[o + 1] - med[m + 1],
|
|
173
|
+
px[o + 2] - med[m + 2]
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
var inkOf = (px, w, h) => {
|
|
179
|
+
const c2 = contrast(px, w, h);
|
|
180
|
+
return Uint8Array.from(c2, (v) => v > INK_CONTRAST ? 1 : 0);
|
|
181
|
+
};
|
|
182
|
+
function scoreDrawnFrame(a, b, w, h) {
|
|
183
|
+
const [ia, ib] = [inkOf(a, w, h), inkOf(b, w, h)];
|
|
184
|
+
const [na, nb] = [ia.reduce((s, v) => s + v, 0), ib.reduce((s, v) => s + v, 0)];
|
|
185
|
+
if (na + nb < MIN_INK) return { score: null, offset: [0, 0], inkOriginal: na, inkYours: nb };
|
|
186
|
+
let mostOverlappingShift = { iou: -1, dx: 0, dy: 0 };
|
|
187
|
+
for (let dy = -ALIGN; dy <= ALIGN; dy++)
|
|
188
|
+
for (let dx = -ALIGN; dx <= ALIGN; dx++) {
|
|
189
|
+
let [both, either] = [0, 0];
|
|
190
|
+
for (let y = 0; y < h; y++) {
|
|
191
|
+
const sy = y - dy;
|
|
192
|
+
for (let x = 0; x < w; x++) {
|
|
193
|
+
const sx = x - dx;
|
|
194
|
+
const vb = sy >= 0 && sy < h && sx >= 0 && sx < w ? ib[sy * w + sx] : 0;
|
|
195
|
+
const va = ia[y * w + x];
|
|
196
|
+
both += va & vb;
|
|
197
|
+
either += va | vb;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const iou = either ? both / either : 0;
|
|
201
|
+
if (iou > mostOverlappingShift.iou) mostOverlappingShift = { iou, dx, dy };
|
|
202
|
+
}
|
|
203
|
+
const at = (x, y) => (Math.min(h - 1, Math.max(0, y)) * w + Math.min(w - 1, Math.max(0, x))) * 3;
|
|
204
|
+
const near = (p, o, q, x, y) => {
|
|
205
|
+
for (let ry = -1; ry <= 1; ry++)
|
|
206
|
+
for (let rx = -1; rx <= 1; rx++) {
|
|
207
|
+
const k = at(x + rx, y + ry);
|
|
208
|
+
if (Math.hypot(p[o] - q[k], p[o + 1] - q[k + 1], p[o + 2] - q[k + 2]) < MATCH_COLOUR)
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
};
|
|
213
|
+
let [hitA, hitB, inkA, inkB] = [0, 0, 0, 0];
|
|
214
|
+
for (let y = 0; y < h; y++)
|
|
215
|
+
for (let x = 0; x < w; x++) {
|
|
216
|
+
const i = y * w + x;
|
|
217
|
+
const [sx, sy] = [x - mostOverlappingShift.dx, y - mostOverlappingShift.dy];
|
|
218
|
+
const inB = sy >= 0 && sy < h && sx >= 0 && sx < w && ib[sy * w + sx] === 1;
|
|
219
|
+
if (ia[i]) {
|
|
220
|
+
inkA++;
|
|
221
|
+
if (near(a, i * 3, b, sx, sy)) hitA++;
|
|
222
|
+
}
|
|
223
|
+
if (inB) {
|
|
224
|
+
inkB++;
|
|
225
|
+
if (near(b, at(sx, sy), a, x, y)) hitB++;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const [recall, precision] = [inkA ? hitA / inkA : 0, inkB ? hitB / inkB : 0];
|
|
229
|
+
return {
|
|
230
|
+
score: recall + precision ? 2 * recall * precision / (recall + precision) : 0,
|
|
231
|
+
offset: [0 - mostOverlappingShift.dx, 0 - mostOverlappingShift.dy],
|
|
232
|
+
inkOriginal: na,
|
|
233
|
+
inkYours: nb
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
var median = (v) => [...v].sort((x, y) => x - y)[v.length >> 1] ?? 0;
|
|
237
|
+
function drawnVerdict(box, window, frames) {
|
|
238
|
+
const head = { box, window, frames: frames.length };
|
|
239
|
+
const scored = frames.flatMap((f) => f.score === null ? [] : [f]);
|
|
240
|
+
if (!scored.length) return { ...head, pass: null };
|
|
241
|
+
const sorted = scored.map((f) => f.score).sort((x, y) => x - y);
|
|
242
|
+
const mean = sorted.reduce((s, v) => s + v, 0) / sorted.length;
|
|
243
|
+
const p05 = sorted[Math.min(sorted.length - 1, Math.floor(0.05 * sorted.length))];
|
|
244
|
+
const both = scored.filter((f) => f.inkOriginal >= MIN_INK && f.inkYours >= MIN_INK);
|
|
245
|
+
return {
|
|
246
|
+
...head,
|
|
247
|
+
pass: mean >= DRAWN_MIN_MEAN && p05 >= DRAWN_MIN_P05,
|
|
248
|
+
score: round(mean, 3),
|
|
249
|
+
p05: round(p05, 3),
|
|
250
|
+
offset: [median(scored.map((f) => f.offset[0])), median(scored.map((f) => f.offset[1]))],
|
|
251
|
+
...both.length ? { ink: round(median(both.map((f) => f.inkYours / f.inkOriginal)), 2) } : {}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function readDrawn(clip, jobs, width, height) {
|
|
255
|
+
if (!jobs.length) return [];
|
|
256
|
+
const work = mkdtempSync(join(tmpdir(), "hf-diff-drawn-"));
|
|
257
|
+
try {
|
|
258
|
+
const tags = jobs.map((_, j) => `[d${j}]`).join("");
|
|
259
|
+
const graph = [
|
|
260
|
+
`[0:v]${[...clip.filters, "setsar=1", `scale=${width}:${height}:flags=bicubic`].join(",")},split=${jobs.length}${tags}`,
|
|
261
|
+
...jobs.map(({ box: [x, y, w, h], frames }, j) => {
|
|
262
|
+
const pick = frames.map((k) => `eq(n\\,${k})`).join("+");
|
|
263
|
+
return `[d${j}]select=${pick},crop=${w}:${h}:${x}:${y},format=rgb24[e${j}]`;
|
|
264
|
+
})
|
|
265
|
+
].join(";");
|
|
266
|
+
const outs = jobs.flatMap((_, j) => [
|
|
267
|
+
...["-map", `[e${j}]`, "-fps_mode", "passthrough", "-f", "rawvideo", `e${j}.rgb`]
|
|
268
|
+
]);
|
|
269
|
+
runFfmpeg([...clip.input, "-an", "-filter_complex", graph, ...outs], void 0, work);
|
|
270
|
+
return jobs.map(({ box: [, , w, h] }, j) => {
|
|
271
|
+
const raw = readFileSync(join(work, `e${j}.rgb`));
|
|
272
|
+
const size = w * h * 3;
|
|
273
|
+
const frames = [];
|
|
274
|
+
for (let i = 0; i + size <= raw.length; i += size) frames.push(raw.subarray(i, i + size));
|
|
275
|
+
return frames;
|
|
276
|
+
});
|
|
277
|
+
} finally {
|
|
278
|
+
rmSync(work, { recursive: true, force: true });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function drawnFrames(ks, fps, a, b, available) {
|
|
282
|
+
const stride = Math.max(1, Math.round(fps / MAX_FPS));
|
|
283
|
+
const inside = ks.flatMap(
|
|
284
|
+
(k, i) => i < available && k / fps >= a - 1e-6 && k / fps < b - 1e-6 ? [i] : []
|
|
285
|
+
);
|
|
286
|
+
let last = -Infinity;
|
|
287
|
+
return inside.filter((i) => {
|
|
288
|
+
if (ks[i] - last < stride) return false;
|
|
289
|
+
last = ks[i];
|
|
290
|
+
return true;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/measure/person.ts
|
|
295
|
+
import { existsSync, mkdtempSync as mkdtempSync2, readFileSync as readFileSync2, rmSync as rmSync2 } from "fs";
|
|
296
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
297
|
+
import { join as join2 } from "path";
|
|
298
|
+
var FRAMING_SHIFT = 0.3;
|
|
299
|
+
var FRAMING_SCALE = [0.8, 1.25];
|
|
300
|
+
var FRAMING_MIN_S = 1;
|
|
301
|
+
var FRAMING_MIN_FACES = 3;
|
|
302
|
+
var FACE_RATE = 4;
|
|
303
|
+
var SYNC_MS = [-125, 45];
|
|
304
|
+
var SYNC_MIN_S = 2;
|
|
305
|
+
var SYNC_MIN_SPEECH = 0.3;
|
|
306
|
+
var CARRIED_TEXT = 0.35;
|
|
307
|
+
var TEXT_CONTRAST = 140;
|
|
308
|
+
var DRAWN_DIFF = 60;
|
|
309
|
+
var TEXT_COLOUR = 15;
|
|
310
|
+
var TEXT_MIN_INK = 50;
|
|
311
|
+
var CARRIED_SAMPLES = 8;
|
|
312
|
+
var LOCATE_MIN = 0.6;
|
|
313
|
+
var AT_CUT_S = 0.1;
|
|
314
|
+
var ENVELOPE_RATE = 100;
|
|
315
|
+
var isRecord = (v) => typeof v === "object" && v !== null;
|
|
316
|
+
function generatedClips(ledger) {
|
|
317
|
+
return ledger.split("\n").flatMap((line) => {
|
|
318
|
+
let entry;
|
|
319
|
+
try {
|
|
320
|
+
entry = JSON.parse(line);
|
|
321
|
+
} catch {
|
|
322
|
+
return [];
|
|
323
|
+
}
|
|
324
|
+
if (!isRecord(entry) || entry.type !== "video" || typeof entry.path !== "string") return [];
|
|
325
|
+
const p = entry.provenance;
|
|
326
|
+
if (!isRecord(p) || p.provider !== "heygen") return [];
|
|
327
|
+
const w = Array.isArray(p.window) ? p.window.filter((v) => typeof v === "number") : [];
|
|
328
|
+
const refs = Array.isArray(p.references) ? p.references.filter((v) => typeof v === "string") : [];
|
|
329
|
+
return [
|
|
330
|
+
{
|
|
331
|
+
path: entry.path,
|
|
332
|
+
...refs[0] ? { reference: refs[0] } : {},
|
|
333
|
+
...w.length === 2 ? { offset: w[0], window: [w[0], w[1]] } : {}
|
|
334
|
+
}
|
|
335
|
+
];
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function envelope(path) {
|
|
339
|
+
const raw = runFfmpeg([...["-i", path, "-vn", "-ac", "1", "-ar", "8000", "-f", "f32le", "-"]]);
|
|
340
|
+
const s = new Float32Array(
|
|
341
|
+
raw.buffer.slice(raw.byteOffset, raw.byteOffset + (raw.byteLength & ~3))
|
|
342
|
+
);
|
|
343
|
+
const step = 8e3 / ENVELOPE_RATE;
|
|
344
|
+
const out = [];
|
|
345
|
+
for (let i = 0; i + step <= s.length; i += step) {
|
|
346
|
+
let e = 0;
|
|
347
|
+
for (let j = i; j < i + step; j++) e += s[j] ** 2;
|
|
348
|
+
out.push(Math.sqrt(e / step));
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
function bestLag(a, b) {
|
|
353
|
+
let best = { lag: 0, r: -2 };
|
|
354
|
+
const keep = Math.ceil(0.9 * b.length);
|
|
355
|
+
for (let lag = -(b.length - keep); lag <= a.length - keep; lag++) {
|
|
356
|
+
const [i0, i1] = [Math.max(0, -lag), Math.min(b.length, a.length - lag)];
|
|
357
|
+
const n = i1 - i0;
|
|
358
|
+
if (n < Math.max(50, keep)) continue;
|
|
359
|
+
const r = pearson(a.slice(i0 + lag, i1 + lag), b.slice(i0, i1)) ?? -2;
|
|
360
|
+
if (r > best.r) best = { lag, r };
|
|
361
|
+
}
|
|
362
|
+
return best;
|
|
363
|
+
}
|
|
364
|
+
function placeClips(clips, project, ref, cuts, shown = /* @__PURE__ */ new Map()) {
|
|
365
|
+
let whole;
|
|
366
|
+
return clips.map((c2) => {
|
|
367
|
+
const file = project ? join2(project, c2.path) : void 0;
|
|
368
|
+
let info;
|
|
369
|
+
try {
|
|
370
|
+
info = file ? probeVideo(file) : void 0;
|
|
371
|
+
} catch {
|
|
372
|
+
info = void 0;
|
|
373
|
+
}
|
|
374
|
+
if (!info || !file) return { ...c2, note: "the clip's file is not in the project" };
|
|
375
|
+
const uses = shown.get(normalize(c2.path));
|
|
376
|
+
let placed = c2;
|
|
377
|
+
if (c2.offset === void 0 && info.audio && ref.audio) {
|
|
378
|
+
whole ??= envelope(ref.path);
|
|
379
|
+
const { lag, r } = bestLag(whole, envelope(file));
|
|
380
|
+
const offset2 = round(lag / ENVELOPE_RATE + ref.audioStart - info.audioStart, 3);
|
|
381
|
+
placed = r >= LOCATE_MIN ? { ...c2, offset: offset2, match: round(r, 2) } : { ...c2, match: round(r, 2), note: "its sound does not match the original's" };
|
|
382
|
+
}
|
|
383
|
+
if (placed.offset === void 0 && uses?.length)
|
|
384
|
+
placed = { ...placed, offset: round(uses[0].window[0] - uses[0].from / uses[0].rate, 3) };
|
|
385
|
+
if (placed.offset === void 0)
|
|
386
|
+
return {
|
|
387
|
+
...placed,
|
|
388
|
+
file,
|
|
389
|
+
info,
|
|
390
|
+
note: placed.note ?? "no window in the ledger, no sound and no place in the project"
|
|
391
|
+
};
|
|
392
|
+
const offset = placed.offset;
|
|
393
|
+
const end = Math.min(ref.pictureDuration, offset + info.pictureDuration);
|
|
394
|
+
return {
|
|
395
|
+
...placed,
|
|
396
|
+
window: placed.window ?? [round(Math.max(0, offset), 3), round(end, 3)],
|
|
397
|
+
uses: uses ?? [
|
|
398
|
+
{
|
|
399
|
+
window: [round(Math.max(0, offset), 3), round(end, 3)],
|
|
400
|
+
from: Math.max(0, -offset),
|
|
401
|
+
rate: 1
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
at_cut: [0, ...cuts].some((t) => Math.abs(t - offset) <= AT_CUT_S),
|
|
405
|
+
file,
|
|
406
|
+
info,
|
|
407
|
+
...c2.reference && existsSync(join2(project, c2.reference)) ? { still: join2(project, c2.reference) } : {}
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
async function clipUses(project) {
|
|
412
|
+
const out = /* @__PURE__ */ new Map();
|
|
413
|
+
const index = join2(project, "index.html");
|
|
414
|
+
if (!existsSync(index)) return out;
|
|
415
|
+
const [{ ensureDOMParser }, { describeProject }] = await Promise.all([
|
|
416
|
+
import("./dom-VFHEO7VM.js"),
|
|
417
|
+
import("./describeProject-F43LI3YQ.js")
|
|
418
|
+
]);
|
|
419
|
+
ensureDOMParser();
|
|
420
|
+
const timeline = await describeProject(index);
|
|
421
|
+
for (const row of timeline.tracks.find((t) => t.kind === "video")?.rows ?? []) {
|
|
422
|
+
if (!row.src || row.absEnd <= row.absStart) continue;
|
|
423
|
+
const key = normalize(row.src);
|
|
424
|
+
const use = {
|
|
425
|
+
window: [round(row.absStart, 3), round(row.absEnd, 3)],
|
|
426
|
+
from: row.mediaStart ?? 0,
|
|
427
|
+
rate: row.playbackRate ?? 1
|
|
428
|
+
};
|
|
429
|
+
out.set(key, [...out.get(key) ?? [], use]);
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}
|
|
433
|
+
var normalize = (p) => p.replace(/^\.\//, "").replace(/\\/g, "/");
|
|
434
|
+
function boxAt(info, times, box, w, h) {
|
|
435
|
+
const ks = times.map((t) => Math.max(0, Math.min(info.frames - 1, Math.round(t * info.fps))));
|
|
436
|
+
const unique = [...new Set(ks)].sort((x, y) => x - y);
|
|
437
|
+
const work = mkdtempSync2(join2(tmpdir2(), "hf-person-"));
|
|
438
|
+
try {
|
|
439
|
+
const filters = [
|
|
440
|
+
`select=${unique.map((k) => `eq(n\\,${k})`).join("+")}`,
|
|
441
|
+
`scale=${w}:${h}:force_original_aspect_ratio=increase:flags=bicubic`,
|
|
442
|
+
`crop=${w}:${h}`,
|
|
443
|
+
`crop=${box[2]}:${box[3]}:${box[0]}:${box[1]}`,
|
|
444
|
+
"format=rgb24"
|
|
445
|
+
].join(",");
|
|
446
|
+
runFfmpeg(
|
|
447
|
+
[
|
|
448
|
+
...["-i", info.path, "-an", "-vf", filters, "-fps_mode", "passthrough"],
|
|
449
|
+
...["-f", "rawvideo", "out.rgb"]
|
|
450
|
+
],
|
|
451
|
+
void 0,
|
|
452
|
+
work
|
|
453
|
+
);
|
|
454
|
+
const raw = readFileSync2(join2(work, "out.rgb"));
|
|
455
|
+
const size = box[2] * box[3] * 3;
|
|
456
|
+
return ks.map((k) => {
|
|
457
|
+
const i = unique.indexOf(k) * size;
|
|
458
|
+
return i + size <= raw.length ? raw.subarray(i, i + size) : void 0;
|
|
459
|
+
});
|
|
460
|
+
} finally {
|
|
461
|
+
rmSync2(work, { recursive: true, force: true });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function nearby(w, h, x, y, r, test) {
|
|
465
|
+
for (let dy = -r; dy <= r; dy++)
|
|
466
|
+
for (let dx = -r; dx <= r; dx++) {
|
|
467
|
+
const [xx, yy] = [Math.min(w - 1, Math.max(0, x + dx)), Math.min(h - 1, Math.max(0, y + dy))];
|
|
468
|
+
if (test(yy * w + xx)) return true;
|
|
469
|
+
}
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
var dist = (p, i, q, k) => Math.hypot(p[i * 3] - q[k * 3], p[i * 3 + 1] - q[k * 3 + 1], p[i * 3 + 2] - q[k * 3 + 2]);
|
|
473
|
+
function carriedFrame(original, clip, still, w, h, yours) {
|
|
474
|
+
const [sharp, inked] = [contrast(original, w, h), contrast(clip, w, h)];
|
|
475
|
+
let [n, hit] = [0, 0];
|
|
476
|
+
for (let y = 0; y < h; y++)
|
|
477
|
+
for (let x = 0; x < w; x++) {
|
|
478
|
+
const i = y * w + x;
|
|
479
|
+
if (sharp[i] <= TEXT_CONTRAST) continue;
|
|
480
|
+
if (still && !nearby(w, h, x, y, 2, (k) => dist(original, k, still, k) > DRAWN_DIFF))
|
|
481
|
+
continue;
|
|
482
|
+
if (yours && !nearby(w, h, x, y, 2, (k) => dist(yours, k, clip, k) > DRAWN_DIFF)) continue;
|
|
483
|
+
n++;
|
|
484
|
+
const same = (k) => inked[k] > TEXT_CONTRAST && dist(original, i, clip, k) < TEXT_COLOUR;
|
|
485
|
+
if (nearby(w, h, x, y, 2, same)) hit++;
|
|
486
|
+
}
|
|
487
|
+
return n >= TEXT_MIN_INK ? hit / n : null;
|
|
488
|
+
}
|
|
489
|
+
function stillBox(path, box, w, h) {
|
|
490
|
+
try {
|
|
491
|
+
const raw = runFfmpeg([
|
|
492
|
+
...["-i", path, "-frames:v", "1", "-vf"],
|
|
493
|
+
`scale=${w}:${h}:force_original_aspect_ratio=increase:flags=bicubic,crop=${w}:${h},crop=${box[2]}:${box[3]}:${box[0]}:${box[1]},format=rgb24`,
|
|
494
|
+
...["-f", "rawvideo", "-"]
|
|
495
|
+
]);
|
|
496
|
+
return raw.length >= box[2] * box[3] * 3 ? new Uint8Array(raw) : void 0;
|
|
497
|
+
} catch {
|
|
498
|
+
return void 0;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function carriedText(ref, yours, clip, drawn) {
|
|
502
|
+
const spans = clip.uses.flatMap((u) => {
|
|
503
|
+
const [a, b] = [Math.max(drawn.window[0], u.window[0]), Math.min(drawn.window[1], u.window[1])];
|
|
504
|
+
return b - a >= 1 / ref.fps ? [{ a, b, u }] : [];
|
|
505
|
+
});
|
|
506
|
+
const total = spans.reduce((s, x) => s + x.b - x.a, 0);
|
|
507
|
+
if (!total) return void 0;
|
|
508
|
+
const times = Array.from({ length: CARRIED_SAMPLES }, (_, i) => {
|
|
509
|
+
let at = (i + 0.5) * total / CARRIED_SAMPLES;
|
|
510
|
+
for (const x2 of spans) {
|
|
511
|
+
if (at <= x2.b - x2.a)
|
|
512
|
+
return { t: x2.a + at, c: x2.u.from + (at + x2.a - x2.u.window[0]) * x2.u.rate };
|
|
513
|
+
at -= x2.b - x2.a;
|
|
514
|
+
}
|
|
515
|
+
const x = spans.at(-1);
|
|
516
|
+
return { t: x.b, c: x.u.from + (x.b - x.u.window[0]) * x.u.rate };
|
|
517
|
+
});
|
|
518
|
+
const orig = boxAt(
|
|
519
|
+
ref,
|
|
520
|
+
times.map((x) => x.t),
|
|
521
|
+
drawn.box,
|
|
522
|
+
ref.width,
|
|
523
|
+
ref.height
|
|
524
|
+
);
|
|
525
|
+
const generated = boxAt(
|
|
526
|
+
clip.info,
|
|
527
|
+
times.map((x) => x.c),
|
|
528
|
+
drawn.box,
|
|
529
|
+
ref.width,
|
|
530
|
+
ref.height
|
|
531
|
+
);
|
|
532
|
+
const mine = boxAt(
|
|
533
|
+
yours,
|
|
534
|
+
times.map((x) => x.t),
|
|
535
|
+
drawn.box,
|
|
536
|
+
ref.width,
|
|
537
|
+
ref.height
|
|
538
|
+
);
|
|
539
|
+
const still = clip.still ? stillBox(clip.still, drawn.box, ref.width, ref.height) : void 0;
|
|
540
|
+
const scores2 = orig.flatMap((o, i) => {
|
|
541
|
+
const g = generated[i];
|
|
542
|
+
const s = o && g ? carriedFrame(o, g, still, drawn.box[2], drawn.box[3], mine[i]) : null;
|
|
543
|
+
return s === null ? [] : [s];
|
|
544
|
+
});
|
|
545
|
+
if (!scores2.length) return void 0;
|
|
546
|
+
const score = scores2.reduce((s, v) => s + v, 0) / scores2.length;
|
|
547
|
+
return {
|
|
548
|
+
drawn: drawn.id,
|
|
549
|
+
clip: clip.path,
|
|
550
|
+
window: [round(spans[0].a, 3), round(spans.at(-1).b, 3)],
|
|
551
|
+
score: round(score, 3),
|
|
552
|
+
carried: score >= CARRIED_TEXT
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
var median2 = (v) => [...v].sort((x, y) => x - y)[v.length >> 1];
|
|
556
|
+
var centre = (b) => [b[0] + b[2] / 2, b[1] + b[3] / 2];
|
|
557
|
+
function shotsIn(window, cuts) {
|
|
558
|
+
const edges = [window[0], ...cuts.filter((t) => t > window[0] && t < window[1]), window[1]];
|
|
559
|
+
return edges.slice(1).map((e, i) => [edges[i], e]);
|
|
560
|
+
}
|
|
561
|
+
function shotFraming(window, original, yours, aspect = 1) {
|
|
562
|
+
const inside = (s) => s.t >= window[0] && s.t < window[1];
|
|
563
|
+
const apart = (b2, x, y) => Math.hypot((centre(b2)[0] - x) * aspect, centre(b2)[1] - y);
|
|
564
|
+
const [a, b] = [original.filter(inside), yours.filter(inside)];
|
|
565
|
+
const moments = a.flatMap((o, i) => {
|
|
566
|
+
const y = b[i];
|
|
567
|
+
if (!o.boxes.length || !y?.boxes.length) return [];
|
|
568
|
+
const subject = o.boxes.reduce((p, q) => q[3] > p[3] ? q : p);
|
|
569
|
+
const [ox, oy] = centre(subject);
|
|
570
|
+
const near = y.boxes.reduce((p, q) => apart(q, ox, oy) < apart(p, ox, oy) ? q : p);
|
|
571
|
+
return [{ shift: apart(near, ox, oy) / subject[3], scale: near[3] / subject[3] }];
|
|
572
|
+
});
|
|
573
|
+
if (moments.length < FRAMING_MIN_FACES) return void 0;
|
|
574
|
+
const shift = round(median2(moments.map((m) => m.shift)), 3);
|
|
575
|
+
const scale = round(median2(moments.map((m) => m.scale)), 3);
|
|
576
|
+
return {
|
|
577
|
+
window: [round(window[0], 3), round(window[1], 3)],
|
|
578
|
+
shift,
|
|
579
|
+
scale,
|
|
580
|
+
pass: shift <= FRAMING_SHIFT && scale >= FRAMING_SCALE[0] && scale <= FRAMING_SCALE[1]
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
function syncPass(r) {
|
|
584
|
+
if (r.confidence !== "high" || r.best_lag_ms === null) return null;
|
|
585
|
+
return r.best_lag_ms >= SYNC_MS[0] && r.best_lag_ms <= SYNC_MS[1];
|
|
586
|
+
}
|
|
587
|
+
async function personVerdict(opts) {
|
|
588
|
+
const { ref, yours, window } = opts;
|
|
589
|
+
const shots = shotsIn(window, opts.cuts);
|
|
590
|
+
const n = Math.max(2, Math.round((window[1] - window[0]) * FACE_RATE));
|
|
591
|
+
const drawnFace = (t, b) => opts.drawn.some(({ box: [x, y, w, h], window: [a, z] }) => {
|
|
592
|
+
const [cx, cy] = [(b[0] + b[2] / 2) * ref.width, (b[1] + b[3] / 2) * ref.height];
|
|
593
|
+
return t >= a && t < z && cx >= x && cx < x + w && cy >= y && cy < y + h;
|
|
594
|
+
});
|
|
595
|
+
const people = (samples) => samples.map((f) => ({ ...f, boxes: f.boxes.filter((b) => !drawnFace(f.t, b)) }));
|
|
596
|
+
const [fo, fy] = [
|
|
597
|
+
people(await faceBoxes(ref, window[0], window[1], n)),
|
|
598
|
+
people(await faceBoxes(yours, window[0], window[1], n))
|
|
599
|
+
];
|
|
600
|
+
const framing = shots.flatMap(
|
|
601
|
+
(s) => s[1] - s[0] >= FRAMING_MIN_S ? [shotFraming(s, fo, fy, ref.width / ref.height)].filter((f) => f !== void 0) : []
|
|
602
|
+
);
|
|
603
|
+
const text = opts.drawn.flatMap(
|
|
604
|
+
(d) => opts.clips.flatMap(
|
|
605
|
+
(c2) => c2.info && c2.uses ? [
|
|
606
|
+
carriedText(
|
|
607
|
+
ref,
|
|
608
|
+
yours,
|
|
609
|
+
{ path: c2.path, info: c2.info, uses: c2.uses, still: c2.still },
|
|
610
|
+
d
|
|
611
|
+
)
|
|
612
|
+
].filter((t) => t !== void 0) : []
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
const sync = shots.flatMap((s) => {
|
|
616
|
+
if (s[1] - s[0] < SYNC_MIN_S || !yours.audio) return [];
|
|
617
|
+
const mouth = (info, samples) => {
|
|
618
|
+
const boxes = samples.filter((f) => f.t >= s[0] && f.t < s[1] && f.boxes.length).map((f) => f.boxes.reduce((x2, y2) => y2[3] > x2[3] ? y2 : x2));
|
|
619
|
+
if (boxes.length < FRAMING_MIN_FACES) return void 0;
|
|
620
|
+
const [x, y, w, h] = [0, 1, 2, 3].map((i) => median2(boxes.map((b) => b[i])));
|
|
621
|
+
const roi = [
|
|
622
|
+
Math.round((x + 0.2 * w) * info.width / 2) * 2,
|
|
623
|
+
Math.round((y + 0.62 * h) * info.height / 2) * 2,
|
|
624
|
+
Math.max(8, Math.round(0.6 * w * info.width / 2) * 2),
|
|
625
|
+
Math.max(8, Math.round(0.38 * h * info.height / 2) * 2)
|
|
626
|
+
];
|
|
627
|
+
return roi[0] + roi[2] <= info.width && roi[1] + roi[3] <= info.height ? roi : void 0;
|
|
628
|
+
};
|
|
629
|
+
const [mo, my] = [mouth(ref, fo), mouth(yours, fy)];
|
|
630
|
+
if (!my) return [];
|
|
631
|
+
const mine = avSync(yours, my, s[0], s[1]);
|
|
632
|
+
if (mine.speech_active_fraction < SYNC_MIN_SPEECH) return [];
|
|
633
|
+
const theirs = mo && ref.audio ? avSync(ref, mo, s[0], s[1]) : void 0;
|
|
634
|
+
return [
|
|
635
|
+
{
|
|
636
|
+
window: [round(s[0], 3), round(s[1], 3)],
|
|
637
|
+
lag_ms: mine.best_lag_ms,
|
|
638
|
+
original_lag_ms: theirs?.best_lag_ms ?? null,
|
|
639
|
+
confidence: mine.confidence,
|
|
640
|
+
pass: syncPass(mine)
|
|
641
|
+
}
|
|
642
|
+
];
|
|
643
|
+
});
|
|
644
|
+
const gate = (v) => v.includes(false) ? false : v.some((p) => p === true) ? true : null;
|
|
645
|
+
const gates = {
|
|
646
|
+
framing: gate(framing.map((f) => f.pass)),
|
|
647
|
+
text: gate(text.map((t) => !t.carried)),
|
|
648
|
+
sync: gate(sync.map((s) => s.pass))
|
|
649
|
+
};
|
|
650
|
+
const all = Object.values(gates);
|
|
651
|
+
return {
|
|
652
|
+
gates,
|
|
653
|
+
pass: all.includes(false) ? false : all.some((g) => g === true) ? true : null,
|
|
654
|
+
...framing.length ? { framing } : {},
|
|
655
|
+
...text.length ? { text } : {},
|
|
656
|
+
...sync.length ? { sync } : {}
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// src/measure/diff.ts
|
|
661
|
+
var DEFAULT_MIN_MEAN = 0.92;
|
|
662
|
+
var DEFAULT_MIN_P05 = 0.85;
|
|
663
|
+
var DEFAULT_MIN_CELL = 0.75;
|
|
664
|
+
var ENERGY_RATIO = [0.8, 1.25];
|
|
665
|
+
var GRID = 4;
|
|
666
|
+
var ALL_CELLS = Array.from({ length: GRID * GRID }, (_, c2) => c2);
|
|
667
|
+
var WORST_GAP_S = 0.5;
|
|
668
|
+
var SHEET_W = 960;
|
|
669
|
+
var CUT_SLACK = 1;
|
|
670
|
+
var REGION_CELL_SHARE = 0.1;
|
|
671
|
+
var MISSING_W = 192;
|
|
672
|
+
var MISSING_SAMPLES = 1800;
|
|
673
|
+
var MISSING_DETAIL = 8;
|
|
674
|
+
var MISSING_KEEP = 0.35;
|
|
675
|
+
var MISSING_FLAT = 4;
|
|
676
|
+
var MISSING_MAX_SHARE = 0.02;
|
|
677
|
+
var STRUCTURE_SCALE = 8;
|
|
678
|
+
var WHOLE_FRAME_SHARE = 0.9;
|
|
679
|
+
var REUSE_SSIM = 0.9;
|
|
680
|
+
var REUSE_MAX_FRAMES = 2;
|
|
681
|
+
var REUSE_MIN_S = 0.5;
|
|
682
|
+
var STILL_W = 96;
|
|
683
|
+
var STILL_DIFF = 4;
|
|
684
|
+
var pct = (sorted, p) => sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))] ?? 0;
|
|
685
|
+
function scores(frame, worstCell) {
|
|
686
|
+
const sorted = [...frame].sort((a, b) => a - b);
|
|
687
|
+
const n = sorted.length;
|
|
688
|
+
return {
|
|
689
|
+
frames: n,
|
|
690
|
+
mean: round(n ? sorted.reduce((s, v) => s + v, 0) / n : 0, 4),
|
|
691
|
+
p05: round(pct(sorted, 0.05), 4),
|
|
692
|
+
min: round(sorted[0] ?? 0, 4),
|
|
693
|
+
cell_p05: round(
|
|
694
|
+
pct(
|
|
695
|
+
[...worstCell].sort((a, b) => a - b),
|
|
696
|
+
0.05
|
|
697
|
+
),
|
|
698
|
+
4
|
|
699
|
+
)
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
var passes = (s, t) => s.frames > 0 && s.mean >= t.mean && s.p05 >= t.p05 && s.cell_p05 >= t.cell;
|
|
703
|
+
function pickedFrames(pick, total) {
|
|
704
|
+
if (pick.kind === "at") return pick.ks;
|
|
705
|
+
const [k0, k1] = pick.kind === "range" ? [pick.k0, pick.k1] : [0, total];
|
|
706
|
+
return Array.from({ length: Math.max(0, k1 - k0) }, (_, i) => k0 + i);
|
|
707
|
+
}
|
|
708
|
+
function selectFilter(pick, fpsText) {
|
|
709
|
+
const pts = `setpts=N/(${fpsText})/TB`;
|
|
710
|
+
if (pick.kind === "all") return [];
|
|
711
|
+
if (pick.kind === "range") return [`select=between(n\\,${pick.k0}\\,${pick.k1 - 1})`, pts];
|
|
712
|
+
return [`select=${pick.ks.map((k) => `eq(n\\,${k})`).join("+")}`, pts];
|
|
713
|
+
}
|
|
714
|
+
var cellSize = (w, h) => [
|
|
715
|
+
Math.floor(w / (2 * GRID)) * 2,
|
|
716
|
+
Math.floor(h / (2 * GRID)) * 2
|
|
717
|
+
];
|
|
718
|
+
function ssimSeries(ref, yours, logPath) {
|
|
719
|
+
const side = (filters) => [...filters, "setsar=1", "format=yuv420p"].join(",");
|
|
720
|
+
const n = GRID * GRID + 1;
|
|
721
|
+
const tags = (p) => Array.from({ length: n }, (_, i) => `[${p}${i}]`).join("");
|
|
722
|
+
const [cw, ch] = cellSize(ref.width, ref.height);
|
|
723
|
+
const graph = [
|
|
724
|
+
`[0:v]${side(ref.filters)},split=${n}${tags("r")}`,
|
|
725
|
+
`[1:v]${side([...yours.filters, `scale=${ref.width}:${ref.height}:flags=bicubic`])},split=${n}${tags("o")}`,
|
|
726
|
+
"[o0][r0]ssim=stats_file=-:shortest=1[s0]",
|
|
727
|
+
...Array.from({ length: GRID * GRID }, (_, i) => {
|
|
728
|
+
const crop = `crop=${cw}:${ch}:${i % GRID * cw}:${Math.floor(i / GRID) * ch}`;
|
|
729
|
+
const k = i + 1;
|
|
730
|
+
return `[r${k}]${crop}[rc${k}];[o${k}]${crop}[oc${k}];[oc${k}][rc${k}]ssim=stats_file=cell${i}.log:shortest=1[s${k}]`;
|
|
731
|
+
})
|
|
732
|
+
].join(";");
|
|
733
|
+
const work = mkdtempSync3(join3(tmpdir3(), "hf-diff-cells-"));
|
|
734
|
+
const all = (text) => [...text.matchAll(/All:([\d.]+)/g)].map((m) => Number(m[1]));
|
|
735
|
+
try {
|
|
736
|
+
const maps = Array.from({ length: n }, (_, i) => ["-map", `[s${i}]`]).flat();
|
|
737
|
+
const text = runFfmpeg(
|
|
738
|
+
[...ref.input, ...yours.input, "-filter_complex", graph, ...maps, "-f", "null", "-"],
|
|
739
|
+
void 0,
|
|
740
|
+
work
|
|
741
|
+
).toString();
|
|
742
|
+
writeFileSync(logPath, text);
|
|
743
|
+
const frame = all(text);
|
|
744
|
+
const perCell = Array.from(
|
|
745
|
+
{ length: GRID * GRID },
|
|
746
|
+
(_, i) => all(readFileSync3(join3(work, `cell${i}.log`), "utf8"))
|
|
747
|
+
);
|
|
748
|
+
return { frame, cells: frame.map((_, f) => perCell.map((cell) => cell[f] ?? 1)) };
|
|
749
|
+
} finally {
|
|
750
|
+
rmSync3(work, { recursive: true, force: true });
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
function missingContent(ref, yours, ks, fps, judged = () => ALL_CELLS) {
|
|
754
|
+
const stride = Math.max(1, Math.ceil(ks.length / MISSING_SAMPLES));
|
|
755
|
+
const w = MISSING_W;
|
|
756
|
+
const h = Math.max(GRID * 2, Math.round(w * ref.height / ref.width / GRID) * GRID);
|
|
757
|
+
const [cw, ch] = [
|
|
758
|
+
w / STRUCTURE_SCALE,
|
|
759
|
+
Math.max(GRID, Math.round(h / STRUCTURE_SCALE / GRID) * GRID)
|
|
760
|
+
];
|
|
761
|
+
const thin = stride > 1 ? [`select=not(mod(n\\,${stride}))`, `setpts=N/(${fps / stride})/TB`] : [];
|
|
762
|
+
const spreads = (clip, sw, sh) => decode(clip.input, [...clip.filters, ...thin, `scale=${sw}:${sh}`], sw, sh, true).frames.map(
|
|
763
|
+
(px) => cellSpreads(px, sw, sh)
|
|
764
|
+
);
|
|
765
|
+
const [a, b, coarse] = [spreads(ref, w, h), spreads(yours, w, h), spreads(ref, cw, ch)];
|
|
766
|
+
const n = Math.min(a.length, b.length, coarse.length, Math.ceil(ks.length / stride));
|
|
767
|
+
const kinds = Array.from({ length: n }, (_, j) => {
|
|
768
|
+
const empty = judged(ks[j * stride]).filter((c2) => {
|
|
769
|
+
const s = a[j][c2];
|
|
770
|
+
return s >= MISSING_DETAIL && b[j][c2] < Math.min(MISSING_FLAT, MISSING_KEEP * s);
|
|
771
|
+
});
|
|
772
|
+
return {
|
|
773
|
+
structure: empty.some((c2) => coarse[j][c2] >= MISSING_DETAIL),
|
|
774
|
+
texture: empty.length > 0
|
|
775
|
+
};
|
|
776
|
+
});
|
|
777
|
+
const spansOf = (on) => {
|
|
778
|
+
const spans = [];
|
|
779
|
+
on.forEach((e, j) => {
|
|
780
|
+
if (!e) return;
|
|
781
|
+
const t = round(ks[j * stride] / fps, 3);
|
|
782
|
+
const end = round((ks[Math.min(ks.length - 1, (j + 1) * stride - 1)] + 1) / fps, 3);
|
|
783
|
+
const last = spans.at(-1);
|
|
784
|
+
if (last && on[j - 1]) last[1] = end;
|
|
785
|
+
else spans.push([t, end]);
|
|
786
|
+
});
|
|
787
|
+
return spans.sort((x, y) => y[1] - y[0] - (x[1] - x[0])).slice(0, 8).sort((x, y) => x[0] - y[0]);
|
|
788
|
+
};
|
|
789
|
+
const structure = kinds.map((k) => k.structure);
|
|
790
|
+
const texture = kinds.map((k) => k.texture && !k.structure);
|
|
791
|
+
const share = n ? structure.filter(Boolean).length / n : 0;
|
|
792
|
+
return {
|
|
793
|
+
share: round(share, 4),
|
|
794
|
+
spans: spansOf(structure),
|
|
795
|
+
pass: share <= MISSING_MAX_SHARE,
|
|
796
|
+
texture: {
|
|
797
|
+
share: round(n ? texture.filter(Boolean).length / n : 0, 4),
|
|
798
|
+
spans: spansOf(texture)
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function cellSpreads(px, w, h) {
|
|
803
|
+
const [cw, ch] = [Math.floor(w / GRID), Math.floor(h / GRID)];
|
|
804
|
+
return Array.from({ length: GRID * GRID }, (_, c2) => {
|
|
805
|
+
const [x0, y0] = [c2 % GRID * cw, Math.floor(c2 / GRID) * ch];
|
|
806
|
+
let [s, ss] = [0, 0];
|
|
807
|
+
for (let y = y0; y < y0 + ch; y++)
|
|
808
|
+
for (let x = x0; x < x0 + cw; x++) {
|
|
809
|
+
const v = px[y * w + x];
|
|
810
|
+
s += v;
|
|
811
|
+
ss += v * v;
|
|
812
|
+
}
|
|
813
|
+
const m = s / (cw * ch);
|
|
814
|
+
return Math.sqrt(Math.max(0, ss / (cw * ch) - m * m));
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
function worstIndexes(worstCell, ks, fps, count) {
|
|
818
|
+
const order = worstCell.map((_, i) => i).filter((i) => worstCell[i] < 0.98).sort((a, b) => worstCell[a] - worstCell[b]);
|
|
819
|
+
const out = [];
|
|
820
|
+
for (const i of order) {
|
|
821
|
+
if (out.length >= count) break;
|
|
822
|
+
if (out.every((j) => Math.abs(ks[i] - ks[j]) / fps >= WORST_GAP_S)) out.push(i);
|
|
823
|
+
}
|
|
824
|
+
return out.sort((a, b) => ks[a] - ks[b]);
|
|
825
|
+
}
|
|
826
|
+
function frameOf(clip, i, w, h) {
|
|
827
|
+
const { frames } = decode(
|
|
828
|
+
clip.input,
|
|
829
|
+
[...clip.filters, `select=eq(n\\,${i})`, `scale=${w}:${h}`],
|
|
830
|
+
w,
|
|
831
|
+
h,
|
|
832
|
+
false,
|
|
833
|
+
1
|
|
834
|
+
);
|
|
835
|
+
if (!frames[0]) throw new Fix(`could not read frame ${i}`, "check both videos play to their end");
|
|
836
|
+
return frames[0];
|
|
837
|
+
}
|
|
838
|
+
function outline(px, w, [x, y, bw, bh], t = 3) {
|
|
839
|
+
const h = px.length / 3 / w;
|
|
840
|
+
for (let yy = y; yy < Math.min(h, y + bh); yy++)
|
|
841
|
+
for (let xx = x; xx < Math.min(w, x + bw); xx++) {
|
|
842
|
+
const edge = yy - y < t || y + bh - 1 - yy < t || xx - x < t || x + bw - 1 - xx < t;
|
|
843
|
+
if (edge) px.set([255, 40, 40], (yy * w + xx) * 3);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
function cutReport(ref, yours, k0, fps) {
|
|
847
|
+
const [da, db] = [ref, yours].map((c2) => frameChanges(signatures(c2.input, c2.filters).frames));
|
|
848
|
+
const [a, b] = [cutsIn(da), cutsIn(db)];
|
|
849
|
+
const used = /* @__PURE__ */ new Set();
|
|
850
|
+
const missing = [];
|
|
851
|
+
for (const cut of a) {
|
|
852
|
+
const hit = b.find((g) => !used.has(g.frame) && Math.abs(g.frame - cut.frame) <= CUT_SLACK);
|
|
853
|
+
if (hit) used.add(hit.frame);
|
|
854
|
+
else if (!(cut.soft && confirmsCut(db, cut))) missing.push(cut.frame);
|
|
855
|
+
}
|
|
856
|
+
const extra = b.filter((g) => !used.has(g.frame) && !(g.soft && confirmsCut(da, g)));
|
|
857
|
+
const t = (f) => round((k0 + f) / fps, 3);
|
|
858
|
+
return {
|
|
859
|
+
reference: a.map((c2) => t(c2.frame)),
|
|
860
|
+
yours: b.map((c2) => t(c2.frame)),
|
|
861
|
+
missing: missing.map(t),
|
|
862
|
+
extra: extra.map((c2) => t(c2.frame)),
|
|
863
|
+
pass: missing.length === 0 && extra.length === 0
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
async function captureProject(projectDir, times, opts, ref) {
|
|
867
|
+
const { captureSnapshots } = await import("./snapshot-57YYYE5J.js");
|
|
868
|
+
const shots = mkdtempSync3(join3(tmpdir3(), "hf-diff-shots-"));
|
|
869
|
+
const seq = mkdtempSync3(join3(tmpdir3(), "hf-diff-seq-"));
|
|
870
|
+
try {
|
|
871
|
+
const captured = await captureSnapshots(projectDir, {
|
|
872
|
+
at: times,
|
|
873
|
+
includeEnd: false,
|
|
874
|
+
outputDir: shots,
|
|
875
|
+
timeout: opts.timeoutMs,
|
|
876
|
+
log: opts.log ?? (() => {
|
|
877
|
+
}),
|
|
878
|
+
record: false
|
|
879
|
+
});
|
|
880
|
+
if (captured.paths.length !== times.length)
|
|
881
|
+
throw new Fix(
|
|
882
|
+
`captured ${captured.paths.length} of ${times.length} frames from ${projectDir}`,
|
|
883
|
+
"run npx hyperframes check on the project, then diff again"
|
|
884
|
+
);
|
|
885
|
+
captured.paths.forEach(
|
|
886
|
+
(p, i) => copyFileSync(resolve(projectDir, p), join3(seq, `${String(i).padStart(6, "0")}.png`))
|
|
887
|
+
);
|
|
888
|
+
} catch (err) {
|
|
889
|
+
rmSync3(seq, { recursive: true, force: true });
|
|
890
|
+
throw err;
|
|
891
|
+
} finally {
|
|
892
|
+
rmSync3(shots, { recursive: true, force: true });
|
|
893
|
+
}
|
|
894
|
+
return {
|
|
895
|
+
dir: seq,
|
|
896
|
+
clip: {
|
|
897
|
+
input: ["-framerate", ref.fpsText, "-i", join3(seq, "%06d.png")],
|
|
898
|
+
filters: [],
|
|
899
|
+
width: ref.width,
|
|
900
|
+
height: ref.height,
|
|
901
|
+
fps: ref.fps
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
function regeneratedVerdict(s, reference, yours, ref, roi) {
|
|
906
|
+
const seconds = s.end - s.start;
|
|
907
|
+
const [a, b] = [videoClip(reference, s.start, seconds, ref), videoClip(yours, s.start, seconds)];
|
|
908
|
+
const mine = roi && scaleRoi(roi, b.width / ref.width, b.height / ref.height);
|
|
909
|
+
const energy = compareEnergy(energyCurve(a, roi), energyCurve(b, mine));
|
|
910
|
+
const looks = compareLook(look(a, 2, roi), look(b, 2, mine));
|
|
911
|
+
const moves = energy.mean_ratio >= ENERGY_RATIO[0] && energy.mean_ratio <= ENERGY_RATIO[1];
|
|
912
|
+
return { pass: moves && sameLook(looks), energy, look: looks };
|
|
913
|
+
}
|
|
914
|
+
var scaleRoi = ([x, y, w, h], sx, sy) => {
|
|
915
|
+
const [x0, y0] = [Math.round(x * sx / 2) * 2, Math.round(y * sy / 2) * 2];
|
|
916
|
+
return [
|
|
917
|
+
x0,
|
|
918
|
+
y0,
|
|
919
|
+
Math.max(2, Math.round(w * sx / 2) * 2),
|
|
920
|
+
Math.max(2, Math.round(h * sy / 2) * 2)
|
|
921
|
+
];
|
|
922
|
+
};
|
|
923
|
+
function regionRoi(box, width, height) {
|
|
924
|
+
const [sx, sy] = box.every((v) => v <= 1) ? [width, height] : [1, 1];
|
|
925
|
+
const roi = scaleRoi(box, sx, sy);
|
|
926
|
+
const [x, y] = [Math.min(roi[0], width - 2), Math.min(roi[1], height - 2)];
|
|
927
|
+
return [x, y, Math.min(roi[2], width - x), Math.min(roi[3], height - y)];
|
|
928
|
+
}
|
|
929
|
+
function cellsOutside(roi, width, height) {
|
|
930
|
+
const [cw, ch] = cellSize(width, height);
|
|
931
|
+
return ALL_CELLS.filter((c2) => {
|
|
932
|
+
const [x, y] = [c2 % GRID * cw, Math.floor(c2 / GRID) * ch];
|
|
933
|
+
const ox = Math.max(0, Math.min(x + cw, roi[0] + roi[2]) - Math.max(x, roi[0]));
|
|
934
|
+
const oy = Math.max(0, Math.min(y + ch, roi[1] + roi[3]) - Math.max(y, roi[1]));
|
|
935
|
+
return ox * oy <= REGION_CELL_SHARE * cw * ch;
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
function segmentVerdicts(segments, series, worstCell, ks, ctx) {
|
|
939
|
+
return segments.map((s) => {
|
|
940
|
+
const head = { id: s.id, window: [s.start, s.end], pixels: s.pixels };
|
|
941
|
+
if (s.pixels === "regenerated" && !s.drawn) {
|
|
942
|
+
if (ctx.mode !== "video")
|
|
943
|
+
return {
|
|
944
|
+
...head,
|
|
945
|
+
pass: null,
|
|
946
|
+
note: "regenerated pixels are judged on a render: diff a render"
|
|
947
|
+
};
|
|
948
|
+
const moved = regeneratedVerdict(s, ctx.reference, ctx.yours, ctx.ref);
|
|
949
|
+
const person = ctx.person.get(s);
|
|
950
|
+
if (!person || person.pass === null) return { ...head, ...moved };
|
|
951
|
+
return {
|
|
952
|
+
...head,
|
|
953
|
+
pass: person.pass,
|
|
954
|
+
scored: "the person: framing, text carried in the generated clip, lip sync",
|
|
955
|
+
person: { ...person, energy: moved.energy, look: moved.look }
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
const [a, b] = [frameAt(s.start, ctx.ref.fps), frameAt(s.end, ctx.ref.fps)];
|
|
959
|
+
const mine = ks.flatMap((k, i) => k >= a && k < b && i < series.frame.length ? [i] : []);
|
|
960
|
+
if (!mine.length)
|
|
961
|
+
return { ...head, pass: null, note: "no compared frame falls in this segment" };
|
|
962
|
+
if (s.regenerated || s.pixels === "regenerated")
|
|
963
|
+
return mixedVerdict(s, head, mine, series, ctx);
|
|
964
|
+
const st = scores(
|
|
965
|
+
mine.map((i) => series.frame[i]),
|
|
966
|
+
mine.map((i) => worstCell[i])
|
|
967
|
+
);
|
|
968
|
+
return {
|
|
969
|
+
...head,
|
|
970
|
+
pass: passes(st, ctx.t),
|
|
971
|
+
ssim: st,
|
|
972
|
+
worst_cell: lowestCell(mine, series, ks, ctx.ref)
|
|
973
|
+
};
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
function lowestCell(mine, series, ks, ref) {
|
|
977
|
+
const means = series.cells[mine[0]].map(
|
|
978
|
+
(_, c3) => mine.reduce((sum, i) => sum + series.cells[i][c3], 0) / mine.length
|
|
979
|
+
);
|
|
980
|
+
const c2 = means.indexOf(Math.min(...means));
|
|
981
|
+
const at = mine.reduce((lo, i) => series.cells[i][c2] < series.cells[lo][c2] ? i : lo);
|
|
982
|
+
const [cw, ch] = cellSize(ref.width, ref.height);
|
|
983
|
+
return {
|
|
984
|
+
roi: [c2 % GRID * cw, Math.floor(c2 / GRID) * ch, cw, ch],
|
|
985
|
+
ssim: round(means[c2], 4),
|
|
986
|
+
t: round(ks[at] / ref.fps, 3)
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
function mixedVerdict(s, head, mine, series, ctx) {
|
|
990
|
+
const whole = s.pixels === "regenerated";
|
|
991
|
+
const roi = whole ? [0, 0, ctx.ref.width, ctx.ref.height] : regionRoi(s.regenerated, ctx.ref.width, ctx.ref.height);
|
|
992
|
+
const rest = whole ? [] : cellsOutside(roi, ctx.ref.width, ctx.ref.height);
|
|
993
|
+
const moved = ctx.mode === "video" ? regeneratedVerdict(s, ctx.reference, ctx.yours, ctx.ref, whole ? void 0 : roi) : void 0;
|
|
994
|
+
const gates = ctx.person.get(s);
|
|
995
|
+
const person = gates || moved ? {
|
|
996
|
+
...gates ?? { gates: { framing: null, text: null, sync: null }, pass: null },
|
|
997
|
+
energy: moved?.energy,
|
|
998
|
+
look: moved?.look
|
|
999
|
+
} : void 0;
|
|
1000
|
+
const st = rest.length ? scores(
|
|
1001
|
+
mine.map((i) => rest.reduce((sum, c2) => sum + series.cells[i][c2], 0) / rest.length),
|
|
1002
|
+
mine.map((i) => Math.min(...rest.map((c2) => series.cells[i][c2])))
|
|
1003
|
+
) : void 0;
|
|
1004
|
+
const drawn = ctx.drawn.get(s) ?? [];
|
|
1005
|
+
const verdicts = [
|
|
1006
|
+
st ? passes(st, ctx.t) : null,
|
|
1007
|
+
person?.pass ?? null,
|
|
1008
|
+
...drawn.map((d) => d.pass)
|
|
1009
|
+
];
|
|
1010
|
+
const pass = verdicts.includes(false) ? false : verdicts.every((p) => p === null) ? null : true;
|
|
1011
|
+
const scored = [
|
|
1012
|
+
st ? `SSIM: the ${rest.length} cells outside the regenerated box` : drawn.length ? "drawn elements only (no cell is outside the regenerated box)" : "no pixels (the regenerated box covers every cell)",
|
|
1013
|
+
"the person: framing, text carried in the generated clip, lip sync (motion and look reported)",
|
|
1014
|
+
...drawn.length ? [`${drawn.length} drawn elements, each scored by itself`] : []
|
|
1015
|
+
].join("; ");
|
|
1016
|
+
const note = ctx.mode === "project" ? { note: `the regenerated ${whole ? "picture" : "region"} is judged on a render` } : {};
|
|
1017
|
+
const parts = {
|
|
1018
|
+
pass,
|
|
1019
|
+
scored,
|
|
1020
|
+
...st ? { ssim: st } : {},
|
|
1021
|
+
...drawn.length ? { drawn } : {},
|
|
1022
|
+
...person ? { person } : {}
|
|
1023
|
+
};
|
|
1024
|
+
return { ...head, ...parts, ...whole ? {} : { regenerated: { roi } }, ...note };
|
|
1025
|
+
}
|
|
1026
|
+
function scoreDrawn(segments, refClip, yours, ks, ref, available) {
|
|
1027
|
+
const jobs = segments.flatMap((s) => drawnOf(s, ref).map((d) => ({ s, ...d })));
|
|
1028
|
+
const verdicts = scoreElements(jobs, refClip, yours, ks, ref, available);
|
|
1029
|
+
const out = /* @__PURE__ */ new Map();
|
|
1030
|
+
jobs.forEach((j, n) => out.set(j.s, [...out.get(j.s) ?? [], verdicts[n]]));
|
|
1031
|
+
return out;
|
|
1032
|
+
}
|
|
1033
|
+
function scoreElements(elements, refClip, yours, ks, ref, available) {
|
|
1034
|
+
const jobs = elements.map((d) => ({
|
|
1035
|
+
...d,
|
|
1036
|
+
frames: drawnFrames(ks, ref.fps, ...d.window, available)
|
|
1037
|
+
}));
|
|
1038
|
+
const live = jobs.filter((j) => j.frames.length);
|
|
1039
|
+
const [a, b] = [refClip, yours].map((clip) => readDrawn(clip, live, ref.width, ref.height));
|
|
1040
|
+
return jobs.map((j) => {
|
|
1041
|
+
const n = live.indexOf(j);
|
|
1042
|
+
const pairs = n < 0 ? [] : a[n].map((fa, i) => [fa, b[n][i]]).filter(([, fb]) => fb);
|
|
1043
|
+
const frames = pairs.map(([fa, fb]) => scoreDrawnFrame(fa, fb, j.box[2], j.box[3]));
|
|
1044
|
+
return { id: j.id, ...drawnVerdict(j.box, j.window, frames) };
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
function drawnOf(s, ref) {
|
|
1048
|
+
if (!(s.regenerated || s.pixels === "regenerated")) return [];
|
|
1049
|
+
return (s.drawn ?? []).map((d, n) => ({
|
|
1050
|
+
id: `${s.id}.D${n + 1}`,
|
|
1051
|
+
box: regionRoi(d.box, ref.width, ref.height),
|
|
1052
|
+
window: [Math.max(s.start, d.window?.[0] ?? s.start), Math.min(s.end, d.window?.[1] ?? s.end)]
|
|
1053
|
+
}));
|
|
1054
|
+
}
|
|
1055
|
+
function headline(segments, clips, t, cuts = []) {
|
|
1056
|
+
const parts = segments.flatMap((v) => [
|
|
1057
|
+
...v.ssim ? [{ pass: passes(v.ssim, t), score: v.ssim.mean }] : [],
|
|
1058
|
+
...(v.drawn ?? []).flatMap(
|
|
1059
|
+
(d) => d.pass === null ? [] : [{ pass: d.pass, score: d.score ?? 0 }]
|
|
1060
|
+
)
|
|
1061
|
+
]);
|
|
1062
|
+
const people = segments.flatMap(
|
|
1063
|
+
(v) => v.person ? [{ id: v.id, window: v.window, ...v.person }] : []
|
|
1064
|
+
);
|
|
1065
|
+
const gate = (key) => {
|
|
1066
|
+
const g = people.map((p) => p.gates[key]);
|
|
1067
|
+
return g.includes(false) ? false : g.some((x) => x === true) ? true : null;
|
|
1068
|
+
};
|
|
1069
|
+
const ratios = people.flatMap((p) => p.energy ? [p.energy.mean_ratio] : []);
|
|
1070
|
+
const placed = clips.filter((c2) => c2.at_cut !== void 0);
|
|
1071
|
+
return {
|
|
1072
|
+
components: {
|
|
1073
|
+
passed: parts.filter((p) => p.pass).length,
|
|
1074
|
+
total: parts.length,
|
|
1075
|
+
mean: parts.length ? round(parts.reduce((sum, p) => sum + p.score, 0) / parts.length, 4) : null
|
|
1076
|
+
},
|
|
1077
|
+
person: {
|
|
1078
|
+
gates: { framing: gate("framing"), text: gate("text"), sync: gate("sync") },
|
|
1079
|
+
failed: {
|
|
1080
|
+
framing: people.filter((p) => p.gates.framing === false).map((p) => p.id),
|
|
1081
|
+
text: people.filter((p) => p.gates.text === false).map((p) => p.id),
|
|
1082
|
+
sync: people.filter((p) => p.gates.sync === false).map((p) => p.id)
|
|
1083
|
+
},
|
|
1084
|
+
energy: ratios.length ? round([...ratios].sort((a, b) => a - b)[ratios.length >> 1], 3) : null,
|
|
1085
|
+
shots_at_cuts: {
|
|
1086
|
+
at_cuts: placed.filter((c2) => c2.at_cut).length,
|
|
1087
|
+
total: placed.length,
|
|
1088
|
+
off: placed.flatMap((c2) => c2.at_cut ? [] : [{ clip: c2.path, start: c2.offset }]),
|
|
1089
|
+
cuts_without_shot: placed.length ? cuts.filter(
|
|
1090
|
+
(k) => people.some((p) => k > p.window[0] && k < p.window[1]) && !placed.some((c2) => Math.abs(c2.offset - k) <= AT_CUT_S)
|
|
1091
|
+
) : []
|
|
1092
|
+
},
|
|
1093
|
+
clips
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
function wholeFrameCuts(ledger, width, height) {
|
|
1098
|
+
const isRecord2 = (v) => typeof v === "object" && v !== null;
|
|
1099
|
+
const numbers = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "number") : [];
|
|
1100
|
+
const cuts = ledger.split("\n").flatMap((line) => {
|
|
1101
|
+
let entry;
|
|
1102
|
+
try {
|
|
1103
|
+
entry = JSON.parse(line);
|
|
1104
|
+
} catch {
|
|
1105
|
+
return [];
|
|
1106
|
+
}
|
|
1107
|
+
if (!isRecord2(entry) || !isRecord2(entry.provenance) || entry.provenance.provider !== "original")
|
|
1108
|
+
return [];
|
|
1109
|
+
const p = entry.provenance;
|
|
1110
|
+
const [window, roi] = [numbers(p.window), numbers(p.roi)];
|
|
1111
|
+
const area = roi.length === 4 ? roi[2] * roi[3] : width * height;
|
|
1112
|
+
if (area < WHOLE_FRAME_SHARE * width * height) return [];
|
|
1113
|
+
if (entry.type === "video" && window.length === 2)
|
|
1114
|
+
return [{ window: [window[0], window[1]] }];
|
|
1115
|
+
return entry.type === "image" && typeof p.at === "number" ? [{ at: p.at }] : [];
|
|
1116
|
+
});
|
|
1117
|
+
return {
|
|
1118
|
+
windows: cuts.flatMap((c2) => "window" in c2 ? [c2.window] : []),
|
|
1119
|
+
stills: [...new Set(cuts.flatMap((c2) => "at" in c2 ? [c2.at] : []))].sort((a, b) => a - b)
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
function stillsShown(ref, yours, stills, fps) {
|
|
1123
|
+
if (!stills.length) return [];
|
|
1124
|
+
const h = Math.max(GRID, Math.round(STILL_W * ref.height / ref.width / GRID) * GRID);
|
|
1125
|
+
const read = (clip, extra = [], limit) => decode(
|
|
1126
|
+
clip.input,
|
|
1127
|
+
[...clip.filters, ...extra, `scale=${STILL_W}:${h}`],
|
|
1128
|
+
STILL_W,
|
|
1129
|
+
h,
|
|
1130
|
+
true,
|
|
1131
|
+
limit
|
|
1132
|
+
).frames;
|
|
1133
|
+
const mine = read(yours);
|
|
1134
|
+
return stills.map((at) => {
|
|
1135
|
+
const still = read(ref, [`select=eq(n\\,${frameAt(at, fps)})`], 1)[0];
|
|
1136
|
+
if (!still) return mine.map(() => false);
|
|
1137
|
+
return mine.map((px) => {
|
|
1138
|
+
const cells = cellDiffs(px, still, STILL_W, h).sort((a, b) => a - b);
|
|
1139
|
+
return pct(cells, 0.5) <= STILL_DIFF;
|
|
1140
|
+
});
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
function cellDiffs(a, b, w, h) {
|
|
1144
|
+
const [cw, ch] = [Math.floor(w / GRID), Math.floor(h / GRID)];
|
|
1145
|
+
return ALL_CELLS.map((c2) => {
|
|
1146
|
+
const [x0, y0] = [c2 % GRID * cw, Math.floor(c2 / GRID) * ch];
|
|
1147
|
+
let sum = 0;
|
|
1148
|
+
for (let y = y0; y < y0 + ch; y++)
|
|
1149
|
+
for (let x = x0; x < x0 + cw; x++) sum += Math.abs(a[y * w + x] - b[y * w + x]);
|
|
1150
|
+
return sum / (cw * ch);
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
function findLedger(yours, segmentsFile) {
|
|
1154
|
+
const dirs = [
|
|
1155
|
+
...existsSync2(yours) && statSync(yours).isDirectory() ? [yours] : [],
|
|
1156
|
+
...segmentsFile ? [dirname(segmentsFile)] : []
|
|
1157
|
+
];
|
|
1158
|
+
return dirs.flatMap((d) => [join3(d, ".media", "manifest.jsonl"), join3(d, "media-manifest.jsonl")]).find((f) => existsSync2(f));
|
|
1159
|
+
}
|
|
1160
|
+
function frameSpans(on, ks, fps) {
|
|
1161
|
+
const spans = [];
|
|
1162
|
+
on.forEach((v, i) => {
|
|
1163
|
+
if (!v) return;
|
|
1164
|
+
const last = spans.at(-1);
|
|
1165
|
+
if (last && on[i - 1] && ks[i] === ks[i - 1] + 1) last[1] = round((ks[i] + 1) / fps, 3);
|
|
1166
|
+
else spans.push([round(ks[i] / fps, 3), round((ks[i] + 1) / fps, 3)]);
|
|
1167
|
+
});
|
|
1168
|
+
return spans;
|
|
1169
|
+
}
|
|
1170
|
+
function wholeFrameReuse(cuts, stills, series, ks, fps, segments) {
|
|
1171
|
+
const inside = (k, a, b) => k >= frameAt(a, fps) && k < frameAt(b, fps);
|
|
1172
|
+
const played = series.frame.map(
|
|
1173
|
+
(_, i) => cuts.windows.some(([a, b]) => inside(ks[i], a, b)) && pct(
|
|
1174
|
+
[...series.cells[i]].sort((x, y) => x - y),
|
|
1175
|
+
0.5
|
|
1176
|
+
) >= REUSE_SSIM
|
|
1177
|
+
);
|
|
1178
|
+
const long = longRuns(played, ks, Math.ceil(REUSE_MIN_S * fps));
|
|
1179
|
+
const shown = long.map((v, i) => v || stills.some((on) => on[i]));
|
|
1180
|
+
const drawn = shown.map(
|
|
1181
|
+
(v, i) => v && !!segments?.some((s) => s.copy && inside(ks[i], s.start, s.end))
|
|
1182
|
+
);
|
|
1183
|
+
return {
|
|
1184
|
+
spans: frameSpans(shown, ks, fps),
|
|
1185
|
+
stills: cuts.stills.filter((_, j) => stills[j]?.some(Boolean)),
|
|
1186
|
+
share: round(shown.filter(Boolean).length / Math.max(1, shown.length), 4),
|
|
1187
|
+
drawn: frameSpans(drawn, ks, fps),
|
|
1188
|
+
pass: drawn.filter(Boolean).length <= REUSE_MAX_FRAMES
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
function longRuns(on, ks, min) {
|
|
1192
|
+
const out = [...on];
|
|
1193
|
+
for (let i = 0; i < on.length; ) {
|
|
1194
|
+
if (!on[i]) {
|
|
1195
|
+
i++;
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
let j = i + 1;
|
|
1199
|
+
while (j < on.length && on[j] && ks[j] === ks[j - 1] + 1) j++;
|
|
1200
|
+
if (j - i < min) out.fill(false, i, j);
|
|
1201
|
+
i = j;
|
|
1202
|
+
}
|
|
1203
|
+
return out;
|
|
1204
|
+
}
|
|
1205
|
+
function regionWarnings(segments, ref) {
|
|
1206
|
+
return segments.flatMap((s) => {
|
|
1207
|
+
const box = s.regenerated && regionRoi(s.regenerated, ref.width, ref.height);
|
|
1208
|
+
if (s.drawn || !(box || s.pixels === "regenerated")) return [];
|
|
1209
|
+
if (box && box[2] * box[3] >= WHOLE_FRAME_SHARE * ref.width * ref.height)
|
|
1210
|
+
return [
|
|
1211
|
+
`${s.id}: its Regenerated box covers the whole frame, so nothing in it is judged by pixels: box the person, and give each drawn element over them a Drawn: x, y, w, h line`
|
|
1212
|
+
];
|
|
1213
|
+
return s.copy ? [
|
|
1214
|
+
`${s.id} draws copy over a regenerated person: a drawn element inside the person's box is judged by pixels only with its own Drawn: x, y, w, h line`
|
|
1215
|
+
] : [];
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
async function worstMoments(picks, ctx) {
|
|
1219
|
+
const { ref, series } = ctx;
|
|
1220
|
+
const sw = Math.min(SHEET_W, ref.width);
|
|
1221
|
+
const sh = Math.max(2, Math.round(ref.height * sw / ref.width / 2) * 2);
|
|
1222
|
+
const [cw, ch] = cellSize(ref.width, ref.height);
|
|
1223
|
+
const worst = [];
|
|
1224
|
+
const images = [];
|
|
1225
|
+
const labels = [];
|
|
1226
|
+
for (const [n, i] of picks.entries()) {
|
|
1227
|
+
const cells = series.cells[i];
|
|
1228
|
+
const c2 = cells.indexOf(Math.min(...cells));
|
|
1229
|
+
const roi = [c2 % GRID * cw, Math.floor(c2 / GRID) * ch, cw, ch];
|
|
1230
|
+
const scaled = roi.map(
|
|
1231
|
+
(v, j) => Math.round(v * (j % 2 ? sh : sw) / (j % 2 ? ref.height : ref.width))
|
|
1232
|
+
);
|
|
1233
|
+
const t = round(ctx.ks[i] / ref.fps, 3);
|
|
1234
|
+
const tag = `worst-${String(n + 1).padStart(2, "0")}`;
|
|
1235
|
+
const [fa, fb] = [
|
|
1236
|
+
frameOf(ctx.refClip, i, ref.width, ref.height),
|
|
1237
|
+
frameOf(ctx.yours, i, ref.width, ref.height)
|
|
1238
|
+
];
|
|
1239
|
+
const pair = new Uint8Array((2 * cw + 4) * ch * 3).fill(255);
|
|
1240
|
+
for (let y = 0; y < ch; y++)
|
|
1241
|
+
[fa, fb].forEach(
|
|
1242
|
+
(f, side) => pair.set(
|
|
1243
|
+
f.subarray(
|
|
1244
|
+
((roi[1] + y) * ref.width + roi[0]) * 3,
|
|
1245
|
+
((roi[1] + y) * ref.width + roi[0] + cw) * 3
|
|
1246
|
+
),
|
|
1247
|
+
(y * (2 * cw + 4) + side * (cw + 4)) * 3
|
|
1248
|
+
)
|
|
1249
|
+
);
|
|
1250
|
+
const cellPicture = writeImage(join3(ctx.outDir, `${tag}-cell.png`), pair, 2 * cw + 4, ch);
|
|
1251
|
+
const [a, b] = [frameOf(ctx.refClip, i, sw, sh), frameOf(ctx.yours, i, sw, sh)];
|
|
1252
|
+
outline(a, sw, scaled);
|
|
1253
|
+
outline(b, sw, scaled);
|
|
1254
|
+
images.push(writeImage(join3(ctx.outDir, `${tag}-original.png`), a, sw, sh));
|
|
1255
|
+
images.push(writeImage(join3(ctx.outDir, `${tag}-yours.png`), b, sw, sh));
|
|
1256
|
+
labels.push(
|
|
1257
|
+
`original ${t}s`,
|
|
1258
|
+
`yours ${t}s \xB7 ssim ${round(series.frame[i], 3)} \xB7 cell ${round(cells[c2], 2)}`
|
|
1259
|
+
);
|
|
1260
|
+
worst.push({
|
|
1261
|
+
t,
|
|
1262
|
+
frame: ctx.ks[i],
|
|
1263
|
+
ssim: round(series.frame[i], 4),
|
|
1264
|
+
cell: { roi, ssim: round(cells[c2], 3), picture: cellPicture }
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
if (!images.length) return { worst };
|
|
1268
|
+
const { createContactSheet } = await import("./contactSheet-WG4HT5XP.js");
|
|
1269
|
+
const sheet = await createContactSheet(images, join3(ctx.outDir, "worst.jpg"), {
|
|
1270
|
+
cols: 2,
|
|
1271
|
+
maxImages: images.length,
|
|
1272
|
+
cellWidth: 640,
|
|
1273
|
+
labelMode: "custom",
|
|
1274
|
+
labels
|
|
1275
|
+
});
|
|
1276
|
+
return { worst, ...sheet ? { sheet } : {} };
|
|
1277
|
+
}
|
|
1278
|
+
function onsetCurve(path) {
|
|
1279
|
+
const raw = runFfmpeg([
|
|
1280
|
+
...["-i", path, "-vn", "-af", "aresample=async=1:first_pts=0"],
|
|
1281
|
+
...["-t", "20", "-ac", "1", "-ar", "8000", "-f", "f32le", "-"]
|
|
1282
|
+
]);
|
|
1283
|
+
const samples = new Float32Array(raw.buffer, raw.byteOffset, Math.floor(raw.byteLength / 4));
|
|
1284
|
+
const rms = [];
|
|
1285
|
+
for (let i = 0; i + 80 <= samples.length; i += 80) {
|
|
1286
|
+
let s = 0;
|
|
1287
|
+
for (let j = i; j < i + 80; j++) s += samples[j] ** 2;
|
|
1288
|
+
rms.push(Math.sqrt(s / 80));
|
|
1289
|
+
}
|
|
1290
|
+
return rms.map((v, i) => Math.max(0, v - (rms[i - 1] ?? v)));
|
|
1291
|
+
}
|
|
1292
|
+
function soundOffset(reference, yours, ref, mine) {
|
|
1293
|
+
if (!ref.audio || !mine.audio)
|
|
1294
|
+
return { original: ref.audio, yours: mine.audio, pass: ref.audio === mine.audio };
|
|
1295
|
+
const [a, b] = [onsetCurve(reference), onsetCurve(yours)];
|
|
1296
|
+
let best = [-2, 0];
|
|
1297
|
+
for (let lag = -50; lag <= 50; lag++) {
|
|
1298
|
+
const n = Math.min(a.length, b.length) - Math.abs(lag);
|
|
1299
|
+
if (n < 50) continue;
|
|
1300
|
+
const [i, j] = [Math.max(0, -lag), Math.max(0, lag)];
|
|
1301
|
+
const r = pearson(a.slice(i, i + n), b.slice(j, j + n)) ?? -2;
|
|
1302
|
+
if (r > best[0]) best = [r, lag];
|
|
1303
|
+
}
|
|
1304
|
+
const offset = best[1] * 10;
|
|
1305
|
+
if (best[0] <= 0.3)
|
|
1306
|
+
return {
|
|
1307
|
+
offset_ms: null,
|
|
1308
|
+
match: round(best[0], 2),
|
|
1309
|
+
pass: true,
|
|
1310
|
+
note: "too few distinct sounds to align"
|
|
1311
|
+
};
|
|
1312
|
+
return { offset_ms: offset, match: round(best[0], 2), pass: Math.abs(offset) <= 1e3 / ref.fps };
|
|
1313
|
+
}
|
|
1314
|
+
function sideBySide(reference, yours, ref, out) {
|
|
1315
|
+
runFfmpeg([
|
|
1316
|
+
...["-y", "-i", reference, "-i", yours, "-filter_complex"],
|
|
1317
|
+
`[0:v]setsar=1[a];[1:v]scale=${ref.width}:${ref.height},setsar=1[b];[a][b]hstack=inputs=2,pad=ceil(iw/2)*2:ceil(ih/2)*2[v]`,
|
|
1318
|
+
...["-map", "[v]", "-map", "0:a?", "-c:v", "libx264", "-crf", "20", "-pix_fmt", "yuv420p"],
|
|
1319
|
+
...["-c:a", "aac", "-shortest", out]
|
|
1320
|
+
]);
|
|
1321
|
+
return out;
|
|
1322
|
+
}
|
|
1323
|
+
function choosePick(opts, ref) {
|
|
1324
|
+
if (opts.at)
|
|
1325
|
+
return {
|
|
1326
|
+
kind: "at",
|
|
1327
|
+
ks: [...new Set(opts.at.map((t) => frameAt(t, ref.fps)))].sort((x, y) => x - y)
|
|
1328
|
+
};
|
|
1329
|
+
if (opts.range)
|
|
1330
|
+
return {
|
|
1331
|
+
kind: "range",
|
|
1332
|
+
k0: frameAt(opts.range[0], ref.fps),
|
|
1333
|
+
k1: Math.min(ref.frames, Math.ceil(opts.range[1] * ref.fps - 1e-6))
|
|
1334
|
+
};
|
|
1335
|
+
return { kind: "all" };
|
|
1336
|
+
}
|
|
1337
|
+
async function diffVideos(options) {
|
|
1338
|
+
const opts = { ...options, reference: resolve(options.reference), yours: resolve(options.yours) };
|
|
1339
|
+
const ref = probeVideo(opts.reference);
|
|
1340
|
+
const warnings = [];
|
|
1341
|
+
if (ref.vfr)
|
|
1342
|
+
warnings.push(
|
|
1343
|
+
"the original's frame rate varies, so frame times drift: npx hyperframes measure probe makes a constant-rate copy"
|
|
1344
|
+
);
|
|
1345
|
+
const mode = existsSync2(opts.yours) && statSync(opts.yours).isDirectory() ? "project" : "video";
|
|
1346
|
+
if (mode === "project" && !existsSync2(join3(opts.yours, "index.html")))
|
|
1347
|
+
throw new Fix(`${opts.yours} has no index.html`, "pass a project folder or a rendered video");
|
|
1348
|
+
if (mode === "project" && !opts.at && !opts.range && opts.segments?.length)
|
|
1349
|
+
opts.range = [
|
|
1350
|
+
Math.min(...opts.segments.map((s) => s.start)),
|
|
1351
|
+
Math.max(...opts.segments.map((s) => s.end))
|
|
1352
|
+
];
|
|
1353
|
+
if (mode === "project" && !opts.at && !opts.range)
|
|
1354
|
+
throw new Fix(
|
|
1355
|
+
"a project folder is compared at chosen times, not whole",
|
|
1356
|
+
"pass --at t1,t2 or --range start,end, or render it and diff the render"
|
|
1357
|
+
);
|
|
1358
|
+
const pick = choosePick(opts, ref);
|
|
1359
|
+
const ks = pickedFrames(pick, ref.frames);
|
|
1360
|
+
if (!ks.length || ks.some((k) => k >= ref.frames))
|
|
1361
|
+
throw new Fix(
|
|
1362
|
+
`the original has ${ref.frames} frames (${round(ref.duration, 2)} s)`,
|
|
1363
|
+
"pick times inside it"
|
|
1364
|
+
);
|
|
1365
|
+
const select = selectFilter(pick, ref.fpsText);
|
|
1366
|
+
const refClip = { ...videoClip(opts.reference, 0, void 0, ref), filters: select };
|
|
1367
|
+
let yours;
|
|
1368
|
+
let seqDir;
|
|
1369
|
+
let yoursInfo;
|
|
1370
|
+
if (mode === "project") {
|
|
1371
|
+
const captured = await captureProject(
|
|
1372
|
+
opts.yours,
|
|
1373
|
+
ks.map((k) => k / ref.fps),
|
|
1374
|
+
opts,
|
|
1375
|
+
ref
|
|
1376
|
+
);
|
|
1377
|
+
[yours, seqDir] = [captured.clip, captured.dir];
|
|
1378
|
+
} else {
|
|
1379
|
+
yoursInfo = probeVideo(opts.yours);
|
|
1380
|
+
yours = {
|
|
1381
|
+
...videoClip(opts.yours, 0, void 0, yoursInfo),
|
|
1382
|
+
filters: [`fps=${ref.fpsText}`, ...select]
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
try {
|
|
1386
|
+
mkdirSync(opts.outDir, { recursive: true });
|
|
1387
|
+
for (const f of readdirSync(opts.outDir))
|
|
1388
|
+
if (/^worst-/.test(f)) rmSync3(join3(opts.outDir, f), { force: true });
|
|
1389
|
+
const logPath = join3(opts.outDir, "ssim.log");
|
|
1390
|
+
const series = ssimSeries(refClip, yours, logPath);
|
|
1391
|
+
if (!series.frame.length)
|
|
1392
|
+
throw new Fix("ffmpeg compared no frames", "check both videos play and overlap in time");
|
|
1393
|
+
if (series.frame.length < ks.length)
|
|
1394
|
+
warnings.push(`yours ends early: ${series.frame.length} of ${ks.length} frames compared`);
|
|
1395
|
+
const worstCell = series.cells.map((cells) => Math.min(...cells));
|
|
1396
|
+
writeFileSync(
|
|
1397
|
+
join3(opts.outDir, "frames.tsv"),
|
|
1398
|
+
[
|
|
1399
|
+
"t frame ssim worst_cell cell",
|
|
1400
|
+
...series.frame.map((v, i) => {
|
|
1401
|
+
const c2 = series.cells[i].indexOf(worstCell[i]);
|
|
1402
|
+
return [
|
|
1403
|
+
round(ks[i] / ref.fps, 3),
|
|
1404
|
+
ks[i],
|
|
1405
|
+
round(v, 4),
|
|
1406
|
+
round(worstCell[i], 4),
|
|
1407
|
+
`r${Math.floor(c2 / GRID)}c${c2 % GRID}`
|
|
1408
|
+
].join(" ");
|
|
1409
|
+
})
|
|
1410
|
+
].join("\n") + "\n"
|
|
1411
|
+
);
|
|
1412
|
+
const t = {
|
|
1413
|
+
mean: opts.thresholds?.mean ?? DEFAULT_MIN_MEAN,
|
|
1414
|
+
p05: opts.thresholds?.p05 ?? DEFAULT_MIN_P05,
|
|
1415
|
+
cell: opts.thresholds?.cell ?? DEFAULT_MIN_CELL
|
|
1416
|
+
};
|
|
1417
|
+
const overall = scores(series.frame, worstCell);
|
|
1418
|
+
const missing = missingContent(refClip, yours, ks, ref.fps, (k) => {
|
|
1419
|
+
const s = opts.segments?.find(
|
|
1420
|
+
(seg) => k >= frameAt(seg.start, ref.fps) && k < frameAt(seg.end, ref.fps)
|
|
1421
|
+
);
|
|
1422
|
+
if (s?.pixels === "regenerated") return [];
|
|
1423
|
+
return s?.regenerated ? cellsOutside(regionRoi(s.regenerated, ref.width, ref.height), ref.width, ref.height) : ALL_CELLS;
|
|
1424
|
+
});
|
|
1425
|
+
if (!missing.pass)
|
|
1426
|
+
warnings.push(
|
|
1427
|
+
`${Math.round(missing.share * 100)}% of frames leave empty what the original fills (${missing.spans.map(([a, b]) => `${a}\u2013${b} s`).join(", ")}): build what is missing there`
|
|
1428
|
+
);
|
|
1429
|
+
if (missing.texture.share > MISSING_MAX_SHARE)
|
|
1430
|
+
warnings.push(
|
|
1431
|
+
`${Math.round(missing.texture.share * 100)}% of frames lack fine texture or small detail the original has (${missing.texture.spans.map(([a, b]) => `${a}\u2013${b} s`).join(", ")}): reported, not failed`
|
|
1432
|
+
);
|
|
1433
|
+
const picks = worstIndexes(worstCell, ks, ref.fps, opts.worst ?? 4);
|
|
1434
|
+
const { worst, sheet } = await worstMoments(picks, {
|
|
1435
|
+
refClip,
|
|
1436
|
+
yours,
|
|
1437
|
+
series,
|
|
1438
|
+
ks,
|
|
1439
|
+
ref,
|
|
1440
|
+
outDir: opts.outDir
|
|
1441
|
+
});
|
|
1442
|
+
const cuts = pick.kind === "at" ? void 0 : cutReport(refClip, yours, ks[0], ref.fps);
|
|
1443
|
+
const duration = yoursInfo && pick.kind === "all" ? {
|
|
1444
|
+
reference: round(ref.pictureDuration, 3),
|
|
1445
|
+
yours: round(yoursInfo.pictureDuration, 3),
|
|
1446
|
+
pass: Math.abs(ref.pictureDuration - yoursInfo.pictureDuration) <= 1.5 / ref.fps
|
|
1447
|
+
} : void 0;
|
|
1448
|
+
const ledgerText = opts.ledger && existsSync2(opts.ledger) ? readFileSync3(opts.ledger, "utf8") : void 0;
|
|
1449
|
+
const people = /* @__PURE__ */ new Map();
|
|
1450
|
+
let clips = [];
|
|
1451
|
+
if (opts.segments && yoursInfo) {
|
|
1452
|
+
const project = opts.project ?? (opts.ledger && basename(dirname(opts.ledger)) === ".media" ? dirname(dirname(opts.ledger)) : void 0);
|
|
1453
|
+
const refCuts = cuts?.reference ?? [];
|
|
1454
|
+
const uses = project ? await clipUses(project).catch(() => /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
|
|
1455
|
+
clips = ledgerText ? placeClips(generatedClips(ledgerText), project, ref, refCuts, uses) : [];
|
|
1456
|
+
if (clips.length && clips.every((c2) => !c2.info))
|
|
1457
|
+
warnings.push(
|
|
1458
|
+
"the ledger's generated clips are not found, so text carried in them is not checked: pass --project <folder>"
|
|
1459
|
+
);
|
|
1460
|
+
for (const s of opts.segments)
|
|
1461
|
+
if (s.regenerated || s.pixels === "regenerated")
|
|
1462
|
+
people.set(
|
|
1463
|
+
s,
|
|
1464
|
+
await personVerdict({
|
|
1465
|
+
ref,
|
|
1466
|
+
yours: yoursInfo,
|
|
1467
|
+
window: [s.start, s.end],
|
|
1468
|
+
cuts: refCuts,
|
|
1469
|
+
clips,
|
|
1470
|
+
drawn: drawnOf(s, ref)
|
|
1471
|
+
})
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
const segments = opts.segments ? segmentVerdicts(opts.segments, series, worstCell, ks, {
|
|
1475
|
+
reference: opts.reference,
|
|
1476
|
+
yours: opts.yours,
|
|
1477
|
+
ref,
|
|
1478
|
+
mode,
|
|
1479
|
+
t,
|
|
1480
|
+
drawn: scoreDrawn(opts.segments, refClip, yours, ks, ref, series.frame.length),
|
|
1481
|
+
person: people
|
|
1482
|
+
}) : void 0;
|
|
1483
|
+
if (opts.segments) warnings.push(...regionWarnings(opts.segments, ref));
|
|
1484
|
+
const elements = opts.drawn?.length ? scoreElements(
|
|
1485
|
+
opts.drawn.map((d, n) => ({
|
|
1486
|
+
id: `D${n + 1}`,
|
|
1487
|
+
box: regionRoi(d.box, ref.width, ref.height),
|
|
1488
|
+
window: d.window ?? [0, round(ref.pictureDuration, 3)]
|
|
1489
|
+
})),
|
|
1490
|
+
refClip,
|
|
1491
|
+
yours,
|
|
1492
|
+
ks,
|
|
1493
|
+
ref,
|
|
1494
|
+
series.frame.length
|
|
1495
|
+
) : void 0;
|
|
1496
|
+
const ledger = ledgerText ? wholeFrameCuts(ledgerText, ref.width, ref.height) : void 0;
|
|
1497
|
+
const reuse = ledger && (ledger.windows.length || ledger.stills.length) ? wholeFrameReuse(
|
|
1498
|
+
ledger,
|
|
1499
|
+
stillsShown({ ...refClip, filters: [] }, yours, ledger.stills, ref.fps),
|
|
1500
|
+
series,
|
|
1501
|
+
ks,
|
|
1502
|
+
ref.fps,
|
|
1503
|
+
opts.segments
|
|
1504
|
+
) : void 0;
|
|
1505
|
+
if (reuse && !reuse.pass) {
|
|
1506
|
+
const seconds = reuse.drawn.reduce((sum, [a, b]) => sum + b - a, 0);
|
|
1507
|
+
warnings.push(
|
|
1508
|
+
`${round(seconds, 2)} s play the original's whole frame with its drawn things in it (${reuse.drawn.map(([a, b]) => `${a}\u2013${b} s`).join(", ")}): a copy, not a reverse. Cut only the camera image, each piece on its own box, and rebuild what is drawn`
|
|
1509
|
+
);
|
|
1510
|
+
for (const v of segments ?? [])
|
|
1511
|
+
if (reuse.drawn.some(([a, b]) => a < v.window[1] && b > v.window[0])) {
|
|
1512
|
+
v.pass = false;
|
|
1513
|
+
v.note = "plays the original's whole frame with its drawn things: a copy";
|
|
1514
|
+
}
|
|
1515
|
+
} else if (reuse?.spans.length && !opts.segments)
|
|
1516
|
+
warnings.push(
|
|
1517
|
+
`${Math.round(reuse.share * 100)}% of frames play the original's whole frame: pass --segments <file> to tell footage from copied drawings`
|
|
1518
|
+
);
|
|
1519
|
+
const sound = yoursInfo && pick.kind === "all" ? soundOffset(opts.reference, opts.yours, ref, yoursInfo) : void 0;
|
|
1520
|
+
const sbs = opts.sbs && mode === "video" ? sideBySide(opts.reference, opts.yours, ref, join3(opts.outDir, "sbs.mp4")) : void 0;
|
|
1521
|
+
const judged = segments ? segments.every((s) => s.pass !== false) : passes(overall, t);
|
|
1522
|
+
const top = segments ? headline(
|
|
1523
|
+
segments,
|
|
1524
|
+
clips.map(({ info: _info, file: _file, still: _still, ...c2 }) => c2),
|
|
1525
|
+
t,
|
|
1526
|
+
cuts?.reference
|
|
1527
|
+
) : void 0;
|
|
1528
|
+
const complete = series.frame.length === ks.length;
|
|
1529
|
+
return {
|
|
1530
|
+
pass: judged && complete && missing.pass && (reuse?.pass ?? true) && (cuts?.pass ?? true) && (duration?.pass ?? true) && (sound?.pass ?? true),
|
|
1531
|
+
reference: opts.reference,
|
|
1532
|
+
yours: opts.yours,
|
|
1533
|
+
mode,
|
|
1534
|
+
window: [round(ks[0] / ref.fps, 3), round((ks.at(-1) + 1) / ref.fps, 3)],
|
|
1535
|
+
thresholds: t,
|
|
1536
|
+
ssim: overall,
|
|
1537
|
+
missing_content: missing,
|
|
1538
|
+
...reuse ? { whole_frame_reuse: reuse } : {},
|
|
1539
|
+
worst,
|
|
1540
|
+
...cuts ? { cuts } : {},
|
|
1541
|
+
...duration ? { duration } : {},
|
|
1542
|
+
...sound ? { sound } : {},
|
|
1543
|
+
...top ? top : {},
|
|
1544
|
+
...segments ? { segments } : {},
|
|
1545
|
+
...elements ? { drawn: elements } : {},
|
|
1546
|
+
...sheet ? { sheet } : {},
|
|
1547
|
+
...sbs ? { sbs } : {},
|
|
1548
|
+
log: logPath,
|
|
1549
|
+
frames: join3(opts.outDir, "frames.tsv"),
|
|
1550
|
+
warnings
|
|
1551
|
+
};
|
|
1552
|
+
} finally {
|
|
1553
|
+
if (seqDir) rmSync3(seqDir, { recursive: true, force: true });
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// src/measure/segments.ts
|
|
1558
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
|
|
1559
|
+
var HEADING = /^##\s+(S\d+)\s*[·|-]\s*(\d+(?:\.\d+)?)\s*[–—-]\s*(\d+(?:\.\d+)?)\s*s\b\s*(?:[·|-]\s*(.*))?$/gm;
|
|
1560
|
+
var SOURCES = ["rebuilt", "reused", "regenerated"];
|
|
1561
|
+
var PIXELS = /^Pixels:\s*(rebuilt|reused|regenerated)\b/im;
|
|
1562
|
+
var NUMBER = String.raw`(\d+(?:\.\d+)?)`;
|
|
1563
|
+
var SEP = String.raw`(?:\s*,\s*|\s+)`;
|
|
1564
|
+
var DRAWN = new RegExp(
|
|
1565
|
+
`^Drawn:\\s*${NUMBER}${SEP}${NUMBER}${SEP}${NUMBER}${SEP}${NUMBER}(?:.*?${NUMBER}\\s*[\u2013\u2014-]\\s*${NUMBER}\\s*s\\b)?`,
|
|
1566
|
+
"gim"
|
|
1567
|
+
);
|
|
1568
|
+
var COPY = /^Copy:.*["“”]\S/im;
|
|
1569
|
+
var REGION = /^Regenerated:\s*(\d+(?:\.\d+)?)(?:\s*,\s*|\s+)(\d+(?:\.\d+)?)(?:\s*,\s*|\s+)(\d+(?:\.\d+)?)(?:\s*,\s*|\s+)(\d+(?:\.\d+)?)/im;
|
|
1570
|
+
function parseSegments(markdown) {
|
|
1571
|
+
const heads = [...markdown.matchAll(HEADING)];
|
|
1572
|
+
return heads.map((m, i) => {
|
|
1573
|
+
const body = markdown.slice(m.index + m[0].length, heads[i + 1]?.index ?? markdown.length);
|
|
1574
|
+
const found = PIXELS.exec(body)?.[1]?.toLowerCase();
|
|
1575
|
+
const pixels = SOURCES.find((source) => source === found) ?? "rebuilt";
|
|
1576
|
+
const r = REGION.exec(body);
|
|
1577
|
+
const region = r ? [Number(r[1]), Number(r[2]), Number(r[3]), Number(r[4])] : void 0;
|
|
1578
|
+
const drawn = [...body.matchAll(DRAWN)].flatMap((d) => {
|
|
1579
|
+
const box = [
|
|
1580
|
+
Number(d[1]),
|
|
1581
|
+
Number(d[2]),
|
|
1582
|
+
Number(d[3]),
|
|
1583
|
+
Number(d[4])
|
|
1584
|
+
];
|
|
1585
|
+
if (box[2] <= 0 || box[3] <= 0) return [];
|
|
1586
|
+
return [d[5] ? { box, window: [Number(d[5]), Number(d[6])] } : { box }];
|
|
1587
|
+
});
|
|
1588
|
+
return {
|
|
1589
|
+
id: m[1],
|
|
1590
|
+
start: Number(m[2]),
|
|
1591
|
+
end: Number(m[3]),
|
|
1592
|
+
title: (m[4] ?? "").trim(),
|
|
1593
|
+
pixels,
|
|
1594
|
+
...region && pixels !== "regenerated" && region[2] > 0 && region[3] > 0 ? { regenerated: region } : {},
|
|
1595
|
+
...drawn.length ? { drawn } : {},
|
|
1596
|
+
...COPY.test(body) ? { copy: true } : {}
|
|
1597
|
+
};
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
function readSegments(path) {
|
|
1601
|
+
if (!existsSync3(path))
|
|
1602
|
+
throw new Fix(`no segments file at ${path}`, "pass a file of `## S01 \xB7 a\u2013b s` segments");
|
|
1603
|
+
const segments = parseSegments(readFileSync4(path, "utf8"));
|
|
1604
|
+
if (!segments.length)
|
|
1605
|
+
throw new Fix(
|
|
1606
|
+
`${path} has no "## S01 \xB7 0.00\u20132.40 s \xB7 title" segment headings`,
|
|
1607
|
+
"write one `## S01 \xB7 a\u2013b s \xB7 title` heading per segment"
|
|
1608
|
+
);
|
|
1609
|
+
return segments;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
// src/commands/diff.ts
|
|
1613
|
+
var examples = [
|
|
1614
|
+
[
|
|
1615
|
+
"Score a render against the original, frame by frame",
|
|
1616
|
+
"hyperframes diff original.mp4 renders/final.mp4"
|
|
1617
|
+
],
|
|
1618
|
+
[
|
|
1619
|
+
"Score one segment of a project without rendering it",
|
|
1620
|
+
"hyperframes diff original.mp4 . --range 2.1,4.5"
|
|
1621
|
+
],
|
|
1622
|
+
[
|
|
1623
|
+
"Score chosen moments of a project without rendering it",
|
|
1624
|
+
"hyperframes diff original.mp4 . --at 0.5,2.4,3.1"
|
|
1625
|
+
],
|
|
1626
|
+
[
|
|
1627
|
+
"Score one drawn element (a title's box) by itself at chosen moments of a project",
|
|
1628
|
+
"hyperframes diff original.mp4 . --at 1,1.5,2 --drawn 120,670,485,115"
|
|
1629
|
+
],
|
|
1630
|
+
[
|
|
1631
|
+
"Judge each segment of the final render and write a side-by-side",
|
|
1632
|
+
"hyperframes diff original.mp4 renders/final.mp4 --segments segments.md --sbs"
|
|
1633
|
+
]
|
|
1634
|
+
];
|
|
1635
|
+
function number(value, flag) {
|
|
1636
|
+
if (value === void 0) return void 0;
|
|
1637
|
+
const [n] = parseNumbers(value, flag);
|
|
1638
|
+
return n;
|
|
1639
|
+
}
|
|
1640
|
+
function parseDrawn(text) {
|
|
1641
|
+
try {
|
|
1642
|
+
return parseMask(text);
|
|
1643
|
+
} catch {
|
|
1644
|
+
throw new Fix(`--drawn ${text} is not x,y,w,h[,a-b]`, "--drawn 120,670,485,115,0-2.77");
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
function personLine(p) {
|
|
1648
|
+
const off = [
|
|
1649
|
+
...(p.framing ?? []).filter((f) => !f.pass).map(
|
|
1650
|
+
(f) => `framing off ${f.window[0]}\u2013${f.window[1]} s (shift ${f.shift}, size \xD7${f.scale})`
|
|
1651
|
+
),
|
|
1652
|
+
...(p.text ?? []).filter((t) => t.carried).map((t) => `${t.clip} carries ${t.drawn}'s text`),
|
|
1653
|
+
...(p.sync ?? []).filter((x) => x.pass === false).map((x) => `lips ${x.lag_ms} ms off at ${x.window[0]} s`)
|
|
1654
|
+
];
|
|
1655
|
+
const moved = p.energy ? `, motion \xD7${p.energy.mean_ratio} (reported)` : "";
|
|
1656
|
+
return `person ${p.pass === null ? "\u2014" : p.pass ? "\u2713" : "\u2717"}${off.length ? ` ${off.join("; ")}` : ""}${moved}`;
|
|
1657
|
+
}
|
|
1658
|
+
function printHuman(r) {
|
|
1659
|
+
const mark = r.pass ? c.success("\u2713 pass") : c.error("\u2717 fail");
|
|
1660
|
+
console.log(
|
|
1661
|
+
`${mark} SSIM mean ${r.ssim.mean}, p05 ${r.ssim.p05}, worst cell p05 ${r.ssim.cell_p05} over ${r.ssim.frames} frames (${r.window[0]}\u2013${r.window[1]} s)`
|
|
1662
|
+
);
|
|
1663
|
+
if (!r.missing_content.pass)
|
|
1664
|
+
console.log(
|
|
1665
|
+
` missing content in ${Math.round(r.missing_content.share * 100)}% of frames: ${r.missing_content.spans.map(([a, b]) => `${a}\u2013${b} s`).join(", ")}`
|
|
1666
|
+
);
|
|
1667
|
+
if (r.missing_content.texture.share > 0)
|
|
1668
|
+
console.log(
|
|
1669
|
+
` missing texture (reported, not failed) in ${Math.round(r.missing_content.texture.share * 100)}% of frames: ${r.missing_content.texture.spans.map(([a, b]) => `${a}\u2013${b} s`).join(", ")}`
|
|
1670
|
+
);
|
|
1671
|
+
for (const m of r.worst)
|
|
1672
|
+
console.log(` worst ${m.t}s ssim ${m.ssim} cell ${m.cell.roi.join(",")} at ${m.cell.ssim}`);
|
|
1673
|
+
if (r.whole_frame_reuse?.spans.length)
|
|
1674
|
+
console.log(
|
|
1675
|
+
` whole frame of the original in ${Math.round(r.whole_frame_reuse.share * 100)}% of frames${r.whole_frame_reuse.pass ? "" : `, with its drawn things at ${r.whole_frame_reuse.drawn.map(([a, b]) => `${a}\u2013${b} s`).join(", ")} (a copy)`}`
|
|
1676
|
+
);
|
|
1677
|
+
if (r.cuts)
|
|
1678
|
+
console.log(
|
|
1679
|
+
` cuts: ${r.cuts.reference.length} in the original${r.cuts.pass ? ", all matched" : `; missing ${r.cuts.missing.join(", ") || "none"}, extra ${r.cuts.extra.join(", ") || "none"}`}`
|
|
1680
|
+
);
|
|
1681
|
+
if (r.duration)
|
|
1682
|
+
console.log(
|
|
1683
|
+
` duration: original ${r.duration.reference} s, yours ${r.duration.yours} s${r.duration.pass ? "" : " (differ)"}`
|
|
1684
|
+
);
|
|
1685
|
+
if (r.sound)
|
|
1686
|
+
console.log(
|
|
1687
|
+
` sound: ${"offset_ms" in r.sound ? r.sound.offset_ms === null ? r.sound.note ?? "not aligned" : `${r.sound.offset_ms} ms off` : `original ${r.sound.original ? "has" : "has no"} sound, yours ${r.sound.yours ? "has" : "has no"}`}${r.sound.pass ? "" : " (fails)"}`
|
|
1688
|
+
);
|
|
1689
|
+
if (r.components)
|
|
1690
|
+
console.log(
|
|
1691
|
+
` components: ${r.components.passed} of ${r.components.total} pass${r.components.mean === null ? "" : `, mean ${r.components.mean}`}`
|
|
1692
|
+
);
|
|
1693
|
+
if (r.person) {
|
|
1694
|
+
const g = r.person.gates;
|
|
1695
|
+
const mark2 = (v, failed) => v === null ? "unmeasured" : v ? "ok" : `fails in ${failed.join(", ")}`;
|
|
1696
|
+
console.log(
|
|
1697
|
+
` person: framing ${mark2(g.framing, r.person.failed.framing)}, text in the clip ${mark2(g.text, r.person.failed.text)}, lips ${mark2(g.sync, r.person.failed.sync)}; reported: motion \xD7${r.person.energy ?? "?"}, ${r.person.shots_at_cuts.at_cuts} of ${r.person.shots_at_cuts.total} clips start at a cut${r.person.shots_at_cuts.cuts_without_shot.length ? `, no new clip at ${r.person.shots_at_cuts.cuts_without_shot.join(", ")} s` : ""}`
|
|
1698
|
+
);
|
|
1699
|
+
}
|
|
1700
|
+
console.log(` every frame: ${r.frames}`);
|
|
1701
|
+
for (const s of r.segments ?? []) {
|
|
1702
|
+
const state = s.pass === null ? c.dim("\u2014") : s.pass ? c.success("\u2713") : c.error("\u2717");
|
|
1703
|
+
const detail = [
|
|
1704
|
+
s.ssim && `ssim ${s.ssim.mean} / p05 ${s.ssim.p05} / cell ${s.ssim.cell_p05}`,
|
|
1705
|
+
s.energy && `motion \xD7${s.energy.mean_ratio}, luma \xD7${s.look?.luma_ratio}`,
|
|
1706
|
+
s.person && personLine(s.person)
|
|
1707
|
+
].filter(Boolean).join("; ") || (s.note ?? "");
|
|
1708
|
+
const region = s.regenerated ? `; person in ${s.regenerated.roi.join(",")}` : "";
|
|
1709
|
+
console.log(
|
|
1710
|
+
` ${state} ${s.id} ${s.window[0]}\u2013${s.window[1]} s ${s.pixels}${s.regenerated ? " outside the region" : ""}: ${detail}${region}`
|
|
1711
|
+
);
|
|
1712
|
+
}
|
|
1713
|
+
for (const d of r.drawn ?? []) {
|
|
1714
|
+
const state = d.pass === null ? c.dim("\u2014") : d.pass ? c.success("\u2713") : c.error("\u2717");
|
|
1715
|
+
const detail = d.pass === null ? "no ink found in the box (crop it tight around the letters)" : `score ${d.score} / p05 ${d.p05}, off by ${d.offset.join(",")} px${d.ink === void 0 ? "" : `, ink \xD7${d.ink}`}`;
|
|
1716
|
+
console.log(
|
|
1717
|
+
` ${state} ${d.id} ${d.box.join(",")} ${d.window[0]}\u2013${d.window[1]} s: ${detail}`
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
for (const w of r.warnings) console.log(` ${c.warn("\u26A0")} ${w}`);
|
|
1721
|
+
if (r.sheet) console.log(` sheet ${r.sheet}`);
|
|
1722
|
+
if (r.sbs) console.log(` side by side ${r.sbs}`);
|
|
1723
|
+
}
|
|
1724
|
+
var diff_default = defineCommand({
|
|
1725
|
+
meta: {
|
|
1726
|
+
name: "diff",
|
|
1727
|
+
description: "Score a render or a project against the original video frame by frame: SSIM, worst moments, cuts, segments"
|
|
1728
|
+
},
|
|
1729
|
+
args: {
|
|
1730
|
+
reference: { type: "positional", description: "The original video", required: true },
|
|
1731
|
+
yours: {
|
|
1732
|
+
type: "positional",
|
|
1733
|
+
description: "A rendered video, or a project folder (captured at the original's frame times, no render)",
|
|
1734
|
+
required: true
|
|
1735
|
+
},
|
|
1736
|
+
at: { type: "string", description: "Compare only these seconds, e.g. 0.5,2.4" },
|
|
1737
|
+
range: { type: "string", description: "Compare every frame of start,end seconds" },
|
|
1738
|
+
segments: {
|
|
1739
|
+
type: "string",
|
|
1740
|
+
description: "A file of `## S01 \xB7 a\u2013b s` segments: a verdict per segment (Pixels: regenerated compares motion and look)"
|
|
1741
|
+
},
|
|
1742
|
+
ledger: {
|
|
1743
|
+
type: "string",
|
|
1744
|
+
description: "The project's media ledger, to find whole-frame cuts of the original (default: .media/manifest.jsonl beside the project or REVERSE.md)"
|
|
1745
|
+
},
|
|
1746
|
+
project: {
|
|
1747
|
+
type: "string",
|
|
1748
|
+
description: "The project folder, to find the ledger's generated clips and check them for the original's text (default: the folder holding .media)"
|
|
1749
|
+
},
|
|
1750
|
+
"min-mean": { type: "string", description: `Mean SSIM to pass (default ${DEFAULT_MIN_MEAN})` },
|
|
1751
|
+
"min-p05": {
|
|
1752
|
+
type: "string",
|
|
1753
|
+
description: `5th-percentile SSIM to pass (default ${DEFAULT_MIN_P05})`
|
|
1754
|
+
},
|
|
1755
|
+
"min-cell": {
|
|
1756
|
+
type: "string",
|
|
1757
|
+
description: `5th percentile of each frame's worst 4x4 cell to pass (default ${DEFAULT_MIN_CELL})`
|
|
1758
|
+
},
|
|
1759
|
+
worst: { type: "string", description: "Worst moments to show (default 4)" },
|
|
1760
|
+
sbs: {
|
|
1761
|
+
type: "boolean",
|
|
1762
|
+
description: "Also write an original | yours side-by-side video",
|
|
1763
|
+
default: false
|
|
1764
|
+
},
|
|
1765
|
+
out: {
|
|
1766
|
+
type: "string",
|
|
1767
|
+
description: "Folder for the sheet and log (default .hyperframes/diff/<yours>)"
|
|
1768
|
+
},
|
|
1769
|
+
timeout: {
|
|
1770
|
+
type: "string",
|
|
1771
|
+
description: "Render-ready timeout in ms for a project folder (default 5000)"
|
|
1772
|
+
},
|
|
1773
|
+
drawn: {
|
|
1774
|
+
type: "string",
|
|
1775
|
+
description: "A drawn element's box x,y,w,h in the original's pixels, optionally its seconds a-b (repeatable): scored by itself whatever is behind it, with its offset and ink (yours over the original's: under 1 is lighter, thinner or smaller)"
|
|
1776
|
+
},
|
|
1777
|
+
json: { type: "boolean", description: "Print one JSON result", default: false }
|
|
1778
|
+
},
|
|
1779
|
+
// fallow-ignore-next-line complexity
|
|
1780
|
+
async run({ args, rawArgs }) {
|
|
1781
|
+
const json = args.json === true;
|
|
1782
|
+
try {
|
|
1783
|
+
if (args.at !== void 0 && args.range !== void 0)
|
|
1784
|
+
throw new Fix("--at and --range both given", "pass one of them");
|
|
1785
|
+
const yours = resolve2(String(args.yours));
|
|
1786
|
+
const stem = basename2(yours, extname(yours)) || "project";
|
|
1787
|
+
const segmentsFile = args.segments === void 0 ? void 0 : resolve2(String(args.segments));
|
|
1788
|
+
const result = await diffVideos({
|
|
1789
|
+
reference: resolve2(String(args.reference)),
|
|
1790
|
+
yours,
|
|
1791
|
+
at: args.at === void 0 ? void 0 : parseNumbers(args.at, "--at"),
|
|
1792
|
+
range: args.range === void 0 ? void 0 : parseRange(args.range),
|
|
1793
|
+
segments: segmentsFile === void 0 ? void 0 : readSegments(segmentsFile),
|
|
1794
|
+
ledger: args.ledger === void 0 ? findLedger(yours, segmentsFile) : resolve2(String(args.ledger)),
|
|
1795
|
+
project: args.project === void 0 ? void 0 : resolve2(String(args.project)),
|
|
1796
|
+
drawn: repeated(rawArgs, "--drawn").map(parseDrawn),
|
|
1797
|
+
thresholds: {
|
|
1798
|
+
mean: number(args["min-mean"], "--min-mean"),
|
|
1799
|
+
p05: number(args["min-p05"], "--min-p05"),
|
|
1800
|
+
cell: number(args["min-cell"], "--min-cell")
|
|
1801
|
+
},
|
|
1802
|
+
worst: number(args.worst, "--worst"),
|
|
1803
|
+
sbs: args.sbs === true,
|
|
1804
|
+
outDir: outDir(args.out, join4("diff", stem)),
|
|
1805
|
+
timeoutMs: number(args.timeout, "--timeout"),
|
|
1806
|
+
log: (message) => console.error(message)
|
|
1807
|
+
});
|
|
1808
|
+
if (json) console.log(formatJson(withMeta({ ok: true, ...result })));
|
|
1809
|
+
else printHuman(result);
|
|
1810
|
+
if (!result.pass) setCommandExitCode(1);
|
|
1811
|
+
} catch (err) {
|
|
1812
|
+
const fix = err instanceof Fix ? err.fix : void 0;
|
|
1813
|
+
const message = normalizeErrorMessage(err);
|
|
1814
|
+
if (json)
|
|
1815
|
+
console.log(formatJson(withMeta({ ok: false, error: message, ...fix ? { fix } : {} })));
|
|
1816
|
+
else console.error(`${c.error("\u2717")} ${message}${fix ? `
|
|
1817
|
+
Fix: ${fix}` : ""}`);
|
|
1818
|
+
failCommand();
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
export {
|
|
1823
|
+
diff_default as default,
|
|
1824
|
+
examples
|
|
1825
|
+
};
|