conformtools 0.6.5 → 0.6.6
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 +3 -3
- package/dist/account-HDXVTS5T.js +3 -0
- package/dist/arriraw-YIJ3BYNN.js +525 -0
- package/dist/avid-panel/MANIFEST.json +11 -0
- package/dist/avid-panel/avid-manifest.json +46 -0
- package/dist/avid-panel/icon.svg +4 -0
- package/dist/avid-panel/icons/conformtools.svg +4 -0
- package/dist/avid-panel/index.html +26 -0
- package/dist/avid-panel/panel.css +12 -0
- package/dist/avid-panel/panel.js +7 -0
- package/dist/bridge-D5KPIUSY.js +3 -0
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/chunk-3OCQA33E.js +3 -0
- package/dist/chunk-3XD6NC4G.js +10 -0
- package/dist/chunk-5JBUCVRI.js +20 -0
- package/dist/chunk-5RSNFPED.js +8 -0
- package/dist/chunk-5SUGU2YR.js +3 -0
- package/dist/chunk-6ML26TIK.js +3 -0
- package/dist/chunk-7D7H6VFW.js +3 -0
- package/dist/chunk-7MC7M2Y5.js +3 -0
- package/dist/chunk-AACY2V3L.js +3 -0
- package/dist/chunk-AS7IXHYM.js +19 -0
- package/dist/chunk-BL6L5ZBP.js +39 -0
- package/dist/chunk-C2ESM27Z.js +3 -0
- package/dist/chunk-C5IX63YF.js +3 -0
- package/dist/chunk-D6YDLKSA.js +3 -0
- package/dist/chunk-DKGGJM6Z.js +3 -0
- package/dist/chunk-EJGVNQ3E.js +8 -0
- package/dist/chunk-HGDO3OED.js +3 -0
- package/dist/chunk-JV7TZDKJ.js +3 -0
- package/dist/chunk-LFJLRLEP.js +3 -0
- package/dist/chunk-NFJHWZJX.js +3 -0
- package/dist/chunk-NQHQKEP5.js +3 -0
- package/dist/chunk-NU3X7P4N.js +3 -0
- package/dist/chunk-OJWIBQK4.js +376 -0
- package/dist/chunk-OVUCL3YY.js +5 -0
- package/dist/chunk-P7OVDUA5.js +3 -0
- package/dist/chunk-PFISREY4.js +3 -0
- package/dist/chunk-PFZVET7S.js +3 -0
- package/dist/chunk-PLRB2YXJ.js +3 -0
- package/dist/chunk-PSANHDZM.js +3 -0
- package/dist/chunk-RFIPLBQ4.js +5 -0
- package/dist/chunk-SZD4C5MB.js +6 -0
- package/dist/chunk-TK55FA56.js +3 -0
- package/dist/chunk-TXQR2HI2.js +4 -0
- package/dist/chunk-UCMNH6Q6.js +3 -0
- package/dist/chunk-UKKRZ574.js +7 -0
- package/dist/chunk-VS3MKKJ5.js +3 -0
- package/dist/chunk-X53BNWNV.js +3 -0
- package/dist/chunk-XNR7M4VX.js +3 -0
- package/dist/claude-setup-IIWUB4CE.js +5 -0
- package/dist/cli.js +17 -0
- package/dist/clip-state-B6JOX3JE.js +3 -0
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/cr3-wasm-L2LFY3LM.js +3 -0
- package/dist/dng-wasm-U6NC3MDK.js +3 -0
- package/dist/dpx-wasm-RMKEUKED.js +3 -0
- package/dist/engine-P6H5P6HP.js +5 -0
- package/dist/esm-SFFBP7PS.js +3 -0
- package/dist/exr-wasm-LBAOMOZD.js +3 -0
- package/dist/flame/hook/conformtools_flame/__init__.py +10 -0
- package/dist/flame/hook/conformtools_flame/building.py +191 -0
- package/dist/flame/hook/conformtools_flame/hook.py +177 -0
- package/dist/flame/hook/conformtools_flame/render.py +622 -0
- package/dist/flame/hook/conformtools_flame/util.py +33 -0
- package/dist/flame/hook/conformtools_flame/verbs.py +1037 -0
- package/dist/flame/hook/conformtools_flame_hook.py +42 -0
- package/dist/fonts/gfx/BarlowCondensed-Bold.ttf +0 -0
- package/dist/fonts/gfx/BarlowCondensed-Regular.ttf +0 -0
- package/dist/fonts/gfx/InstrumentSerif-Regular.ttf +0 -0
- package/dist/fonts/gfx/Inter-Bold.ttf +0 -0
- package/dist/fonts/gfx/Inter-Regular.ttf +0 -0
- package/dist/fonts/gfx/JetBrainsMono-Bold.ttf +0 -0
- package/dist/fonts/gfx/JetBrainsMono-Regular.ttf +0 -0
- package/dist/fonts/gfx/OFL.txt +100 -0
- package/dist/framing-SRCJKAYO.js +3 -0
- package/dist/gfx-worker.js +3 -0
- package/dist/h264-3ESGVT6G.js +3 -0
- package/dist/h264-mxf-NPFS7NGH.js +3 -0
- package/dist/host-relink-D6CB2VOQ.js +10 -0
- package/dist/hosts-W4AD2MYH.js +3 -0
- package/dist/http.js +5 -0
- package/dist/i2o-transfer +0 -0
- package/dist/inspect-7ASUPU73.js +68 -0
- package/dist/isobmff-SIOE67WL.js +3 -0
- package/dist/mcp.js +13 -0
- package/dist/media-7AUNRKHF.js +3 -0
- package/dist/media_core-Q2PIEV7D.js +9 -0
- package/dist/media_core_bg-FDL7GJZP.js +3 -0
- package/dist/media_core_bg-XRBVKQZH.js +3 -0
- package/dist/mxf-74TTDICM.js +3 -0
- package/dist/nuke/panel/python/Startup/conformtools_nuke_startup.py +44 -0
- package/dist/nuke/panel/python/conformtools_nuke/__init__.py +10 -0
- package/dist/nuke/panel/python/conformtools_nuke/panel.py +217 -0
- package/dist/nuke/panel/python/conformtools_nuke/verbs.py +837 -0
- package/dist/ops-FSOOBXMV.js +3 -0
- package/dist/peer-kit/ctpeer/__init__.py +21 -0
- package/dist/peer-kit/ctpeer/client.py +247 -0
- package/dist/peer-kit/ctpeer/neutral.py +178 -0
- package/dist/peer-kit/ctpeer/pairing.py +139 -0
- package/dist/peer-kit/ctpeer/protocol.py +209 -0
- package/dist/peer-kit/ctpeer/websocket.py +289 -0
- 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 +68 -0
- package/dist/premiere-uxp/lib/edit.js +516 -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 +67 -0
- package/dist/premiere-uxp/lib/premiere.js +91 -0
- package/dist/premiere-uxp/lib/probe.js +241 -0
- package/dist/premiere-uxp/lib/protocol.js +165 -0
- package/dist/premiere-uxp/lib/render.js +45 -0
- package/dist/premiere-uxp/lib/session.js +85 -0
- package/dist/premiere-uxp/lib/sizing.js +325 -0
- package/dist/premiere-uxp/lib/time.js +88 -0
- package/dist/premiere-uxp/lib/timeline.js +336 -0
- package/dist/premiere-uxp/lib/verbs.js +21 -0
- package/dist/premiere-uxp/lib/write.js +97 -0
- package/dist/premiere-uxp/manifest.json +102 -0
- package/dist/probe-F7WQHMIA.js +3 -0
- package/dist/prores-RIG37OIH.js +526 -0
- package/dist/r3d-YTLOMC7C.js +3 -0
- package/dist/r3d-ZDJ3WURS.js +1025 -0
- package/dist/resolve-bridge.py +2286 -0
- package/dist/resolve-presets/conform.tools.xml +127 -0
- package/dist/source-BDJAUQVR.js +3 -0
- package/dist/statusline-GMMCFMOA.js +4 -0
- package/dist/statusline.js +3 -0
- package/dist/still-ZG2RUQAL.js +3 -0
- package/dist/store-ZHXLQCGN.js +3 -0
- package/dist/tiff-wasm-D2FJ3L56.js +3 -0
- package/dist/timeline-6DYFDVEH.js +3 -0
- package/dist/timeline_core-IOENXK4Z.js +3 -0
- package/dist/timeline_core_bg-JW42YM3G.js +3 -0
- package/dist/udf_bg-B37GKRIH.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-OWMUGQMM.js +3 -0
- package/package.json +6 -4
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// The wire protocol, plugin side (docs/INTERNAL_HOST_BRIDGE.md, protocol 1).
|
|
2
|
+
//
|
|
3
|
+
// The app hosts a loopback WebSocket; this panel is the CLIENT (a UXP panel
|
|
4
|
+
// cannot listen). First frame out is `hello` with the pairing token; the app
|
|
5
|
+
// answers `welcome`. After that the app sends `request`s and we answer
|
|
6
|
+
// `response`s. We never send a request: there is no message that makes the
|
|
7
|
+
// app run anything.
|
|
8
|
+
//
|
|
9
|
+
// Pure: the WebSocket constructor and the verb table are injected, so the
|
|
10
|
+
// node tests drive this file without Premiere or a socket.
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
const { PeerError } = require("./handles");
|
|
14
|
+
|
|
15
|
+
const PROTOCOL_VERSION = 1;
|
|
16
|
+
const RECONNECT_MS = [500, 1000, 2000, 4000, 8000, 15000];
|
|
17
|
+
|
|
18
|
+
class BridgeClient {
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} opts
|
|
21
|
+
* @param {(url:string)=>WebSocket} opts.makeSocket
|
|
22
|
+
* @param {()=>Promise<{url:string,token:string}|null>} opts.readPairing
|
|
23
|
+
* @param {{id:string,name:string,version:string,platform:string}} opts.host
|
|
24
|
+
* @param {string[]} opts.capabilities
|
|
25
|
+
* @param {string[]} [opts.optionalVerbs]
|
|
26
|
+
* @param {Record<string,(params:object)=>Promise<any>|any>} opts.verbs "cap.verb" -> fn
|
|
27
|
+
* @param {(line:string)=>void} [opts.log]
|
|
28
|
+
* @param {(state:string, detail?:string)=>void} [opts.onState]
|
|
29
|
+
* @param {(fn:Function, ms:number)=>any} [opts.setTimeout]
|
|
30
|
+
*/
|
|
31
|
+
constructor(opts) {
|
|
32
|
+
this.o = opts;
|
|
33
|
+
this.ws = null;
|
|
34
|
+
this.state = "idle";
|
|
35
|
+
this.attempt = 0;
|
|
36
|
+
this._stopped = false;
|
|
37
|
+
this._timer = null;
|
|
38
|
+
this._setTimeout = opts.setTimeout || ((fn, ms) => setTimeout(fn, ms));
|
|
39
|
+
this._clearTimeout = opts.clearTimeout || ((t) => clearTimeout(t));
|
|
40
|
+
this.inflight = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
log(line) { if (this.o.log) this.o.log(line); }
|
|
44
|
+
setState(s, detail) { this.state = s; if (this.o.onState) this.o.onState(s, detail || ""); }
|
|
45
|
+
|
|
46
|
+
start() {
|
|
47
|
+
this._stopped = false;
|
|
48
|
+
this.attempt = 0;
|
|
49
|
+
return this.connect();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
stop() {
|
|
53
|
+
this._stopped = true;
|
|
54
|
+
if (this._timer) { this._clearTimeout(this._timer); this._timer = null; }
|
|
55
|
+
if (this.ws) { try { this.ws.close(); } catch (_) { /* closing */ } this.ws = null; }
|
|
56
|
+
this.setState("stopped");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async connect() {
|
|
60
|
+
if (this._stopped) return;
|
|
61
|
+
let pairing = null;
|
|
62
|
+
try { pairing = await this.o.readPairing(); } catch (e) { this.log(`pairing: ${e.message || e}`); }
|
|
63
|
+
if (!pairing || !pairing.url || !pairing.token) {
|
|
64
|
+
this.setState("unpaired", "no pairing file - enable the host bridge in conform.tools");
|
|
65
|
+
return this.scheduleReconnect();
|
|
66
|
+
}
|
|
67
|
+
// The pairing names 127.0.0.1; UXP matches the manifest's network
|
|
68
|
+
// domains by string, so the same loopback is also tried as `localhost`
|
|
69
|
+
// (both are listed) - alternating per attempt.
|
|
70
|
+
const url = this.attempt % 2 === 1 ? pairing.url.replace("ws://127.0.0.1:", "ws://localhost:") : pairing.url;
|
|
71
|
+
this.setState("connecting", url);
|
|
72
|
+
let ws;
|
|
73
|
+
try {
|
|
74
|
+
ws = this.o.makeSocket(url);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
// UXP raises here when the manifest permission has not been granted yet
|
|
77
|
+
// (seen on cold start of an installed .ccx); a reconnect fixes it.
|
|
78
|
+
this.log(`socket: ${e.message || e}`);
|
|
79
|
+
return this.scheduleReconnect();
|
|
80
|
+
}
|
|
81
|
+
this.ws = ws;
|
|
82
|
+
ws.onopen = () => {
|
|
83
|
+
this.attempt = 0;
|
|
84
|
+
const hello = {
|
|
85
|
+
type: "hello", protocol: PROTOCOL_VERSION, token: pairing.token,
|
|
86
|
+
host: this.o.host, capabilities: this.o.capabilities, optional_verbs: this.o.optionalVerbs || [],
|
|
87
|
+
};
|
|
88
|
+
this.send(hello);
|
|
89
|
+
this.setState("hello");
|
|
90
|
+
};
|
|
91
|
+
ws.onmessage = (ev) => { this.onFrame(typeof ev === "string" ? ev : ev.data); };
|
|
92
|
+
ws.onerror = (ev) => { this.log(`socket error${ev && ev.message ? ": " + ev.message : ""}`); };
|
|
93
|
+
ws.onclose = (ev) => {
|
|
94
|
+
const wasConnected = this.state === "connected";
|
|
95
|
+
this.ws = null;
|
|
96
|
+
this.setState("closed", ev && ev.code ? `code ${ev.code}` : "");
|
|
97
|
+
if (!this._stopped) this.scheduleReconnect(wasConnected);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
scheduleReconnect(fast) {
|
|
102
|
+
if (this._stopped || this._timer) return;
|
|
103
|
+
const ms = fast ? RECONNECT_MS[0] : RECONNECT_MS[Math.min(this.attempt, RECONNECT_MS.length - 1)];
|
|
104
|
+
this.attempt += 1;
|
|
105
|
+
this._timer = this._setTimeout(() => { this._timer = null; this.connect(); }, ms);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
send(obj) {
|
|
109
|
+
if (!this.ws) return false;
|
|
110
|
+
try { this.ws.send(JSON.stringify(obj)); return true; } catch (e) { this.log(`send: ${e.message || e}`); return false; }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** One text frame from the app. Never throws; a bad frame is logged. */
|
|
114
|
+
async onFrame(text) {
|
|
115
|
+
let msg;
|
|
116
|
+
try { msg = JSON.parse(text); } catch (_) { this.log("bad frame (not JSON)"); return; }
|
|
117
|
+
if (!msg || typeof msg !== "object") return;
|
|
118
|
+
switch (msg.type) {
|
|
119
|
+
case "welcome":
|
|
120
|
+
this.app = msg.app || {};
|
|
121
|
+
this.setState("connected", `${this.app.name || "app"} ${this.app.version || ""}`.trim());
|
|
122
|
+
return;
|
|
123
|
+
case "error":
|
|
124
|
+
this.log(`app refused: ${msg.code || "error"}${msg.message ? " - " + msg.message : ""}`);
|
|
125
|
+
this.setState("refused", msg.code || "error");
|
|
126
|
+
if (msg.code === "bad_token" || msg.code === "protocol_mismatch") {
|
|
127
|
+
// A stale pairing file: re-read it next time rather than hammering.
|
|
128
|
+
this.attempt = Math.max(this.attempt, 3);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
case "request":
|
|
132
|
+
return this.onRequest(msg);
|
|
133
|
+
default:
|
|
134
|
+
this.log(`unexpected frame type ${msg.type}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async onRequest(msg) {
|
|
139
|
+
const id = msg.id;
|
|
140
|
+
const method = String(msg.method || "");
|
|
141
|
+
const fn = this.o.verbs[method];
|
|
142
|
+
if (!fn) {
|
|
143
|
+
const cap = method.split(".")[0];
|
|
144
|
+
const code = this.o.capabilities.includes(cap) ? "unknown_method" : "capability_missing";
|
|
145
|
+
return this.send({ type: "response", id, ok: false, error: { code, message: method } });
|
|
146
|
+
}
|
|
147
|
+
this.inflight += 1;
|
|
148
|
+
try {
|
|
149
|
+
const result = await fn(msg.params || {});
|
|
150
|
+
this.send({ type: "response", id, ok: true, result: result === undefined ? null : result });
|
|
151
|
+
} catch (e) {
|
|
152
|
+
const code = (e && e.code) || "peer_error";
|
|
153
|
+
const message = (e && e.message) || String(e);
|
|
154
|
+
this.log(`${method}: ${message}`);
|
|
155
|
+
this.send({ type: "response", id, ok: false, error: { code, message } });
|
|
156
|
+
} finally {
|
|
157
|
+
this.inflight -= 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** A peer may push an event; it is inert JSON on the app side. */
|
|
162
|
+
event(name, data) { this.send({ type: "event", name, data: data || {} }); }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
module.exports = { BridgeClient, PROTOCOL_VERSION, RECONNECT_MS, PeerError };
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
const EM = ppro.EncoderManager;
|
|
13
|
+
if (!EM) throw new PeerError("api_missing", "EncoderManager is not in this Premiere");
|
|
14
|
+
const m = await P.callAny(EM, ["getManager"]);
|
|
15
|
+
const target = m && P.has(m, "addEventListener") ? m : P.has(EM, "addEventListener") ? EM : null;
|
|
16
|
+
if (target && manager._wired !== target) {
|
|
17
|
+
manager._wired = target;
|
|
18
|
+
// The DOM's events are EncoderManager's EVENT_RENDER_* constants (probe.json, 26.2); older builds used onEncode*.
|
|
19
|
+
const named = ["PROGRESS", "COMPLETE", "ERROR", "CANCEL", "QUEUE"].filter((k) => EM["EVENT_RENDER_" + k] !== undefined).map((k) => [k.toLowerCase(), EM["EVENT_RENDER_" + k]]);
|
|
20
|
+
const evs = named.length ? named : [["progress", "onEncodeProgress"], ["complete", "onEncodeComplete"], ["error", "onEncodeError"]];
|
|
21
|
+
for (const [label, ev] of evs) {
|
|
22
|
+
try { target.addEventListener(ev, (e) => { progress.jobs[String((e && e.jobId) || "last")] = { event: label, data: e && e.progress !== undefined ? e.progress : (e && e.status) }; }); } catch (_) { /* not this build */ }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return m;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const verbs = {
|
|
29
|
+
"render.ame_installed": async () => { try { return !!(await P.callAny(await manager(), ["isAMEInstalled"])); } catch (_) { return false; } },
|
|
30
|
+
// {timeline, output_path, preset_path, queue: bool}
|
|
31
|
+
"render.export_sequence": async ({ timeline, output_path, preset_path, queue }) => {
|
|
32
|
+
const ppro = P.api();
|
|
33
|
+
const seq = g(timeline, "seq");
|
|
34
|
+
const m = await manager();
|
|
35
|
+
// the export types are EncoderManager's own constants (EXPORT_QUEUE_TO_AME, EXPORT_IMMEDIATELY); Constants.ExportType on older builds
|
|
36
|
+
const EM = ppro.EncoderManager, types = ppro.Constants && ppro.Constants.ExportType ? ppro.Constants.ExportType : {};
|
|
37
|
+
const pick = (a, b, n) => (EM[a] !== undefined ? EM[a] : types[b] !== undefined ? types[b] : n);
|
|
38
|
+
const type = queue ? pick("EXPORT_QUEUE_TO_AME", "QUEUE_TO_AME", 1) : pick("EXPORT_IMMEDIATELY", "IMMEDIATELY", 0);
|
|
39
|
+
const job = await P.callAny(m, ["exportSequence"], seq, type, String(output_path), String(preset_path || ""));
|
|
40
|
+
return { ok: job !== false, job: job && typeof job === "object" ? String(job.jobId || job.id || "") : String(job || "") };
|
|
41
|
+
},
|
|
42
|
+
"render.progress": async () => progress.jobs,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
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(() => P.callAnySync(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,325 @@
|
|
|
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
|
+
const isThen = (x) => !!x && typeof x.then === "function";
|
|
24
|
+
|
|
25
|
+
const MOTION = { matchNames: ["AE.ADBE Motion", "ADBE Motion"], display: ["Motion"] };
|
|
26
|
+
const OPACITY = { matchNames: ["AE.ADBE Opacity", "ADBE Opacity"], display: ["Opacity"] };
|
|
27
|
+
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] };
|
|
28
|
+
const OPACITY_PARAMS = { opacity: ["Opacity", 0], blend: ["Blend Mode", 1] };
|
|
29
|
+
const TIME_REMAP = ["AE.ADBE Time Remapping", "ADBE Time Remapping"];
|
|
30
|
+
|
|
31
|
+
async function chainOf(item) {
|
|
32
|
+
return P.callAny(item, ["getComponentChain"]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function componentsOf(chain) {
|
|
36
|
+
const n = await P.callAny(chain, ["getComponentCount"]);
|
|
37
|
+
const out = [];
|
|
38
|
+
for (let i = 0; i < Number(n || 0); i += 1) out.push(await P.callAny(chain, ["getComponentAtIndex"], i));
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function matchName(c) {
|
|
43
|
+
try { return String(await P.callAny(c, ["getMatchName"])); } catch (_) { return ""; }
|
|
44
|
+
}
|
|
45
|
+
async function displayName(c) {
|
|
46
|
+
try { return String(await P.callAny(c, ["getDisplayName"])); } catch (_) { return c.displayName || ""; }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function findComponent(chain, spec) {
|
|
50
|
+
for (const c of await componentsOf(chain)) {
|
|
51
|
+
const mn = await matchName(c);
|
|
52
|
+
if (spec.matchNames.includes(mn)) return c;
|
|
53
|
+
const dn = await displayName(c);
|
|
54
|
+
if (spec.display.includes(dn)) return c;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function paramsOf(component) {
|
|
60
|
+
const n = await P.callAny(component, ["getParamCount"]);
|
|
61
|
+
const out = [];
|
|
62
|
+
for (let i = 0; i < Number(n || 0); i += 1) out.push(await P.callAny(component, ["getParam"], i));
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function findParam(component, [display, index]) {
|
|
67
|
+
const params = await paramsOf(component);
|
|
68
|
+
for (const p of params) {
|
|
69
|
+
const dn = p.displayName || (P.has(p, "getDisplayName") ? await p.getDisplayName() : "");
|
|
70
|
+
if (String(dn) === display) return p;
|
|
71
|
+
}
|
|
72
|
+
return params[index] || null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function paramValue(param, time) {
|
|
76
|
+
if (!param) return null;
|
|
77
|
+
if (P.has(param, "getValueAtTime") && time !== undefined) return param.getValueAtTime(time);
|
|
78
|
+
if (P.has(param, "getStartValue")) return param.getStartValue();
|
|
79
|
+
if (P.has(param, "getValue")) return param.getValue();
|
|
80
|
+
return param.value !== undefined ? param.value : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function isVarying(param) {
|
|
84
|
+
try { return !!(await P.callAny(param, ["isTimeVarying"])); } catch (_) { return false; }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function pt(v) {
|
|
88
|
+
// MEASURED 26.2: a param's start value is a Keyframe whose `.value` is the
|
|
89
|
+
// PointF; the PointF itself has `x` / `y`.
|
|
90
|
+
if (v && typeof v === "object" && v.value && typeof v.value === "object") v = v.value;
|
|
91
|
+
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 };
|
|
92
|
+
return { x: 0, y: 0 };
|
|
93
|
+
}
|
|
94
|
+
function num(v, d) { const n = Number(v && typeof v === "object" && "value" in v ? v.value : v); return Number.isFinite(n) ? n : d; }
|
|
95
|
+
|
|
96
|
+
/** Premiere's raw Motion / Opacity values at the clip's first frame. */
|
|
97
|
+
async function readRaw(item) {
|
|
98
|
+
const chain = await chainOf(item);
|
|
99
|
+
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 };
|
|
100
|
+
const motion = await findComponent(chain, MOTION);
|
|
101
|
+
if (motion) {
|
|
102
|
+
out.has_motion = true;
|
|
103
|
+
const at = P.has(item, "getStartTime") ? await item.getStartTime() : undefined;
|
|
104
|
+
for (const [key, spec] of Object.entries(MOTION_PARAMS)) {
|
|
105
|
+
const p = await findParam(motion, spec);
|
|
106
|
+
if (!p) continue;
|
|
107
|
+
const v = await paramValue(p, at);
|
|
108
|
+
if (key === "position" || key === "anchor") out[key] = pt(v);
|
|
109
|
+
else if (key === "uniform") out.uniform = !!(v && typeof v === "object" && "value" in v ? v.value : v);
|
|
110
|
+
else out[key] = num(v, out[key]);
|
|
111
|
+
if (await isVarying(p)) out.keyframed = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const opacity = await findComponent(chain, OPACITY);
|
|
115
|
+
if (opacity) {
|
|
116
|
+
const p = await findParam(opacity, OPACITY_PARAMS.opacity);
|
|
117
|
+
if (p) { out.opacity = num(await paramValue(p), 100); if (await isVarying(p)) out.keyframed = true; }
|
|
118
|
+
}
|
|
119
|
+
for (const c of await componentsOf(chain)) {
|
|
120
|
+
if (TIME_REMAP.includes(await matchName(c))) { out.variable_speed = true; break; }
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Neutral sizing for the model (editlist.ir_sizing's keys and units). */
|
|
126
|
+
function toNeutral(raw, raster) {
|
|
127
|
+
const w = raster && raster[0] ? raster[0] : 1920;
|
|
128
|
+
const hgt = raster && raster[1] ? raster[1] : 1080;
|
|
129
|
+
const out = {};
|
|
130
|
+
const px = raw.position.x - 0.5;
|
|
131
|
+
const py = raw.position.y - 0.5;
|
|
132
|
+
if (Math.abs(px) > 1e-9) out.Pan = Math.round(px * w * 1000) / 1000;
|
|
133
|
+
if (Math.abs(py) > 1e-9) out.Tilt = Math.round(-py * hgt * 1000) / 1000;
|
|
134
|
+
const sx = raw.uniform ? raw.scale : raw.scale_width;
|
|
135
|
+
const sy = raw.scale;
|
|
136
|
+
if (Math.abs(sx - 100) > 1e-6) out.ZoomX = Math.round(sx / 100 * 1e5) / 1e5;
|
|
137
|
+
if (Math.abs(sy - 100) > 1e-6) out.ZoomY = Math.round(sy / 100 * 1e5) / 1e5;
|
|
138
|
+
if (Math.abs(raw.rotation) > 1e-9) out.RotationAngle = Math.round(-raw.rotation * 1e4) / 1e4;
|
|
139
|
+
const ax = raw.anchor.x - 0.5;
|
|
140
|
+
const ay = raw.anchor.y - 0.5;
|
|
141
|
+
if (Math.abs(ax) > 1e-9) out.AnchorPointX = Math.round(ax * w * 1000) / 1000;
|
|
142
|
+
if (Math.abs(ay) > 1e-9) out.AnchorPointY = Math.round(-ay * hgt * 1000) / 1000;
|
|
143
|
+
if (Math.abs(raw.opacity - 100) > 1e-6) out.Opacity = Math.round(raw.opacity * 1000) / 1000;
|
|
144
|
+
if (raw.keyframed) out.keyframed = 1.0;
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function readSizingForModel(item, raster) {
|
|
149
|
+
try {
|
|
150
|
+
const raw = await readRaw(item);
|
|
151
|
+
return { sizing: toNeutral(raw, raster), keyframed: raw.keyframed, variable_speed: raw.variable_speed };
|
|
152
|
+
} catch (_) {
|
|
153
|
+
return { sizing: {}, keyframed: false, variable_speed: false };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The neutral POSE (what `align_cv.read_pose_full` returns for Resolve):
|
|
158
|
+
* Pan/Tilt in sequence pixels, ZoomX/ZoomY factors, RotationAngle,
|
|
159
|
+
* AnchorPointX/Y, FlipX/FlipY (Premiere has none on Motion), Opacity. */
|
|
160
|
+
async function readPose(item, raster) {
|
|
161
|
+
const raw = await readRaw(item);
|
|
162
|
+
const n = toNeutral(raw, raster);
|
|
163
|
+
return {
|
|
164
|
+
Pan: n.Pan || 0, Tilt: n.Tilt || 0, ZoomX: n.ZoomX || 1, ZoomY: n.ZoomY || 1, RotationAngle: n.RotationAngle || 0,
|
|
165
|
+
AnchorPointX: n.AnchorPointX || 0, AnchorPointY: n.AnchorPointY || 0, FlipX: 0, FlipY: 0, Opacity: raw.opacity,
|
|
166
|
+
keyframed: raw.keyframed, raw,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Write a pose (neutral units) as Premiere values, as ONE undo step. Only the
|
|
171
|
+
* keys present are written; a keyframed parameter is left alone and named. */
|
|
172
|
+
async function writePose(item, pose, raster, label) {
|
|
173
|
+
const project = await activeProject();
|
|
174
|
+
if (!project) throw new PeerError("no_project", "No project open");
|
|
175
|
+
const r = await poseActions(item, pose, raster);
|
|
176
|
+
const n = await transact(project, label || "conform.tools sizing", (add) => { for (const a of r.actions) add(a); });
|
|
177
|
+
return { actions: n, written: r.written, skipped: r.skipped };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** The actions that set `pose` on `item`, not committed: edit.apply adds them to its one transaction. */
|
|
181
|
+
async function poseActions(item, pose, raster) {
|
|
182
|
+
const actions = [];
|
|
183
|
+
const add = (a) => { if (a) actions.push(a); };
|
|
184
|
+
const w = raster && raster[0] ? raster[0] : 1920;
|
|
185
|
+
const hgt = raster && raster[1] ? raster[1] : 1080;
|
|
186
|
+
const chain = await chainOf(item);
|
|
187
|
+
const motion = await findComponent(chain, MOTION);
|
|
188
|
+
if (!motion) throw new PeerError("no_motion", "this clip has no Motion effect");
|
|
189
|
+
const skipped = [];
|
|
190
|
+
const written = [];
|
|
191
|
+
const at = P.has(item, "getStartTime") ? await item.getStartTime() : undefined;
|
|
192
|
+
const raw = await readRaw(item);
|
|
193
|
+
await (async () => {
|
|
194
|
+
// MEASURED 26.2: createSetValueAction's exact signature is not documented
|
|
195
|
+
// and a wrong shape raises "Illegal Parameter type". Try the forms in
|
|
196
|
+
// order and remember the first that builds an action - a keyframe with
|
|
197
|
+
// updateUI, a keyframe alone, the raw value with updateUI, the raw value
|
|
198
|
+
// alone. `_sizingSetForm` (set once per pass) skips the probing next time.
|
|
199
|
+
// MEASURED 26.2 (debug.sizing_probe): createSetValueAction takes a
|
|
200
|
+
// KEYFRAME, not a raw value - `createSetValueAction(130)` raises "Illegal
|
|
201
|
+
// Parameter type", `createSetValueAction(param.createKeyframe(130))`
|
|
202
|
+
// commits. The keyframe is created INSIDE each try so a value shape
|
|
203
|
+
// createKeyframe rejects (a PointF, say) falls through instead of
|
|
204
|
+
// throwing before the loop. The first shape that builds is cached.
|
|
205
|
+
// A THUNK the transaction runs under project.lockedAccess (26.3+ makes every action there, synchronously).
|
|
206
|
+
// The first form that builds is cached for the rest of the pass.
|
|
207
|
+
const buildSetValue = (p, value) => () => {
|
|
208
|
+
const forms = [
|
|
209
|
+
["keyframe,updateUI", () => { const k = p.createKeyframe(value); return isThen(k) ? k.then((kf) => p.createSetValueAction(kf, true)) : p.createSetValueAction(k, true); }],
|
|
210
|
+
["keyframe", () => { const k = p.createKeyframe(value); return isThen(k) ? k.then((kf) => p.createSetValueAction(kf)) : p.createSetValueAction(k); }],
|
|
211
|
+
["value,updateUI", () => p.createSetValueAction(value, true)],
|
|
212
|
+
["value", () => p.createSetValueAction(value)],
|
|
213
|
+
].filter(([name]) => P.has(p, "createKeyframe") || !name.startsWith("keyframe"));
|
|
214
|
+
const only = forms.filter(([name]) => !S._sizingSetForm || name === S._sizingSetForm);
|
|
215
|
+
const errors = [];
|
|
216
|
+
for (const [name, make] of (only.length ? only : forms)) {
|
|
217
|
+
try { const a = make(); if (a) { S._sizingSetForm = name; return a; } } catch (e) { errors.push(`${name}: ${e.message || e}`); }
|
|
218
|
+
}
|
|
219
|
+
throw new PeerError("set_value_failed", `createSetValueAction: ${errors.join("; ")}`);
|
|
220
|
+
};
|
|
221
|
+
const setValueAction = (p, value) => buildSetValue(p, value);
|
|
222
|
+
// the key counts as written once its action is made (under the lock, at commit); a refusal names it
|
|
223
|
+
const guard = (thunk, key) => { written.push(key); return () => { try { return thunk(); } catch (e) { written.splice(written.indexOf(key), 1); skipped.push(`${key} (${e.message || e})`); return null; } }; };
|
|
224
|
+
// One param failing does not abort the pose: the ones that write, write,
|
|
225
|
+
// and the rest are named. (MEASURED 26.2: scalar Motion params - Scale,
|
|
226
|
+
// Rotation, Opacity - write through the keyframe form; the two-axis
|
|
227
|
+
// params - Position, Anchor Point - reject every createKeyframe /
|
|
228
|
+
// createSetValueAction shape tried, so they are reported unwritten. No
|
|
229
|
+
// shipped tool writes sizing over the bridge yet; the Reconformer READS
|
|
230
|
+
// it and carries it through the engine's .prproj writer.)
|
|
231
|
+
const setNum = async (spec, value, key) => {
|
|
232
|
+
const p = await findParam(motion, spec);
|
|
233
|
+
if (!p) return;
|
|
234
|
+
if (await isVarying(p)) { skipped.push(key); return; }
|
|
235
|
+
add(guard(setValueAction(p, value), key));
|
|
236
|
+
};
|
|
237
|
+
const setPoint = async (spec, x, y, key) => {
|
|
238
|
+
const p = await findParam(motion, spec);
|
|
239
|
+
if (!p) return;
|
|
240
|
+
if (await isVarying(p)) { skipped.push(key); return; }
|
|
241
|
+
const ppro = P.api();
|
|
242
|
+
// 26.5 documents `new PointF(x, y)`; 26.2 had neither shape working (PointF.create, a plain {x, y})
|
|
243
|
+
let point = { x, y };
|
|
244
|
+
try { point = typeof ppro.PointF === "function" ? new ppro.PointF(x, y) : P.has(ppro.PointF, "create") ? ppro.PointF.create(x, y) : point; } catch (_) { try { point = ppro.PointF.create(x, y); } catch (_e) { /* plain */ } }
|
|
245
|
+
add(guard(setValueAction(p, point), key));
|
|
246
|
+
};
|
|
247
|
+
if (pose.Pan !== undefined || pose.Tilt !== undefined) {
|
|
248
|
+
const x = 0.5 + Number(pose.Pan !== undefined ? pose.Pan : (raw.position.x - 0.5) * w) / w;
|
|
249
|
+
const y = 0.5 - Number(pose.Tilt !== undefined ? pose.Tilt : -(raw.position.y - 0.5) * hgt) / hgt;
|
|
250
|
+
await setPoint(MOTION_PARAMS.position, x, y, "Pan/Tilt");
|
|
251
|
+
}
|
|
252
|
+
if (pose.ZoomX !== undefined || pose.ZoomY !== undefined) {
|
|
253
|
+
const zx = pose.ZoomX !== undefined ? Number(pose.ZoomX) : (raw.uniform ? raw.scale : raw.scale_width) / 100;
|
|
254
|
+
const zy = pose.ZoomY !== undefined ? Number(pose.ZoomY) : raw.scale / 100;
|
|
255
|
+
if (Math.abs(zx - zy) < 1e-6) {
|
|
256
|
+
await setNum(MOTION_PARAMS.uniform, true, "Uniform");
|
|
257
|
+
await setNum(MOTION_PARAMS.scale, zy * 100, "Zoom");
|
|
258
|
+
} else {
|
|
259
|
+
await setNum(MOTION_PARAMS.uniform, false, "Uniform");
|
|
260
|
+
await setNum(MOTION_PARAMS.scale, zy * 100, "ZoomY");
|
|
261
|
+
await setNum(MOTION_PARAMS.scale_width, zx * 100, "ZoomX");
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (pose.RotationAngle !== undefined) await setNum(MOTION_PARAMS.rotation, -Number(pose.RotationAngle), "Rotation");
|
|
265
|
+
if (pose.AnchorPointX !== undefined || pose.AnchorPointY !== undefined) {
|
|
266
|
+
const x = 0.5 + Number(pose.AnchorPointX !== undefined ? pose.AnchorPointX : (raw.anchor.x - 0.5) * w) / w;
|
|
267
|
+
const y = 0.5 - Number(pose.AnchorPointY !== undefined ? pose.AnchorPointY : -(raw.anchor.y - 0.5) * hgt) / hgt;
|
|
268
|
+
await setPoint(MOTION_PARAMS.anchor, x, y, "Anchor");
|
|
269
|
+
}
|
|
270
|
+
if (pose.Opacity !== undefined) {
|
|
271
|
+
const op = await findComponent(chain, OPACITY);
|
|
272
|
+
const p = op && await findParam(op, OPACITY_PARAMS.opacity);
|
|
273
|
+
if (p) {
|
|
274
|
+
if (await isVarying(p)) skipped.push("Opacity");
|
|
275
|
+
else {
|
|
276
|
+
add(guard(buildSetValue(p, Number(pose.Opacity)), "Opacity"));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (pose.FlipX || pose.FlipY) skipped.push("Flip (Premiere's Motion has no flip; use a Transform effect)");
|
|
281
|
+
})();
|
|
282
|
+
return { actions, written, skipped };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function rasterOfItemSeq() {
|
|
286
|
+
const project = await activeProject();
|
|
287
|
+
const seq = project && await P.callAny(project, ["getActiveSequence"]);
|
|
288
|
+
if (!seq) return [1920, 1080];
|
|
289
|
+
try { const fs = await P.callAny(seq, ["getFrameSize"]); return [Number(fs.width || 0) || 1920, Number(fs.height || 0) || 1080]; } catch (_) { return [1920, 1080]; }
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const verbs = {
|
|
293
|
+
"sizing.read_pose": async ({ item }) => readPose(g(item, "item"), await rasterOfItemSeq()),
|
|
294
|
+
"sizing.restore_pose": async ({ item, pose }) => {
|
|
295
|
+
const r = await writePose(g(item, "item"), pose || {}, await rasterOfItemSeq(), "conform.tools restore sizing");
|
|
296
|
+
return r.actions > 0;
|
|
297
|
+
},
|
|
298
|
+
"sizing.apply_transform": async ({ item, transform, compose }) => {
|
|
299
|
+
const it = g(item, "item");
|
|
300
|
+
const raster = await rasterOfItemSeq();
|
|
301
|
+
const t = transform || {};
|
|
302
|
+
let pose = { ...t };
|
|
303
|
+
if (compose !== false) {
|
|
304
|
+
const cur = await readPose(it, raster);
|
|
305
|
+
pose = {};
|
|
306
|
+
if (t.Pan !== undefined) pose.Pan = cur.Pan + Number(t.Pan);
|
|
307
|
+
if (t.Tilt !== undefined) pose.Tilt = cur.Tilt + Number(t.Tilt);
|
|
308
|
+
if (t.ZoomX !== undefined) pose.ZoomX = cur.ZoomX * Number(t.ZoomX);
|
|
309
|
+
if (t.ZoomY !== undefined) pose.ZoomY = cur.ZoomY * Number(t.ZoomY);
|
|
310
|
+
if (t.RotationAngle !== undefined) pose.RotationAngle = cur.RotationAngle + Number(t.RotationAngle);
|
|
311
|
+
for (const k of ["AnchorPointX", "AnchorPointY", "Opacity", "FlipX", "FlipY"]) if (t[k] !== undefined) pose[k] = t[k];
|
|
312
|
+
}
|
|
313
|
+
const r = await writePose(it, pose, raster, "conform.tools align");
|
|
314
|
+
return { applied: r.written, skipped: r.skipped, pose: await readPose(it, raster) };
|
|
315
|
+
},
|
|
316
|
+
"sizing.units": async ({ timeline_w, timeline_h }) => {
|
|
317
|
+
// Pan / tilt in the neutral pose are already sequence pixels: 1 unit = 1 px.
|
|
318
|
+
const w = Number(timeline_w) || 1920;
|
|
319
|
+
const hgt = Number(timeline_h) || 1080;
|
|
320
|
+
return { kx: 1.0, ky: 1.0, basis: "sequence_pixels", raster: [w, hgt], position_fraction_of_frame: true };
|
|
321
|
+
},
|
|
322
|
+
"sizing.raw": async ({ item }) => readRaw(g(item, "item")),
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
module.exports = { verbs, readRaw, toNeutral, readPose, writePose, poseActions, readSizingForModel, MOTION_PARAMS, OPACITY_PARAMS, findComponent, findParam, h };
|