conformtools 0.5.1 → 0.6.2
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/README.md +69 -6
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/chunk-6TM32YIJ.js +7 -0
- package/dist/chunk-BTXLTVNK.js +3 -0
- package/dist/{chunk-AHNDJFQR.js → chunk-BUEIRRNY.js} +1 -1
- package/dist/chunk-BXFVYGFW.js +3 -0
- package/dist/chunk-CX3USH6A.js +318 -0
- package/dist/chunk-D5DEQ467.js +3 -0
- package/dist/{chunk-YPRTUS5W.js → chunk-FNGHTZ5F.js} +1 -1
- package/dist/chunk-GXEVALBL.js +3 -0
- package/dist/chunk-JH3OLTR6.js +3 -0
- package/dist/chunk-KP4C2MFM.js +3 -0
- package/dist/chunk-PIEH7J6J.js +3 -0
- package/dist/chunk-RUBNBRUK.js +3 -0
- package/dist/chunk-RULUDOB7.js +3 -0
- package/dist/chunk-Y2BEEOPB.js +3 -0
- package/dist/claude-setup-XSNTKEU7.js +5 -0
- package/dist/cli.js +11 -5
- package/dist/conformtools-decode +0 -0
- package/dist/cr3-wasm-YTMVBAFM.js +3 -0
- package/dist/dng-wasm-WUUQB7M2.js +3 -0
- package/dist/dpx-wasm-XBKO4V4W.js +3 -0
- package/dist/exr-wasm-VE2W6MFW.js +3 -0
- package/dist/{h264-JHQCJTWP.js → h264-HD7BY5J5.js} +1 -1
- package/dist/{h264-mxf-4M63NBQK.js → h264-mxf-6OOODSAK.js} +1 -1
- package/dist/http.js +2 -2
- package/dist/{inspect-6OM4FTVW.js → inspect-TDZCNXVW.js} +2 -2
- package/dist/isobmff-57HSD6O2.js +3 -0
- package/dist/mcp.js +10 -9
- package/dist/media_core-R5PPN3AY.js +9 -0
- package/dist/{media_core_bg-XIM7Y4R3.js → media_core_bg-YBW45HJ2.js} +1 -1
- package/dist/mxf-FAXEK4WR.js +3 -0
- package/dist/{ops-7HVBBXUQ.js → ops-UPPAG2TI.js} +1 -1
- package/dist/premiere-uxp/icons/panel.png +0 -0
- package/dist/premiere-uxp/icons/panel@2x.png +0 -0
- package/dist/premiere-uxp/icons/plugin.png +0 -0
- package/dist/premiere-uxp/icons/plugin@2x.png +0 -0
- package/dist/premiere-uxp/index.html +38 -0
- package/dist/premiere-uxp/index.js +93 -0
- package/dist/premiere-uxp/lib/clipmeta.js +170 -0
- package/dist/premiere-uxp/lib/ctx.js +62 -0
- package/dist/premiere-uxp/lib/handles.js +57 -0
- package/dist/premiere-uxp/lib/markers.js +198 -0
- package/dist/premiere-uxp/lib/pairing.js +58 -0
- package/dist/premiere-uxp/lib/premiere.js +82 -0
- package/dist/premiere-uxp/lib/probe.js +139 -0
- package/dist/premiere-uxp/lib/protocol.js +165 -0
- package/dist/premiere-uxp/lib/render.js +38 -0
- package/dist/premiere-uxp/lib/session.js +85 -0
- package/dist/premiere-uxp/lib/sizing.js +312 -0
- package/dist/premiere-uxp/lib/time.js +82 -0
- package/dist/premiere-uxp/lib/timeline.js +336 -0
- package/dist/premiere-uxp/lib/verbs.js +20 -0
- package/dist/premiere-uxp/lib/write.js +97 -0
- package/dist/premiere-uxp/manifest.json +102 -0
- package/dist/{r3d-AT6NNIY3.js → r3d-EY6FEFKM.js} +1 -1
- package/dist/r3d-KJVC7T2C.js +3 -0
- package/dist/resolve-bridge.py +974 -0
- package/dist/resolve-presets/conform.tools.xml +127 -0
- package/dist/sscd-embed-DHFTEIOC.js +3 -0
- package/dist/sscd-sweep-OYS4XAID.js +3 -0
- package/dist/statusline-GMMCFMOA.js +4 -0
- package/dist/statusline.js +3 -0
- package/dist/{still-E4HLCCST.js → still-WY7MUR7A.js} +1 -1
- package/dist/tiff-wasm-T2V2ICZT.js +3 -0
- package/dist/wasm/media_core_bg.wasm +0 -0
- package/dist/wasm/udf_bg.wasm +0 -0
- package/dist/wasm-threads/media_core_bg.wasm +0 -0
- package/dist/{wav-DXF73Y56.js → wav-LFS6OZHJ.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-35U7WGES.js +0 -3
- package/dist/chunk-3XTUTEKJ.js +0 -102
- package/dist/chunk-HJXRLQOI.js +0 -3
- package/dist/chunk-IDDQR56R.js +0 -7
- package/dist/chunk-UUMHVA7R.js +0 -3
- package/dist/chunk-WWGQFOB2.js +0 -64
- package/dist/cr3-wasm-X6Q4YMUU.js +0 -3
- package/dist/dng-wasm-EAB24KDN.js +0 -3
- package/dist/dpx-wasm-OX2D24ZB.js +0 -3
- package/dist/exr-wasm-Z6BBPJSN.js +0 -3
- package/dist/isobmff-XL33CVJR.js +0 -3
- package/dist/media_core-VSTO6CS4.js +0 -9
- package/dist/mxf-VIANACTI.js +0 -3
- package/dist/r3d-2QCFX7UX.js +0 -3
- package/dist/sscd-sweep-IXM4OD7O.js +0 -3
- package/dist/tiff-wasm-XYTQNL2F.js +0 -3
- package/dist/zod-IPSV75LP.js +0 -3
- /package/dist/{arriraw-Y5VXHXNX.js → arriraw-BEZILZY3.js} +0 -0
- /package/dist/{chunk-NYB4ISL3.js → chunk-NP53ITN6.js} +0 -0
- /package/dist/{media_core_bg-BKXQLNFA.js → media_core_bg-5UIQAP7I.js} +0 -0
- /package/dist/{prores-TQEZ3KFH.js → prores-BNALPJPS.js} +0 -0
- /package/dist/{timeline_core_bg-QEOVAIWP.js → timeline_core_bg-XYT26ZTU.js} +0 -0
- /package/dist/{udf_bg-UTQ6BVXX.js → udf_bg-R3JEZJAT.js} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
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 };
|
|
@@ -0,0 +1,85 @@
|
|
|
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 };
|
|
@@ -0,0 +1,312 @@
|
|
|
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 };
|
|
@@ -0,0 +1,82 @@
|
|
|
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 };
|