conformtools 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/package.json +1 -1
  2. package/dist/arriraw-3GKCR6K2.js +0 -525
  3. package/dist/browser/timeline_core_bg.wasm +0 -0
  4. package/dist/chunk-42QQI3WX.js +0 -3
  5. package/dist/chunk-6FVGUJ6L.js +0 -3
  6. package/dist/chunk-6TM32YIJ.js +0 -7
  7. package/dist/chunk-7D7H6VFW.js +0 -3
  8. package/dist/chunk-AACY2V3L.js +0 -3
  9. package/dist/chunk-BUEIRRNY.js +0 -3
  10. package/dist/chunk-BW2NQ54J.js +0 -3
  11. package/dist/chunk-C2ESM27Z.js +0 -3
  12. package/dist/chunk-CL26XMDO.js +0 -3
  13. package/dist/chunk-DKGGJM6Z.js +0 -3
  14. package/dist/chunk-DRHOPOC7.js +0 -3
  15. package/dist/chunk-EO5NIBOV.js +0 -3
  16. package/dist/chunk-EPZ6NWE4.js +0 -3
  17. package/dist/chunk-GXEVALBL.js +0 -3
  18. package/dist/chunk-HKP4P6JN.js +0 -3
  19. package/dist/chunk-JB7PR2TQ.js +0 -3
  20. package/dist/chunk-P7OVDUA5.js +0 -3
  21. package/dist/chunk-PSANHDZM.js +0 -3
  22. package/dist/chunk-QDWB7QU7.js +0 -3
  23. package/dist/chunk-QTKRMXL5.js +0 -363
  24. package/dist/chunk-QTPCU2TF.js +0 -3
  25. package/dist/chunk-SP5RGDAM.js +0 -3
  26. package/dist/chunk-TEZP6VEQ.js +0 -3
  27. package/dist/chunk-TK55FA56.js +0 -3
  28. package/dist/chunk-UCMNH6Q6.js +0 -3
  29. package/dist/chunk-WHY3DVXS.js +0 -3
  30. package/dist/chunk-WT6NIJCB.js +0 -3
  31. package/dist/chunk-Y2BEEOPB.js +0 -3
  32. package/dist/claude-setup-BM3AAUKR.js +0 -5
  33. package/dist/cli.js +0 -17
  34. package/dist/clip-state-B6JOX3JE.js +0 -3
  35. package/dist/conformtools-decode +0 -0
  36. package/dist/cr3-wasm-WKWMEK3V.js +0 -3
  37. package/dist/dng-wasm-Z5OVO4UI.js +0 -3
  38. package/dist/dpx-wasm-QNYXAOAJ.js +0 -3
  39. package/dist/esm-SFFBP7PS.js +0 -3
  40. package/dist/exr-wasm-BHSBJLQH.js +0 -3
  41. package/dist/h264-LIZVHN2W.js +0 -3
  42. package/dist/h264-mxf-MWS7DDV7.js +0 -3
  43. package/dist/http.js +0 -4
  44. package/dist/i2o-transfer +0 -0
  45. package/dist/inspect-DZF537QL.js +0 -46
  46. package/dist/isobmff-HM3UPWPZ.js +0 -3
  47. package/dist/mcp.js +0 -14
  48. package/dist/media_core-R5PPN3AY.js +0 -9
  49. package/dist/media_core_bg-FGAR5KA5.js +0 -3
  50. package/dist/media_core_bg-YK63OUDM.js +0 -3
  51. package/dist/mxf-K465SWBN.js +0 -3
  52. package/dist/onnxruntime-web-stub-PKJ2NZBF.js +0 -3
  53. package/dist/ops-73NR3X6R.js +0 -3
  54. package/dist/premiere-uxp/icons/panel.png +0 -0
  55. package/dist/premiere-uxp/icons/panel@2x.png +0 -0
  56. package/dist/premiere-uxp/icons/plugin.png +0 -0
  57. package/dist/premiere-uxp/icons/plugin@2x.png +0 -0
  58. package/dist/premiere-uxp/index.html +0 -38
  59. package/dist/premiere-uxp/index.js +0 -93
  60. package/dist/premiere-uxp/lib/clipmeta.js +0 -170
  61. package/dist/premiere-uxp/lib/ctx.js +0 -62
  62. package/dist/premiere-uxp/lib/handles.js +0 -57
  63. package/dist/premiere-uxp/lib/markers.js +0 -198
  64. package/dist/premiere-uxp/lib/pairing.js +0 -58
  65. package/dist/premiere-uxp/lib/premiere.js +0 -82
  66. package/dist/premiere-uxp/lib/probe.js +0 -139
  67. package/dist/premiere-uxp/lib/protocol.js +0 -165
  68. package/dist/premiere-uxp/lib/render.js +0 -38
  69. package/dist/premiere-uxp/lib/session.js +0 -85
  70. package/dist/premiere-uxp/lib/sizing.js +0 -312
  71. package/dist/premiere-uxp/lib/time.js +0 -82
  72. package/dist/premiere-uxp/lib/timeline.js +0 -336
  73. package/dist/premiere-uxp/lib/verbs.js +0 -20
  74. package/dist/premiere-uxp/lib/write.js +0 -97
  75. package/dist/premiere-uxp/manifest.json +0 -102
  76. package/dist/prores-L4JZZWGH.js +0 -526
  77. package/dist/r3d-RR3FUM6H.js +0 -3
  78. package/dist/r3d-VUOYU2KQ.js +0 -1025
  79. package/dist/resolve-bridge.py +0 -1037
  80. package/dist/resolve-presets/conform.tools.xml +0 -127
  81. package/dist/source-BDJAUQVR.js +0 -3
  82. package/dist/sscd-embed-DHFTEIOC.js +0 -3
  83. package/dist/sscd-sweep-OYS4XAID.js +0 -3
  84. package/dist/statusline-GMMCFMOA.js +0 -4
  85. package/dist/statusline.js +0 -3
  86. package/dist/still-4G25EYN5.js +0 -3
  87. package/dist/tiff-wasm-QJPCR7JT.js +0 -3
  88. package/dist/timeline_core-VK2ZWPCO.js +0 -3
  89. package/dist/timeline_core_bg-2TYWZ35G.js +0 -3
  90. package/dist/udf_bg-A4WEMSAX.js +0 -3
  91. package/dist/wasm/media_core_bg.wasm +0 -0
  92. package/dist/wasm/udf_bg.wasm +0 -0
  93. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  94. package/dist/wav-63QF6SCT.js +0 -3
@@ -1,38 +0,0 @@
1
- // `render`: Adobe Media Encoder through EncoderManager. The app has no
2
- // `render` interface yet (reserved); these verbs exist so the Marker Batch
3
- // Renderer can move when it is wanted, and for the live proof.
4
- "use strict";
5
-
6
- const { g, projectOf, PeerError, P } = require("./ctx");
7
-
8
- const progress = { jobs: {} };
9
-
10
- async function manager() {
11
- const ppro = P.api();
12
- if (!ppro.EncoderManager) throw new PeerError("api_missing", "EncoderManager is not in this Premiere");
13
- const m = await P.callAny(ppro.EncoderManager, ["getManager"]);
14
- if (m && !manager._wired && P.has(m, "addEventListener")) {
15
- manager._wired = true;
16
- for (const ev of ["onEncodeProgress", "onEncodeComplete", "onEncodeError"]) {
17
- try { m.addEventListener(ev, (e) => { progress.jobs[String((e && e.jobId) || "last")] = { event: ev, data: e && e.progress !== undefined ? e.progress : (e && e.status) }; }); } catch (_) { /* older DOM */ }
18
- }
19
- }
20
- return m;
21
- }
22
-
23
- const verbs = {
24
- "render.ame_installed": async () => { try { return !!(await P.callAny(await manager(), ["isAMEInstalled"])); } catch (_) { return false; } },
25
- // {timeline, output_path, preset_path, queue: bool}
26
- "render.export_sequence": async ({ timeline, output_path, preset_path, queue }) => {
27
- const ppro = P.api();
28
- const seq = g(timeline, "seq");
29
- const m = await manager();
30
- const types = ppro.Constants && ppro.Constants.ExportType ? ppro.Constants.ExportType : {};
31
- const type = queue ? (types.QUEUE_TO_AME !== undefined ? types.QUEUE_TO_AME : 1) : (types.IMMEDIATELY !== undefined ? types.IMMEDIATELY : 0);
32
- const job = await P.callAny(m, ["exportSequence"], seq, type, String(output_path), String(preset_path || ""));
33
- return { ok: job !== false, job: job && typeof job === "object" ? String(job.jobId || job.id || "") : String(job || "") };
34
- },
35
- "render.progress": async () => progress.jobs,
36
- };
37
-
38
- module.exports = { verbs };
@@ -1,85 +0,0 @@
1
- // `session`: the open project and its sequences.
2
- "use strict";
3
-
4
- const { handles, h, g, transact, activeProject, projectOf, PeerError, P } = require("./ctx");
5
-
6
- async function sequencesOf(project) {
7
- const seqs = await P.callAny(project, ["getSequences"]);
8
- return Array.isArray(seqs) ? seqs : [];
9
- }
10
-
11
- function nameOf(obj) {
12
- if (!obj) return "";
13
- if (typeof obj.name === "string") return obj.name;
14
- if (typeof obj.getName === "function") return obj.getName();
15
- return "";
16
- }
17
-
18
- const verbs = {
19
- "session.current_project": async () => {
20
- const p = await activeProject();
21
- return p ? h("project", p) : null;
22
- },
23
- "session.current_timeline": async ({ project }) => {
24
- const p = await projectOf(project);
25
- if (!p) return null;
26
- const seq = await P.callAny(p, ["getActiveSequence"]);
27
- return seq ? h("seq", seq) : null;
28
- },
29
- "session.timeline_count": async ({ project }) => {
30
- const p = await projectOf(project);
31
- return p ? (await sequencesOf(p)).length : 0;
32
- },
33
- "session.timeline_by_index": async ({ project, index }) => {
34
- const p = await projectOf(project);
35
- if (!p) return null;
36
- const seqs = await sequencesOf(p);
37
- const seq = seqs[Number(index) - 1];
38
- return seq ? h("seq", seq) : null;
39
- },
40
- "session.set_current_timeline": async ({ project, timeline }) => {
41
- const p = await projectOf(project);
42
- const seq = g(timeline, "seq");
43
- const ok = await P.callAny(p, ["setActiveSequence"], seq);
44
- return ok !== false;
45
- },
46
- "session.name": async ({ handle }) => {
47
- const obj = g(handle);
48
- const n = nameOf(obj);
49
- if (n) return n;
50
- // A track item names itself after its project item.
51
- if (P.has(obj, "getProjectItem")) {
52
- const pi = await obj.getProjectItem();
53
- return nameOf(pi);
54
- }
55
- return "";
56
- },
57
- "session.set_name": async ({ handle, name }) => {
58
- const obj = g(handle);
59
- const kind = handles.kindOf(handle);
60
- const project = await activeProject();
61
- if (!project) throw new PeerError("no_project", "No project open");
62
- if (kind === "project") throw new PeerError("refused", "a project is renamed on disk, not here");
63
- const n = await transact(project, `Rename to "${name}"`, async (add) => {
64
- add(await P.callAny(obj, ["createSetNameAction"], String(name)));
65
- });
66
- return n > 0;
67
- },
68
- "session.unique_id": async ({ handle }) => {
69
- const obj = g(handle);
70
- if (typeof obj.guid === "string") return obj.guid;
71
- if (typeof obj.guid === "object" && obj.guid && typeof obj.guid.toString === "function") return String(obj.guid);
72
- if (P.has(obj, "getGuid")) return String(await obj.getGuid());
73
- if (typeof obj.nodeId === "string") return obj.nodeId;
74
- return handle["$h"];
75
- },
76
- "session.describe": async () => {
77
- const p = await activeProject();
78
- if (!p) return { project: "", timelines: [], current: "" };
79
- const seqs = await sequencesOf(p);
80
- const cur = await P.callAny(p, ["getActiveSequence"]);
81
- return { project: nameOf(p), timelines: seqs.map(nameOf), current: cur ? nameOf(cur) : "" };
82
- },
83
- };
84
-
85
- module.exports = { verbs, sequencesOf, nameOf };
@@ -1,312 +0,0 @@
1
- // `sizing`: a clip's Motion + Opacity, read and written through the component
2
- // chain. Parameter ORDER and UNITS are undocumented; the table below is the
3
- // ExtendScript order Adobe never changed, verified live on 26.2 (see
4
- // docs/INTERNAL_HOST_BRIDGE.md, Premiere section) - `findParam` matches by
5
- // display name first and falls back to the index, so a reordering cannot
6
- // silently write the wrong control.
7
- //
8
- // Units, Premiere's own:
9
- // Position PointF, FRACTION of the sequence frame, (0.5, 0.5) = centred,
10
- // y grows DOWN
11
- // Scale percent (100 = 1:1); Scale Width applies when Uniform Scale is off
12
- // Rotation degrees, clockwise positive
13
- // Anchor PointF, fraction of the CLIP frame, (0.5, 0.5) = centre
14
- // Opacity percent
15
- // The neutral pose (Resolve's names) is pixels of the sequence frame, tilt
16
- // UP-positive, zoom a factor, rotation counter-clockwise positive - exactly
17
- // `editlist.ir_sizing`, so a Premiere side compares with a file side.
18
- "use strict";
19
-
20
- const { h, g, transact, activeProject, PeerError, P } = require("./ctx");
21
- const S = { _sizingSetForm: null };
22
- const T = require("./time");
23
-
24
- const MOTION = { matchNames: ["AE.ADBE Motion", "ADBE Motion"], display: ["Motion"] };
25
- const OPACITY = { matchNames: ["AE.ADBE Opacity", "ADBE Opacity"], display: ["Opacity"] };
26
- const MOTION_PARAMS = { position: ["Position", 0], scale: ["Scale", 1], scale_width: ["Scale Width", 2], uniform: ["Uniform Scale", 3], rotation: ["Rotation", 4], anchor: ["Anchor Point", 5] };
27
- const OPACITY_PARAMS = { opacity: ["Opacity", 0], blend: ["Blend Mode", 1] };
28
- const TIME_REMAP = ["AE.ADBE Time Remapping", "ADBE Time Remapping"];
29
-
30
- async function chainOf(item) {
31
- return P.callAny(item, ["getComponentChain"]);
32
- }
33
-
34
- async function componentsOf(chain) {
35
- const n = await P.callAny(chain, ["getComponentCount"]);
36
- const out = [];
37
- for (let i = 0; i < Number(n || 0); i += 1) out.push(await P.callAny(chain, ["getComponentAtIndex"], i));
38
- return out;
39
- }
40
-
41
- async function matchName(c) {
42
- try { return String(await P.callAny(c, ["getMatchName"])); } catch (_) { return ""; }
43
- }
44
- async function displayName(c) {
45
- try { return String(await P.callAny(c, ["getDisplayName"])); } catch (_) { return c.displayName || ""; }
46
- }
47
-
48
- async function findComponent(chain, spec) {
49
- for (const c of await componentsOf(chain)) {
50
- const mn = await matchName(c);
51
- if (spec.matchNames.includes(mn)) return c;
52
- const dn = await displayName(c);
53
- if (spec.display.includes(dn)) return c;
54
- }
55
- return null;
56
- }
57
-
58
- async function paramsOf(component) {
59
- const n = await P.callAny(component, ["getParamCount"]);
60
- const out = [];
61
- for (let i = 0; i < Number(n || 0); i += 1) out.push(await P.callAny(component, ["getParam"], i));
62
- return out;
63
- }
64
-
65
- async function findParam(component, [display, index]) {
66
- const params = await paramsOf(component);
67
- for (const p of params) {
68
- const dn = p.displayName || (P.has(p, "getDisplayName") ? await p.getDisplayName() : "");
69
- if (String(dn) === display) return p;
70
- }
71
- return params[index] || null;
72
- }
73
-
74
- async function paramValue(param, time) {
75
- if (!param) return null;
76
- if (P.has(param, "getValueAtTime") && time !== undefined) return param.getValueAtTime(time);
77
- if (P.has(param, "getStartValue")) return param.getStartValue();
78
- if (P.has(param, "getValue")) return param.getValue();
79
- return param.value !== undefined ? param.value : null;
80
- }
81
-
82
- async function isVarying(param) {
83
- try { return !!(await P.callAny(param, ["isTimeVarying"])); } catch (_) { return false; }
84
- }
85
-
86
- function pt(v) {
87
- // MEASURED 26.2: a param's start value is a Keyframe whose `.value` is the
88
- // PointF; the PointF itself has `x` / `y`.
89
- if (v && typeof v === "object" && v.value && typeof v.value === "object") v = v.value;
90
- if (v && typeof v === "object") return { x: Number(v.x !== undefined ? v.x : v[0]) || 0, y: Number(v.y !== undefined ? v.y : v[1]) || 0 };
91
- return { x: 0, y: 0 };
92
- }
93
- function num(v, d) { const n = Number(v && typeof v === "object" && "value" in v ? v.value : v); return Number.isFinite(n) ? n : d; }
94
-
95
- /** Premiere's raw Motion / Opacity values at the clip's first frame. */
96
- async function readRaw(item) {
97
- const chain = await chainOf(item);
98
- const out = { position: { x: 0.5, y: 0.5 }, scale: 100, scale_width: 100, uniform: true, rotation: 0, anchor: { x: 0.5, y: 0.5 }, opacity: 100, keyframed: false, variable_speed: false, has_motion: false };
99
- const motion = await findComponent(chain, MOTION);
100
- if (motion) {
101
- out.has_motion = true;
102
- const at = P.has(item, "getStartTime") ? await item.getStartTime() : undefined;
103
- for (const [key, spec] of Object.entries(MOTION_PARAMS)) {
104
- const p = await findParam(motion, spec);
105
- if (!p) continue;
106
- const v = await paramValue(p, at);
107
- if (key === "position" || key === "anchor") out[key] = pt(v);
108
- else if (key === "uniform") out.uniform = !!(v && typeof v === "object" && "value" in v ? v.value : v);
109
- else out[key] = num(v, out[key]);
110
- if (await isVarying(p)) out.keyframed = true;
111
- }
112
- }
113
- const opacity = await findComponent(chain, OPACITY);
114
- if (opacity) {
115
- const p = await findParam(opacity, OPACITY_PARAMS.opacity);
116
- if (p) { out.opacity = num(await paramValue(p), 100); if (await isVarying(p)) out.keyframed = true; }
117
- }
118
- for (const c of await componentsOf(chain)) {
119
- if (TIME_REMAP.includes(await matchName(c))) { out.variable_speed = true; break; }
120
- }
121
- return out;
122
- }
123
-
124
- /** Neutral sizing for the model (editlist.ir_sizing's keys and units). */
125
- function toNeutral(raw, raster) {
126
- const w = raster && raster[0] ? raster[0] : 1920;
127
- const hgt = raster && raster[1] ? raster[1] : 1080;
128
- const out = {};
129
- const px = raw.position.x - 0.5;
130
- const py = raw.position.y - 0.5;
131
- if (Math.abs(px) > 1e-9) out.Pan = Math.round(px * w * 1000) / 1000;
132
- if (Math.abs(py) > 1e-9) out.Tilt = Math.round(-py * hgt * 1000) / 1000;
133
- const sx = raw.uniform ? raw.scale : raw.scale_width;
134
- const sy = raw.scale;
135
- if (Math.abs(sx - 100) > 1e-6) out.ZoomX = Math.round(sx / 100 * 1e5) / 1e5;
136
- if (Math.abs(sy - 100) > 1e-6) out.ZoomY = Math.round(sy / 100 * 1e5) / 1e5;
137
- if (Math.abs(raw.rotation) > 1e-9) out.RotationAngle = Math.round(-raw.rotation * 1e4) / 1e4;
138
- const ax = raw.anchor.x - 0.5;
139
- const ay = raw.anchor.y - 0.5;
140
- if (Math.abs(ax) > 1e-9) out.AnchorPointX = Math.round(ax * w * 1000) / 1000;
141
- if (Math.abs(ay) > 1e-9) out.AnchorPointY = Math.round(-ay * hgt * 1000) / 1000;
142
- if (Math.abs(raw.opacity - 100) > 1e-6) out.Opacity = Math.round(raw.opacity * 1000) / 1000;
143
- if (raw.keyframed) out.keyframed = 1.0;
144
- return out;
145
- }
146
-
147
- async function readSizingForModel(item, raster) {
148
- try {
149
- const raw = await readRaw(item);
150
- return { sizing: toNeutral(raw, raster), keyframed: raw.keyframed, variable_speed: raw.variable_speed };
151
- } catch (_) {
152
- return { sizing: {}, keyframed: false, variable_speed: false };
153
- }
154
- }
155
-
156
- /** The neutral POSE (what `align_cv.read_pose_full` returns for Resolve):
157
- * Pan/Tilt in sequence pixels, ZoomX/ZoomY factors, RotationAngle,
158
- * AnchorPointX/Y, FlipX/FlipY (Premiere has none on Motion), Opacity. */
159
- async function readPose(item, raster) {
160
- const raw = await readRaw(item);
161
- const n = toNeutral(raw, raster);
162
- return {
163
- Pan: n.Pan || 0, Tilt: n.Tilt || 0, ZoomX: n.ZoomX || 1, ZoomY: n.ZoomY || 1, RotationAngle: n.RotationAngle || 0,
164
- AnchorPointX: n.AnchorPointX || 0, AnchorPointY: n.AnchorPointY || 0, FlipX: 0, FlipY: 0, Opacity: raw.opacity,
165
- keyframed: raw.keyframed, raw,
166
- };
167
- }
168
-
169
- /** Write a pose (neutral units) as Premiere values, as ONE undo step. Only the
170
- * keys present are written; a keyframed parameter is left alone and named. */
171
- async function writePose(item, pose, raster, label) {
172
- const project = await activeProject();
173
- if (!project) throw new PeerError("no_project", "No project open");
174
- const w = raster && raster[0] ? raster[0] : 1920;
175
- const hgt = raster && raster[1] ? raster[1] : 1080;
176
- const chain = await chainOf(item);
177
- const motion = await findComponent(chain, MOTION);
178
- if (!motion) throw new PeerError("no_motion", "this clip has no Motion effect");
179
- const skipped = [];
180
- const written = [];
181
- const at = P.has(item, "getStartTime") ? await item.getStartTime() : undefined;
182
- const raw = await readRaw(item);
183
- const n = await transact(project, label || "conform.tools sizing", async (add) => {
184
- // MEASURED 26.2: createSetValueAction's exact signature is not documented
185
- // and a wrong shape raises "Illegal Parameter type". Try the forms in
186
- // order and remember the first that builds an action - a keyframe with
187
- // updateUI, a keyframe alone, the raw value with updateUI, the raw value
188
- // alone. `_sizingSetForm` (set once per pass) skips the probing next time.
189
- // MEASURED 26.2 (debug.sizing_probe): createSetValueAction takes a
190
- // KEYFRAME, not a raw value - `createSetValueAction(130)` raises "Illegal
191
- // Parameter type", `createSetValueAction(param.createKeyframe(130))`
192
- // commits. The keyframe is created INSIDE each try so a value shape
193
- // createKeyframe rejects (a PointF, say) falls through instead of
194
- // throwing before the loop. The first shape that builds is cached.
195
- const buildSetValue = async (p, value) => {
196
- const forms = [
197
- ["keyframe,updateUI", async () => p.createSetValueAction(await p.createKeyframe(value), true)],
198
- ["keyframe", async () => p.createSetValueAction(await p.createKeyframe(value))],
199
- ["value,updateUI", async () => p.createSetValueAction(value, true)],
200
- ["value", async () => p.createSetValueAction(value)],
201
- ].filter(([name]) => P.has(p, "createKeyframe") || !name.startsWith("keyframe"));
202
- const only = forms.filter(([name]) => !S._sizingSetForm || name === S._sizingSetForm);
203
- const errors = [];
204
- for (const [name, make] of (only.length ? only : forms)) {
205
- try { const a = await make(); if (a) { S._sizingSetForm = name; return a; } } catch (e) { errors.push(`${name}: ${e.message || e}`); }
206
- }
207
- throw new PeerError("set_value_failed", `createSetValueAction: ${errors.join("; ")}`);
208
- };
209
- const setValueAction = (p, value) => buildSetValue(p, value);
210
- // One param failing does not abort the pose: the ones that write, write,
211
- // and the rest are named. (MEASURED 26.2: scalar Motion params - Scale,
212
- // Rotation, Opacity - write through the keyframe form; the two-axis
213
- // params - Position, Anchor Point - reject every createKeyframe /
214
- // createSetValueAction shape tried, so they are reported unwritten. No
215
- // shipped tool writes sizing over the bridge yet; the Reconformer READS
216
- // it and carries it through the engine's .prproj writer.)
217
- const setNum = async (spec, value, key) => {
218
- const p = await findParam(motion, spec);
219
- if (!p) return;
220
- if (await isVarying(p)) { skipped.push(key); return; }
221
- try { add(await setValueAction(p, value)); written.push(key); }
222
- catch (e) { skipped.push(`${key} (${e.message || e})`); }
223
- };
224
- const setPoint = async (spec, x, y, key) => {
225
- const p = await findParam(motion, spec);
226
- if (!p) return;
227
- if (await isVarying(p)) { skipped.push(key); return; }
228
- const ppro = P.api();
229
- const point = ppro.PointF && P.has(ppro.PointF, "create") ? ppro.PointF.create(x, y) : { x, y };
230
- try { add(await setValueAction(p, point)); written.push(key); }
231
- catch (e) { skipped.push(`${key} (${e.message || e})`); }
232
- };
233
- if (pose.Pan !== undefined || pose.Tilt !== undefined) {
234
- const x = 0.5 + Number(pose.Pan !== undefined ? pose.Pan : (raw.position.x - 0.5) * w) / w;
235
- const y = 0.5 - Number(pose.Tilt !== undefined ? pose.Tilt : -(raw.position.y - 0.5) * hgt) / hgt;
236
- await setPoint(MOTION_PARAMS.position, x, y, "Pan/Tilt");
237
- }
238
- if (pose.ZoomX !== undefined || pose.ZoomY !== undefined) {
239
- const zx = pose.ZoomX !== undefined ? Number(pose.ZoomX) : (raw.uniform ? raw.scale : raw.scale_width) / 100;
240
- const zy = pose.ZoomY !== undefined ? Number(pose.ZoomY) : raw.scale / 100;
241
- if (Math.abs(zx - zy) < 1e-6) {
242
- await setNum(MOTION_PARAMS.uniform, true, "Uniform");
243
- await setNum(MOTION_PARAMS.scale, zy * 100, "Zoom");
244
- } else {
245
- await setNum(MOTION_PARAMS.uniform, false, "Uniform");
246
- await setNum(MOTION_PARAMS.scale, zy * 100, "ZoomY");
247
- await setNum(MOTION_PARAMS.scale_width, zx * 100, "ZoomX");
248
- }
249
- }
250
- if (pose.RotationAngle !== undefined) await setNum(MOTION_PARAMS.rotation, -Number(pose.RotationAngle), "Rotation");
251
- if (pose.AnchorPointX !== undefined || pose.AnchorPointY !== undefined) {
252
- const x = 0.5 + Number(pose.AnchorPointX !== undefined ? pose.AnchorPointX : (raw.anchor.x - 0.5) * w) / w;
253
- const y = 0.5 - Number(pose.AnchorPointY !== undefined ? pose.AnchorPointY : -(raw.anchor.y - 0.5) * hgt) / hgt;
254
- await setPoint(MOTION_PARAMS.anchor, x, y, "Anchor");
255
- }
256
- if (pose.Opacity !== undefined) {
257
- const op = await findComponent(chain, OPACITY);
258
- const p = op && await findParam(op, OPACITY_PARAMS.opacity);
259
- if (p) {
260
- if (await isVarying(p)) skipped.push("Opacity");
261
- else {
262
- try { add(await buildSetValue(p, Number(pose.Opacity))); written.push("Opacity"); }
263
- catch (e) { skipped.push(`Opacity (${e.message || e})`); }
264
- }
265
- }
266
- }
267
- if (pose.FlipX || pose.FlipY) skipped.push("Flip (Premiere's Motion has no flip; use a Transform effect)");
268
- });
269
- return { actions: n, written, skipped };
270
- }
271
-
272
- async function rasterOfItemSeq() {
273
- const project = await activeProject();
274
- const seq = project && await P.callAny(project, ["getActiveSequence"]);
275
- if (!seq) return [1920, 1080];
276
- try { const fs = await P.callAny(seq, ["getFrameSize"]); return [Number(fs.width || 0) || 1920, Number(fs.height || 0) || 1080]; } catch (_) { return [1920, 1080]; }
277
- }
278
-
279
- const verbs = {
280
- "sizing.read_pose": async ({ item }) => readPose(g(item, "item"), await rasterOfItemSeq()),
281
- "sizing.restore_pose": async ({ item, pose }) => {
282
- const r = await writePose(g(item, "item"), pose || {}, await rasterOfItemSeq(), "conform.tools restore sizing");
283
- return r.actions > 0;
284
- },
285
- "sizing.apply_transform": async ({ item, transform, compose }) => {
286
- const it = g(item, "item");
287
- const raster = await rasterOfItemSeq();
288
- const t = transform || {};
289
- let pose = { ...t };
290
- if (compose !== false) {
291
- const cur = await readPose(it, raster);
292
- pose = {};
293
- if (t.Pan !== undefined) pose.Pan = cur.Pan + Number(t.Pan);
294
- if (t.Tilt !== undefined) pose.Tilt = cur.Tilt + Number(t.Tilt);
295
- if (t.ZoomX !== undefined) pose.ZoomX = cur.ZoomX * Number(t.ZoomX);
296
- if (t.ZoomY !== undefined) pose.ZoomY = cur.ZoomY * Number(t.ZoomY);
297
- if (t.RotationAngle !== undefined) pose.RotationAngle = cur.RotationAngle + Number(t.RotationAngle);
298
- for (const k of ["AnchorPointX", "AnchorPointY", "Opacity", "FlipX", "FlipY"]) if (t[k] !== undefined) pose[k] = t[k];
299
- }
300
- const r = await writePose(it, pose, raster, "conform.tools align");
301
- return { applied: r.written, skipped: r.skipped, pose: await readPose(it, raster) };
302
- },
303
- "sizing.units": async ({ timeline_w, timeline_h }) => {
304
- // Pan / tilt in the neutral pose are already sequence pixels: 1 unit = 1 px.
305
- const w = Number(timeline_w) || 1920;
306
- const hgt = Number(timeline_h) || 1080;
307
- return { kx: 1.0, ky: 1.0, basis: "sequence_pixels", raster: [w, hgt], position_fraction_of_frame: true };
308
- },
309
- "sizing.raw": async ({ item }) => readRaw(g(item, "item")),
310
- };
311
-
312
- module.exports = { verbs, readRaw, toNeutral, readPose, writePose, readSizingForModel, MOTION_PARAMS, OPACITY_PARAMS, findComponent, findParam, h };
@@ -1,82 +0,0 @@
1
- // Premiere counts time in TICKS: 254016000000 per second. A sequence's
2
- // timebase is the tick count of one frame. The neutral model counts FRAMES at
3
- // the sequence rate, so every conversion lives here and is tested in node.
4
- "use strict";
5
-
6
- const TICKS_PER_SECOND = 254016000000;
7
-
8
- /** `ticks` may be a number, a numeric string (the API returns strings for
9
- * large tick values) or a TickTime-like object with `ticks`/`ticksNumber`/`seconds`. */
10
- function toTicks(v) {
11
- if (v === null || v === undefined) return 0;
12
- if (typeof v === "number") return v;
13
- if (typeof v === "string") return Number(v);
14
- if (typeof v === "object") {
15
- if (typeof v.ticksNumber === "number") return v.ticksNumber;
16
- if (v.ticks !== undefined) return Number(v.ticks);
17
- if (typeof v.seconds === "number") return Math.round(v.seconds * TICKS_PER_SECOND);
18
- }
19
- return Number(v) || 0;
20
- }
21
-
22
- /** Frames per second from a sequence timebase (ticks per frame). */
23
- function fpsFromTimebase(timebase) {
24
- const tpf = toTicks(timebase);
25
- return tpf > 0 ? TICKS_PER_SECOND / tpf : 0;
26
- }
27
-
28
- function ticksToFrames(ticks, timebase) {
29
- const tpf = toTicks(timebase);
30
- if (tpf <= 0) return 0;
31
- return Math.round(toTicks(ticks) / tpf);
32
- }
33
-
34
- function framesToTicks(frames, timebase) {
35
- return Math.round(Number(frames) * toTicks(timebase));
36
- }
37
-
38
- /** Timebase for common rates when only fps is known (tests, model_from fps). */
39
- function timebaseFromFps(fps) {
40
- return Math.round(TICKS_PER_SECOND / Number(fps));
41
- }
42
-
43
- /** HH:MM:SS:FF (or ; for drop-frame) from a frame count at `fps`. Drop-frame
44
- * applies to 29.97 / 59.94 only when `drop` is true; Premiere's own display
45
- * setting decides that, so callers pass it. */
46
- function framesToTimecode(frames, fps, drop) {
47
- const nominal = Math.round(fps);
48
- let f = Math.max(0, Math.round(frames));
49
- if (drop && (nominal === 30 || nominal === 60)) {
50
- const dropPerMin = nominal === 30 ? 2 : 4;
51
- const framesPer10 = nominal * 60 * 10 - dropPerMin * 9;
52
- const d = Math.floor(f / framesPer10);
53
- let m = f % framesPer10;
54
- if (m < dropPerMin) m = m + dropPerMin;
55
- f = f + dropPerMin * 9 * d + dropPerMin * Math.floor((m - dropPerMin) / (nominal * 60 - dropPerMin));
56
- }
57
- const ff = f % nominal;
58
- const s = Math.floor(f / nominal) % 60;
59
- const m = Math.floor(f / (nominal * 60)) % 60;
60
- const h = Math.floor(f / (nominal * 3600));
61
- const sep = drop ? ";" : ":";
62
- const p = (n) => String(n).padStart(2, "0");
63
- return `${p(h)}:${p(m)}:${p(s)}${sep}${p(ff)}`;
64
- }
65
-
66
- /** The inverse of framesToTimecode; accepts : or ; separators. */
67
- function timecodeToFrames(tc, fps) {
68
- const m = /^(\d+)[:;](\d+)[:;](\d+)[:;](\d+)$/.exec(String(tc).trim());
69
- if (!m) throw new Error(`not a timecode: ${tc}`);
70
- const nominal = Math.round(fps);
71
- const [h, mi, s, f] = m.slice(1).map(Number);
72
- const drop = tc.includes(";");
73
- let frames = ((h * 60 + mi) * 60 + s) * nominal + f;
74
- if (drop && (nominal === 30 || nominal === 60)) {
75
- const dropPerMin = nominal === 30 ? 2 : 4;
76
- const totalMinutes = h * 60 + mi;
77
- frames -= dropPerMin * (totalMinutes - Math.floor(totalMinutes / 10));
78
- }
79
- return frames;
80
- }
81
-
82
- module.exports = { TICKS_PER_SECOND, toTicks, fpsFromTimebase, ticksToFrames, framesToTicks, timebaseFromFps, framesToTimecode, timecodeToFrames };