@kriya-ai/harness 0.0.0-stage → 0.2.1
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 +379 -2
- package/SAFETY.md +162 -0
- package/THIRD_PARTY_NOTICES.md +7911 -0
- package/bin/kriya.js +577 -0
- package/bundle/cordis.patch.yml +397 -0
- package/contract/SOURCE.md +15 -0
- package/contract/contract.json +1355 -0
- package/package.json +57 -4
- package/plugins/anchor/index.js +56 -0
- package/plugins/anchor/package.json +13 -0
- package/plugins/approvals/index.js +183 -0
- package/plugins/approvals/package.json +13 -0
- package/plugins/brand/DESIGN.md +112 -0
- package/plugins/brand/client.js +826 -0
- package/plugins/brand/index.js +15 -0
- package/plugins/brand/package.json +25 -0
- package/plugins/brand/src/client.js +823 -0
- package/plugins/browser/index.js +218 -0
- package/plugins/browser/package.json +13 -0
- package/plugins/budget/index.js +108 -0
- package/plugins/budget/package.json +13 -0
- package/plugins/changes/client.js +245 -0
- package/plugins/changes/index.js +75 -0
- package/plugins/changes/package.json +22 -0
- package/plugins/edit/client.js +113 -0
- package/plugins/edit/index.js +58 -0
- package/plugins/edit/package.json +23 -0
- package/plugins/fs-freshness/index.js +28 -0
- package/plugins/fs-freshness/package.json +13 -0
- package/plugins/graph/client.js +178 -0
- package/plugins/graph/index.js +4 -0
- package/plugins/graph/package.json +22 -0
- package/plugins/kriya-handoff/index.js +194 -0
- package/plugins/kriya-handoff/package.json +13 -0
- package/plugins/kriya-tools/index.js +189 -0
- package/plugins/kriya-tools/package.json +13 -0
- package/plugins/loop/index.js +743 -0
- package/plugins/loop/package.json +13 -0
- package/plugins/mirror/index.js +235 -0
- package/plugins/mirror/package.json +13 -0
- package/plugins/overview/client.js +276 -0
- package/plugins/overview/index.js +95 -0
- package/plugins/overview/package.json +22 -0
- package/plugins/preview/client.js +337 -0
- package/plugins/preview/index.js +4 -0
- package/plugins/preview/package.json +22 -0
- package/plugins/progress/client.js +290 -0
- package/plugins/progress/index.js +100 -0
- package/plugins/progress/package.json +22 -0
- package/plugins/projects/client.js +249 -0
- package/plugins/projects/index.js +30 -0
- package/plugins/projects/package.json +24 -0
- package/plugins/rea/index.js +256 -0
- package/plugins/rea/package.json +10 -0
- package/plugins/rea/skill/LICENSE +21 -0
- package/plugins/rea/skill/SKILL.md +360 -0
- package/plugins/rea/skill/references/android-applications.md +36 -0
- package/plugins/rea/skill/references/connection-and-recovery.md +127 -0
- package/plugins/rea/skill/references/evidence-workflows.md +71 -0
- package/plugins/rea/skill/references/javascript-applications.md +218 -0
- package/plugins/rea/skill/references/native-and-artifacts.md +297 -0
- package/plugins/rea/skill/references/runtime-observation.md +78 -0
- package/plugins/remote/index.js +297 -0
- package/plugins/remote/package.json +10 -0
- package/plugins/router/index.js +84 -0
- package/plugins/router/package.json +13 -0
- package/plugins/sessions/client.js +68 -0
- package/plugins/sessions/index.js +79 -0
- package/plugins/sessions/package.json +20 -0
- package/plugins/skills/client.js +504 -0
- package/plugins/skills/index.js +166 -0
- package/plugins/skills/package.json +23 -0
- package/src/api.js +97 -0
- package/src/browser.js +286 -0
- package/src/changes.js +191 -0
- package/src/checkpoints.js +313 -0
- package/src/daemon.js +503 -0
- package/src/doctor.js +137 -0
- package/src/edit/core/anchors.js +102 -0
- package/src/edit/core/audio.js +158 -0
- package/src/edit/core/faces.js +99 -0
- package/src/edit/core/ffmpeg.js +258 -0
- package/src/edit/core/handoff.js +220 -0
- package/src/edit/core/history.js +90 -0
- package/src/edit/core/layout.js +92 -0
- package/src/edit/core/mix.js +115 -0
- package/src/edit/core/ops.js +602 -0
- package/src/edit/core/plan.js +266 -0
- package/src/edit/core/project.d.ts +134 -0
- package/src/edit/core/project.js +307 -0
- package/src/edit/core/reframe.js +125 -0
- package/src/edit/core/solver.js +416 -0
- package/src/edit/core/time.js +110 -0
- package/src/edit/core/tonemap.js +57 -0
- package/src/edit/director/ask.js +120 -0
- package/src/edit/director/gateway.js +16 -0
- package/src/edit/director/revise.js +186 -0
- package/src/edit/engine/capabilities.js +33 -0
- package/src/edit/engine/captions.js +154 -0
- package/src/edit/engine/color.js +269 -0
- package/src/edit/engine/confine.js +67 -0
- package/src/edit/engine/dna.js +148 -0
- package/src/edit/engine/index.js +473 -0
- package/src/edit/engine/loudness.js +43 -0
- package/src/edit/engine/media.js +57 -0
- package/src/edit/engine/motion.js +281 -0
- package/src/edit/engine/packs.js +87 -0
- package/src/edit/engine/probe.js +101 -0
- package/src/edit/engine/receipt.js +123 -0
- package/src/edit/engine/tool.js +101 -0
- package/src/edit/gates/copy.js +113 -0
- package/src/edit/gates/index.js +430 -0
- package/src/edit/gates/picture.js +130 -0
- package/src/edit/gates/sound.js +58 -0
- package/src/edit/gates/speech.js +127 -0
- package/src/edit/gates/text.js +196 -0
- package/src/edit/gates/text.swift +22 -0
- package/src/edit/graph/index.js +139 -0
- package/src/edit/graph/journal.js +69 -0
- package/src/edit/graph/scheduler.js +79 -0
- package/src/edit/host/client.js +58 -0
- package/src/edit/host/deliver.js +119 -0
- package/src/edit/host/jobs.js +84 -0
- package/src/edit/host/main.js +135 -0
- package/src/edit/host/paths.js +11 -0
- package/src/edit/host/projects.js +415 -0
- package/src/edit/host/server.js +391 -0
- package/src/edit/host/taste.js +135 -0
- package/src/edit/host/tavi.js +417 -0
- package/src/edit/host/watch.js +141 -0
- package/src/edit/index/db.js +109 -0
- package/src/edit/index/index.js +236 -0
- package/src/edit/index/layers/faces.js +78 -0
- package/src/edit/index/layers/faces.swift +18 -0
- package/src/edit/index/layers/meta.js +35 -0
- package/src/edit/index/layers/music.js +146 -0
- package/src/edit/index/layers/quality.js +120 -0
- package/src/edit/index/layers/retakes.js +132 -0
- package/src/edit/index/layers/screen.js +99 -0
- package/src/edit/index/layers/shots.js +29 -0
- package/src/edit/index/layers/sound.js +42 -0
- package/src/edit/index/layers/words.js +64 -0
- package/src/edit/index/story.js +248 -0
- package/src/edit/index/views.js +71 -0
- package/src/edit/loop/governor.js +112 -0
- package/src/edit/loop/loop.js +69 -0
- package/src/edit/loop/make.js +115 -0
- package/src/edit/loop/repair.js +97 -0
- package/src/edit/loop/replay.js +32 -0
- package/src/edit/recipes/multicam.js +461 -0
- package/src/edit/recipes/reel.js +202 -0
- package/src/edit/recipes/short-from-long.js +237 -0
- package/src/edit/recipes/tutorial.js +137 -0
- package/src/edit/recipes/youtube.js +155 -0
- package/src/edit/runtime/cli.js +126 -0
- package/src/edit/runtime/doctor.js +122 -0
- package/src/edit/runtime/fetch.js +15 -0
- package/src/edit/runtime/licences.js +88 -0
- package/src/edit/runtime/manifest.js +73 -0
- package/src/edit/runtime/setup.js +252 -0
- package/src/failure.js +69 -0
- package/src/gateway-proxy.js +213 -0
- package/src/intent.js +130 -0
- package/src/launch.js +315 -0
- package/src/live.js +81 -0
- package/src/local-skills.js +284 -0
- package/src/login.js +82 -0
- package/src/loop.js +428 -0
- package/src/modes.js +128 -0
- package/src/overview.js +71 -0
- package/src/paths.js +30 -0
- package/src/profiles.js +92 -0
- package/src/projects.js +104 -0
- package/src/recon.js +244 -0
- package/src/rules.js +139 -0
- package/src/runner.bundle.js +21172 -0
- package/src/sentinel.js +248 -0
- package/src/skill-switches.js +130 -0
- package/src/store.js +58 -0
- package/src/strict.js +124 -0
- package/src/verify.js +659 -0
- package/src/world.js +268 -0
- package/studio/dist/index.html +14 -0
- package/studio/dist/studio.css +163 -0
- package/studio/dist/studio.js +1 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// The compiler (EDIT_ENGINE §1, §6, §7): one RenderPlan of plain data for every
|
|
2
|
+
// output. Times inside a node are relative to its segment, and clip ids stay out of
|
|
3
|
+
// it, so a segment that only moved keeps its cache key.
|
|
4
|
+
|
|
5
|
+
import { CROSSFADE, crowdedEffects, DUCK_DEFAULTS, fitMusic, speechSpans } from "./audio.js"
|
|
6
|
+
import { outputFaces, unionBox } from "./faces.js"
|
|
7
|
+
import { canonical, sha256 } from "./project.js"
|
|
8
|
+
import { solveReframe } from "./reframe.js"
|
|
9
|
+
import { solve } from "./solver.js"
|
|
10
|
+
import { flicksToFrames, FLICKS, framesToFlicks, scaleFlicks, snapToFrame } from "./time.js"
|
|
11
|
+
|
|
12
|
+
const MAX_SEGMENT = 6 * FLICKS
|
|
13
|
+
const DRAFT_SHORT_SIDE = 720
|
|
14
|
+
const PICTURE_EFFECTS = new Set(["reframe", "grade", "lut", "stabilize", "transition", "fade"])
|
|
15
|
+
const AUDIO_EFFECTS = new Set(["level", "eq", "duck", "fade", "fit"])
|
|
16
|
+
|
|
17
|
+
const even = (value) => Math.round(value / 2) * 2
|
|
18
|
+
const only = (effects, types) => effects.filter((effect) => types.has(effect.type))
|
|
19
|
+
|
|
20
|
+
function outputOf(project, quality, id) {
|
|
21
|
+
const { width, height, fps } = project.canvas
|
|
22
|
+
if (quality !== "master") {
|
|
23
|
+
const scale = DRAFT_SHORT_SIDE / Math.min(width, height)
|
|
24
|
+
return { width: even(width * scale), height: even(height * scale), fps, codec: "h264" }
|
|
25
|
+
}
|
|
26
|
+
if (id === undefined) return { width, height, fps, codec: "h264" }
|
|
27
|
+
const deliverable = project.deliverables.find((d) => d.id === id)
|
|
28
|
+
if (!deliverable) throw new RangeError(`no deliverable "${id}"`)
|
|
29
|
+
return { width: deliverable.size.width, height: deliverable.size.height, fps: deliverable.fps, codec: deliverable.codec }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function cropPaths(project, rawIndex, timeline, issues) {
|
|
33
|
+
const paths = new Map()
|
|
34
|
+
for (const piece of timeline.picture) {
|
|
35
|
+
const reframe = piece.effects.find((e) => e.type === "reframe")
|
|
36
|
+
if (!reframe || paths.has(piece.clip)) continue
|
|
37
|
+
if (reframe.mode === "fixed") {
|
|
38
|
+
paths.set(piece.clip, [{ t: piece.in, x: reframe.x ?? 0 }])
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
const samples = rawIndex.subjects?.[piece.asset]
|
|
42
|
+
if (!samples?.length) {
|
|
43
|
+
issues.push({ code: "no_subject_track", clip: piece.clip, message: "this clip asks to follow a subject, but the index has no subject track for it" })
|
|
44
|
+
paths.set(piece.clip, null)
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
const facts = project.assets.find((a) => a.id === piece.asset).facts
|
|
48
|
+
const shots = [...new Set(samples.map((sample) => sample.shot))].map((id) => ({ id, samples: samples.filter((sample) => sample.shot === id) }))
|
|
49
|
+
const cropWidth = Math.round((facts.height * project.canvas.width) / project.canvas.height)
|
|
50
|
+
// ED11: the face box stays whole (L8's w), and the crop crosses at most its own width a second (ET-SOL-03)
|
|
51
|
+
paths.set(piece.clip, solveReframe(shots, { sourceWidth: facts.width, cropWidth, deadzone: Math.round(facts.width / 100), maxSpeed: cropWidth }).flatMap((shot) => shot.path))
|
|
52
|
+
}
|
|
53
|
+
return paths
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// A segment's crop points, with one either side so the crop glides across the segment's
|
|
57
|
+
// edge (ffmpeg.js interpolates); never across a shot change, where the path resets
|
|
58
|
+
function cropFor(path, part, shotStarts) {
|
|
59
|
+
const crosses = (a, b) => shotStarts.some((s) => s > a && s <= b)
|
|
60
|
+
const before = path.findLast((point) => point.t < part.in)
|
|
61
|
+
const after = path.find((point) => point.t > part.out)
|
|
62
|
+
return [...(before && !crosses(before.t, part.in) ? [before] : []), ...path.filter((point) => point.t >= part.in && point.t <= part.out), ...(after && !crosses(part.out, after.t) ? [after] : [])]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// A punch-in as a segment sees it. ED11's focus (x, y in thousandths of the framed
|
|
66
|
+
// picture) and smooth ease are added only when set, so older plans keep their keys;
|
|
67
|
+
// an eased zoom needs where this segment sits inside it
|
|
68
|
+
function zoomNode(zoom, start) {
|
|
69
|
+
const node = { scale: zoom.scale, ease: zoom.ease }
|
|
70
|
+
if (zoom.x !== undefined) Object.assign(node, { x: zoom.x, y: zoom.y })
|
|
71
|
+
if (zoom.ease === "smooth") Object.assign(node, { since: start - zoom.at, length: zoom.end - zoom.at })
|
|
72
|
+
return node
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function boundaries(timeline, rawIndex, fps) {
|
|
76
|
+
const cuts = new Set([0, timeline.duration])
|
|
77
|
+
for (const piece of timeline.picture) {
|
|
78
|
+
cuts.add(piece.at)
|
|
79
|
+
for (const shot of rawIndex.shots ?? []) {
|
|
80
|
+
if (shot.asset === piece.asset && shot.start > piece.in && shot.start < piece.out) cuts.add(snapToFrame(piece.at + scaleFlicks(shot.start - piece.in, { n: piece.speed.d, d: piece.speed.n }), fps, "floor"))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// A zoom's edges are segment edges, so each piece has one constant zoom
|
|
84
|
+
for (const zoom of timeline.zooms) {
|
|
85
|
+
cuts.add(zoom.at)
|
|
86
|
+
cuts.add(zoom.end)
|
|
87
|
+
}
|
|
88
|
+
const sorted = [...cuts].filter((t) => t >= 0 && t <= timeline.duration).sort((a, b) => a - b)
|
|
89
|
+
const spans = []
|
|
90
|
+
for (let i = 0; i + 1 < sorted.length; i++) {
|
|
91
|
+
const [start, end] = [sorted[i], sorted[i + 1]]
|
|
92
|
+
const parts = Math.ceil((end - start) / MAX_SEGMENT)
|
|
93
|
+
const [first, last] = [flicksToFrames(start, fps), flicksToFrames(end, fps)]
|
|
94
|
+
for (let p = 0; p < parts; p++) spans.push([framesToFlicks(first + Math.floor(((last - first) * p) / parts), fps), framesToFlicks(first + Math.floor(((last - first) * (p + 1)) / parts), fps)])
|
|
95
|
+
}
|
|
96
|
+
return spans
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function clipped(item, start, end) {
|
|
100
|
+
const from = Math.max(item.at, start)
|
|
101
|
+
const to = Math.min(item.end, end)
|
|
102
|
+
const rate = item.speed ?? { n: 1, d: 1 }
|
|
103
|
+
const pieceIn = item.in + scaleFlicks(from - item.at, rate)
|
|
104
|
+
const pieceOut = Math.min(item.out, item.in + scaleFlicks(to - item.at, rate))
|
|
105
|
+
return { asset: item.asset, in: item.hold ? item.in : pieceIn, out: item.hold ? item.out : pieceOut, at: from - start, end: to - start, speed: rate }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** All of a plan as one segment: a master is one continuous encode, so it has no seams. */
|
|
109
|
+
export function wholeSegment(plan) {
|
|
110
|
+
const absolute = (start) => (item) => ({ ...item, at: item.at + start, end: item.end + start })
|
|
111
|
+
const seen = new Set()
|
|
112
|
+
return {
|
|
113
|
+
id: "whole",
|
|
114
|
+
start: 0,
|
|
115
|
+
end: plan.duration,
|
|
116
|
+
node: {
|
|
117
|
+
picture: plan.segments.flatMap((s) => s.node.picture.map(absolute(s.start))),
|
|
118
|
+
overlays: plan.segments.flatMap((s) => s.node.overlays.map(absolute(s.start))),
|
|
119
|
+
tiles: plan.tiles.filter((tile) => !seen.has(tile.key) && seen.add(tile.key)).map(({ key, at, end }) => ({ key, at, end })),
|
|
120
|
+
...(plan.mattes?.length ? { mattes: plan.mattes } : {}),
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {object} project
|
|
127
|
+
* @param {object} rawIndex
|
|
128
|
+
* @param {{ engineVersion: string, runtimeVersion: string, quality?: "draft" | "master", deliverable?: string, rules?: object }} options
|
|
129
|
+
* @returns {object} the RenderPlan: plain data, no I/O
|
|
130
|
+
*/
|
|
131
|
+
export function compile(project, rawIndex, { engineVersion, runtimeVersion, quality = "draft", deliverable, rules } = {}) {
|
|
132
|
+
if (!engineVersion || !runtimeVersion) throw new TypeError("compile needs engineVersion and runtimeVersion: they are part of every cache key")
|
|
133
|
+
const timeline = solve(project, rawIndex, rules)
|
|
134
|
+
const output = outputOf(project, quality, deliverable)
|
|
135
|
+
const input = quality === "master" ? "source" : "proxy"
|
|
136
|
+
const issues = [...timeline.issues]
|
|
137
|
+
const fingerprint = new Map(project.assets.map((asset) => [asset.id, asset.fingerprint]))
|
|
138
|
+
const settings = { ...output, input }
|
|
139
|
+
|
|
140
|
+
// key = sha256(engine ‖ runtime ‖ inputs' content ids ‖ resolved plan node ‖ output settings)
|
|
141
|
+
const key = (node, assets) => sha256(canonical([engineVersion, runtimeVersion, [...new Set(assets)].map((id) => fingerprint.get(id)).sort(), node, settings]))
|
|
142
|
+
|
|
143
|
+
const burnCaptions = deliverable === undefined || project.deliverables.find((d) => d.id === deliverable)?.burnCaptions !== false
|
|
144
|
+
const captionTiles = burnCaptions
|
|
145
|
+
? timeline.captions.map((caption) => {
|
|
146
|
+
const node = {
|
|
147
|
+
kind: "caption",
|
|
148
|
+
text: caption.text,
|
|
149
|
+
words: caption.words.map((word) => ({ text: word.text, at: word.at - caption.at, end: word.end - caption.at, emphasis: caption.emphasis.includes(word.id) })),
|
|
150
|
+
look: caption.look,
|
|
151
|
+
style: project.look.caption,
|
|
152
|
+
placement: caption.placement,
|
|
153
|
+
duration: caption.end - caption.at,
|
|
154
|
+
...(caption.behind ? { behind: true } : {}),
|
|
155
|
+
}
|
|
156
|
+
return { key: key(node, []), kind: "caption", at: caption.at, end: caption.end, node }
|
|
157
|
+
})
|
|
158
|
+
: []
|
|
159
|
+
const blockTiles = timeline.overlays
|
|
160
|
+
.filter((overlay) => overlay.block)
|
|
161
|
+
.map((overlay) => {
|
|
162
|
+
const node = { kind: "block", ...overlay.block, placement: overlay.placement, duration: overlay.end - overlay.at, ...(overlay.behind ? { behind: true } : {}) }
|
|
163
|
+
return { key: key(node, []), kind: "block", at: overlay.at, end: overlay.end, node }
|
|
164
|
+
})
|
|
165
|
+
const tiles = [...captionTiles, ...blockTiles].sort((a, b) => a.at - b.at || (a.key < b.key ? -1 : 1))
|
|
166
|
+
|
|
167
|
+
const crops = cropPaths(project, rawIndex, timeline, issues)
|
|
168
|
+
// A proxy is normalised when it's made, so only a source needs this (EX-10)
|
|
169
|
+
const sourceColor = (id) => {
|
|
170
|
+
const color = project.assets.find((asset) => asset.id === id).facts.color
|
|
171
|
+
return input === "source" && color && (color.hdr || !color.tagged) ? color : undefined
|
|
172
|
+
}
|
|
173
|
+
// A colour match (ED13) as what the Engine measures: this clip's whole range against the reference clip's, so every segment of a clip gets the same LUT
|
|
174
|
+
const rangeOf = (clip) => {
|
|
175
|
+
const pieces = timeline.picture.filter((p) => p.clip === clip && !p.hold)
|
|
176
|
+
return pieces.length ? { asset: pieces[0].asset, in: Math.min(...pieces.map((p) => p.in)), out: Math.max(...pieces.map((p) => p.out)) } : null
|
|
177
|
+
}
|
|
178
|
+
const lost = new Set()
|
|
179
|
+
const resolved = (piece) =>
|
|
180
|
+
piece.effects.map((effect) => {
|
|
181
|
+
if (effect.type !== "grade" || effect.match === undefined) return effect
|
|
182
|
+
const { match, ...rest } = effect
|
|
183
|
+
const [from, to] = [rangeOf(piece.clip), rangeOf(match)]
|
|
184
|
+
if (!from || !to) {
|
|
185
|
+
if (!lost.has(piece.clip)) issues.push({ code: "match_reference_removed", clip: piece.clip, message: "the shot this was matched to isn't in the cut any more, so it isn't matched" })
|
|
186
|
+
lost.add(piece.clip)
|
|
187
|
+
return rest
|
|
188
|
+
}
|
|
189
|
+
return { ...rest, match: { key: sha256(canonical(["match-1", fingerprint.get(from.asset), from, fingerprint.get(to.asset), to])), from, to } }
|
|
190
|
+
})
|
|
191
|
+
const footage = timeline.overlays.filter((overlay) => !overlay.block)
|
|
192
|
+
const during = (start, end) => (item) => item.at < end && start < item.end
|
|
193
|
+
|
|
194
|
+
// The speaker's matte (EDD-49): the faces under each matte window, on the output.
|
|
195
|
+
// shortcut: one box per window from L8 faces, not a per-frame segmentation; MediaPipe's selfie segmenter replaces it when the runtime has it
|
|
196
|
+
const sizeOf = (id) => project.assets.find((asset) => asset.id === id)?.facts
|
|
197
|
+
const playing = timeline.picture.map((piece) => ({ ...piece, crop: crops.get(piece.clip) ?? undefined }))
|
|
198
|
+
const zoomAt = (t) => timeline.zooms.find((zoom) => zoom.at <= t && t < zoom.end)
|
|
199
|
+
const faces = outputFaces(playing, rawIndex.faces, sizeOf, { canvas: project.canvas, output, zoomAt })
|
|
200
|
+
const mattes = []
|
|
201
|
+
for (const window of timeline.mattes ?? []) {
|
|
202
|
+
const box = unionBox(faces.filter((face) => face.t >= window.at && face.t <= window.end).map((face) => face.box))
|
|
203
|
+
if (box) mattes.push({ at: window.at, end: window.end, box })
|
|
204
|
+
else issues.push({ code: "no_subject_for_matte", clip: window.clip, message: "there is no face under this text, so it is drawn in front, not behind" })
|
|
205
|
+
}
|
|
206
|
+
const hidden = (tile) => tile.node.behind === true && mattes.some((m) => m.at <= tile.at && tile.end <= m.end)
|
|
207
|
+
for (const tile of tiles) if (tile.node.behind && !hidden(tile)) tile.front = true
|
|
208
|
+
|
|
209
|
+
const segments = boundaries(timeline, rawIndex, project.canvas.fps).map(([start, end], i) => {
|
|
210
|
+
const picture = timeline.picture.filter(during(start, end)).map((piece) => {
|
|
211
|
+
const part = clipped(piece, start, end)
|
|
212
|
+
const color = sourceColor(piece.asset)
|
|
213
|
+
const path = crops.get(piece.clip)
|
|
214
|
+
const crop = path ? cropFor(path, part, (rawIndex.shots ?? []).filter((s) => s.asset === piece.asset).map((s) => s.start)) : undefined
|
|
215
|
+
const zoom = timeline.zooms.find(during(start, end))
|
|
216
|
+
return { ...part, ...(piece.hold ? { hold: true } : {}), effects: only(resolved(piece), PICTURE_EFFECTS), ...(crop ? { crop } : {}), ...(zoom ? { zoom: zoomNode(zoom, start) } : {}), ...(color ? { color } : {}) }
|
|
217
|
+
})
|
|
218
|
+
const overlays = footage.filter(during(start, end)).map((overlay) => ({ ...clipped(overlay, start, end), effects: only(overlay.effects, PICTURE_EFFECTS) }))
|
|
219
|
+
const node = {
|
|
220
|
+
picture,
|
|
221
|
+
overlays,
|
|
222
|
+
tiles: tiles.filter(during(start, end)).map((tile) => ({ key: tile.key, at: tile.at - start, end: tile.end - start })),
|
|
223
|
+
...(mattes.some(during(start, end)) ? { mattes: mattes.filter(during(start, end)).map((m) => ({ at: m.at - start, end: m.end - start, box: m.box })) } : {}),
|
|
224
|
+
}
|
|
225
|
+
const luts = picture.flatMap((item) => item.effects.filter((e) => e.type === "lut").map((e) => e.asset))
|
|
226
|
+
return { id: `s${i}`, start, end, key: key(node, [...picture.map((item) => item.asset), ...overlays.map((item) => item.asset), ...luts]), node }
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
issues.push(...crowdedEffects(timeline.audio))
|
|
230
|
+
const items = timeline.audio.map(({ clip: _, effects, ...item }) => ({ ...item, effects: only(effects, AUDIO_EFFECTS) }))
|
|
231
|
+
// Music fitted to the length on its downbeats (ED9); without beats it is cut at the end, and says so
|
|
232
|
+
for (const [i, item] of items.entries()) {
|
|
233
|
+
if (!item.effects.some((e) => e.type === "fit")) continue
|
|
234
|
+
const downbeats = (rawIndex.beats ?? []).filter((b) => b.asset === item.asset && b.downbeat).map((b) => b.t)
|
|
235
|
+
const fit = fitMusic({ from: item.in, to: item.out, downbeats, bars: (rawIndex.bars ?? []).filter((b) => b.asset === item.asset), target: item.end - item.at })
|
|
236
|
+
if (fit) item.fit = { segments: fit.segments, crossfade: CROSSFADE }
|
|
237
|
+
else {
|
|
238
|
+
issues.push({ code: "no_beats", clip: timeline.audio[i].clip, message: "this music has no beat grid yet, so it is cut at the end instead of fitted" })
|
|
239
|
+
item.out = Math.min(item.out, item.in + (item.end - item.at))
|
|
240
|
+
item.effects = item.effects.filter((e) => e.type !== "fit")
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// The duck's speech times on the output, so a new transcript gives a new mix
|
|
244
|
+
const duckEffect = items.flatMap((item) => item.effects).find((e) => e.type === "duck")
|
|
245
|
+
const duck = duckEffect ? { depth: duckEffect.depth ?? DUCK_DEFAULTS.depth, attack: duckEffect.attack ?? DUCK_DEFAULTS.attack, release: duckEffect.release ?? DUCK_DEFAULTS.release, speech: speechSpans(items, rawIndex.words) } : undefined
|
|
246
|
+
// The deliverable's loudness target masters the mix (ED7, for QG-06); none, and the key is as before
|
|
247
|
+
const loudness = deliverable === undefined ? undefined : project.deliverables.find((d) => d.id === deliverable)?.loudness
|
|
248
|
+
const sound = { items, ...(loudness ? { loudness } : {}), ...(duck ? { duck } : {}) }
|
|
249
|
+
const audio = loudness || duck ? { key: key(sound, items.map((item) => item.asset)), ...sound } : { key: key(items, items.map((item) => item.asset)), items }
|
|
250
|
+
const pictureNodes = segments.map(({ node: { tiles: _, ...node } }) => node)
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
schema: 1,
|
|
254
|
+
quality,
|
|
255
|
+
input,
|
|
256
|
+
canvas: project.canvas,
|
|
257
|
+
output,
|
|
258
|
+
duration: timeline.duration,
|
|
259
|
+
segments,
|
|
260
|
+
tiles,
|
|
261
|
+
...(mattes.length ? { mattes } : {}),
|
|
262
|
+
audio,
|
|
263
|
+
keys: { picture: sha256(canonical(pictureNodes)), audio: audio.key, caption: sha256(canonical(tiles.map((tile) => tile.key))) },
|
|
264
|
+
issues,
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// The contract of a Kriya Edit Project (EDIT_ENGINE §3, DATA_MODEL §2).
|
|
2
|
+
// project.js validates it at runtime; these types are for readers and editors.
|
|
3
|
+
|
|
4
|
+
/** An integer count of 1/705,600,000 s. Never a float. */
|
|
5
|
+
export type Flicks = number
|
|
6
|
+
export type Rate = { n: number; d: number }
|
|
7
|
+
export type Edge = "start" | "end"
|
|
8
|
+
|
|
9
|
+
export type Anchor =
|
|
10
|
+
| { word: string; edge: Edge; exact?: boolean }
|
|
11
|
+
| { shot: string; edge?: Edge }
|
|
12
|
+
| { beat: string }
|
|
13
|
+
| { marker: string }
|
|
14
|
+
| { clip: string; edge: Edge; offset?: Flicks }
|
|
15
|
+
|
|
16
|
+
/** A time is a number only when it truly is one; edits usually point at content. */
|
|
17
|
+
export type TimeRef = Flicks | Anchor
|
|
18
|
+
|
|
19
|
+
export type Author = "person" | "agent" | "code"
|
|
20
|
+
export type TrackRole = "base" | "broll" | "matte" | "overlay" | "caption" | "dialogue" | "sfx" | "music" | "ambience"
|
|
21
|
+
export type Box = { x: number; y: number; w: number; h: number }
|
|
22
|
+
|
|
23
|
+
export type Effect =
|
|
24
|
+
| { type: "reframe"; mode: "subject" | "fixed"; x?: number; y?: number }
|
|
25
|
+
| { type: "zoom"; scale: number; ease?: string; x?: number; y?: number } // x, y: focus in thousandths of the framed picture (ED11); ease "smooth" animates
|
|
26
|
+
| { type: "matte"; model?: string }
|
|
27
|
+
| { type: "grade"; lift?: number; gamma?: number; gain?: number; saturation?: number; ev?: number; match?: string }
|
|
28
|
+
| { type: "lut"; asset: string }
|
|
29
|
+
| { type: "stabilize"; strength?: number }
|
|
30
|
+
| { type: "fade"; in?: Flicks; out?: Flicks }
|
|
31
|
+
| { type: "transition"; kind: string; duration: Flicks }
|
|
32
|
+
| { type: "caption"; words: string[]; text?: string; look: string; placement?: Box; emphasis: string[] }
|
|
33
|
+
| { type: "block"; blockId: string; version: number; variables: Record<string, unknown> }
|
|
34
|
+
| { type: "level"; db: number }
|
|
35
|
+
| { type: "eq"; preset: string; strength?: number }
|
|
36
|
+
| { type: "duck"; depth?: number; attack?: Flicks; release?: Flicks }
|
|
37
|
+
| { type: "freeze"; at: TimeRef; duration: Flicks }
|
|
38
|
+
|
|
39
|
+
export type Clip = {
|
|
40
|
+
id: string
|
|
41
|
+
track: string
|
|
42
|
+
/** null for a generated clip: a caption, a title, a punch-in */
|
|
43
|
+
source: { asset: string; in: TimeRef; out: TimeRef } | null
|
|
44
|
+
/** null on the base track: base clips lay end to end, in list order */
|
|
45
|
+
at: TimeRef | null
|
|
46
|
+
until?: TimeRef
|
|
47
|
+
duration?: Flicks
|
|
48
|
+
/** How far into the sound its peak falls, so the peak lands on the anchor */
|
|
49
|
+
peak?: Flicks
|
|
50
|
+
loop?: boolean
|
|
51
|
+
effects: Effect[]
|
|
52
|
+
speed: Rate
|
|
53
|
+
linkGroup?: string
|
|
54
|
+
/** J and L cuts: how far sound starts before, or ends after, the picture */
|
|
55
|
+
audioLead?: Flicks
|
|
56
|
+
audioLag?: Flicks
|
|
57
|
+
createdBy: Author
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type Asset = {
|
|
61
|
+
id: string
|
|
62
|
+
kind: "video" | "audio" | "image" | "document" | "data" | "font" | "lut" | "reference"
|
|
63
|
+
fingerprint: string
|
|
64
|
+
sha256?: string
|
|
65
|
+
path: string
|
|
66
|
+
linked: boolean
|
|
67
|
+
rights: "own" | "licensed" | "public_domain" | "unknown"
|
|
68
|
+
rightsNote?: string
|
|
69
|
+
role?: "aroll" | "broll" | "screen" | "music" | "sfx" | "logo"
|
|
70
|
+
facts: {
|
|
71
|
+
duration?: Flicks
|
|
72
|
+
fps?: Rate | null
|
|
73
|
+
vfr?: boolean
|
|
74
|
+
width?: number
|
|
75
|
+
height?: number
|
|
76
|
+
hasAudio?: boolean
|
|
77
|
+
sampleRate?: number
|
|
78
|
+
channels?: number
|
|
79
|
+
rotation?: number
|
|
80
|
+
color?: { primaries: string; transfer: string; range: string; tagged: boolean; hdr: boolean }
|
|
81
|
+
peak?: Flicks
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type Sequence = {
|
|
86
|
+
id: string
|
|
87
|
+
name: string
|
|
88
|
+
tracks: { id: string; role: TrackRole; order: number; muted: boolean; locked: boolean }[]
|
|
89
|
+
markers: { id: string; name: string; at: TimeRef }[]
|
|
90
|
+
clips: Clip[]
|
|
91
|
+
parent?: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type Deliverable = {
|
|
95
|
+
id: string
|
|
96
|
+
preset: string
|
|
97
|
+
size: { width: number; height: number }
|
|
98
|
+
fps: Rate
|
|
99
|
+
codec: string
|
|
100
|
+
audio: string
|
|
101
|
+
loudness: { lufs: number; tp: number }
|
|
102
|
+
burnCaptions: boolean
|
|
103
|
+
gates: string[]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type EditBrief = {
|
|
107
|
+
format: string
|
|
108
|
+
targetDuration: Flicks
|
|
109
|
+
audience?: string
|
|
110
|
+
tone?: string
|
|
111
|
+
mustKeep: string[]
|
|
112
|
+
mustCut: string[]
|
|
113
|
+
language?: string
|
|
114
|
+
effort: "fast" | "best"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type Version = { id: string; parent: string | null; name?: string; author: Author; opsRange: number[]; hash: string; at: string }
|
|
118
|
+
|
|
119
|
+
export type Project = {
|
|
120
|
+
schema: 1
|
|
121
|
+
id: string
|
|
122
|
+
name: string
|
|
123
|
+
canvas: { width: number; height: number; fps: Rate; color: { primaries: string; transfer: string; range: string }; workingBitDepth: number }
|
|
124
|
+
assets: Asset[]
|
|
125
|
+
sequences: Sequence[]
|
|
126
|
+
active: string
|
|
127
|
+
look: { id: string; caption: object; color: object; motion: object; sound: object; brand: object }
|
|
128
|
+
deliverables: Deliverable[]
|
|
129
|
+
brief?: EditBrief
|
|
130
|
+
/** The next number for a new id, so a removed id is never handed out again */
|
|
131
|
+
nextId: number
|
|
132
|
+
head: string | null
|
|
133
|
+
history: Version[]
|
|
134
|
+
}
|