@morshoto/framekit 0.1.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -17
- package/dist-package/adapters/final-cut/typescript/src/analyzers.js +86 -2
- package/dist-package/adapters/final-cut/typescript/src/connection.js +5 -1
- package/dist-package/adapters/final-cut/typescript/src/export.js +231 -8
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +70 -9
- package/dist-package/adapters/final-cut/typescript/src/live.js +2 -2
- package/dist-package/adapters/final-cut/typescript/src/native.js +1000 -100
- package/dist-package/adapters/final-cut/typescript/src/publisher.js +242 -30
- package/dist-package/adapters/final-cut/typescript/src/session.js +86 -9
- package/dist-package/apps/mcp-server/src/main.js +10 -1
- package/dist-package/apps/mcp-server/src/routing.js +172 -0
- package/dist-package/apps/mcp-server/src/server.js +867 -52
- package/dist-package/apps/mcp-server/src/version.js +34 -0
- package/dist-package/packages/runtime/src/application/duration-policy-service.js +6 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +473 -0
- package/dist-package/packages/runtime/src/application/project-service.js +146 -0
- package/dist-package/packages/runtime/src/application/runtime-options.js +1 -0
- package/dist-package/packages/runtime/src/application/transaction-store.js +12 -0
- package/dist-package/packages/runtime/src/audio/dialogue-normalization.js +64 -0
- package/dist-package/packages/runtime/src/audio/noise-reduction.js +46 -0
- package/dist-package/packages/runtime/src/capabilities.js +187 -1
- package/dist-package/packages/runtime/src/color-correction.js +48 -0
- package/dist-package/packages/runtime/src/context/context-engine.js +20 -6
- package/dist-package/packages/runtime/src/context/context-service.js +30 -0
- package/dist-package/packages/runtime/src/context/revision.js +3 -0
- package/dist-package/packages/runtime/src/domain/capabilities.js +1 -0
- package/dist-package/packages/runtime/src/domain/context.js +1 -0
- package/dist-package/packages/runtime/src/domain/diff.js +1 -0
- package/dist-package/packages/runtime/src/domain/duration.js +1 -0
- package/dist-package/packages/runtime/src/domain/editing.js +1 -0
- package/dist-package/packages/runtime/src/domain/index.js +12 -0
- package/dist-package/packages/runtime/src/domain/media.js +8 -0
- package/dist-package/packages/runtime/src/domain/ports.js +1 -0
- package/dist-package/packages/runtime/src/domain/primitives.js +1 -0
- package/dist-package/packages/runtime/src/domain/project.js +1 -0
- package/dist-package/packages/runtime/src/domain/rough-cut.js +69 -0
- package/dist-package/packages/runtime/src/domain/skills.js +33 -0
- package/dist-package/packages/runtime/src/domain/types.js +5 -1
- package/dist-package/packages/runtime/src/domain/verification.js +1 -0
- package/dist-package/packages/runtime/src/editing/dialogue-normalization-service.js +141 -0
- package/dist-package/packages/runtime/src/editing/duration-policy.js +187 -0
- package/dist-package/packages/runtime/src/editing/edit-service.js +449 -0
- package/dist-package/packages/runtime/src/editing/filler-removal-service.js +361 -0
- package/dist-package/packages/runtime/src/editing/music-service.js +85 -0
- package/dist-package/packages/runtime/src/index.js +14 -3
- package/dist-package/packages/runtime/src/planning/rough-cut.js +71 -0
- package/dist-package/packages/runtime/src/runtime.js +131 -826
- package/dist-package/packages/runtime/src/skills/builtin.js +339 -0
- package/dist-package/packages/runtime/src/skills/index.js +3 -0
- package/dist-package/packages/runtime/src/skills/registry.js +74 -0
- package/dist-package/packages/runtime/src/skills/requirements.js +170 -0
- package/dist-package/packages/runtime/src/skills/runtime.js +239 -0
- package/dist-package/packages/runtime/src/speech/analysis.js +301 -0
- package/dist-package/packages/runtime/src/speech/filler-detector.js +132 -0
- package/dist-package/packages/runtime/src/speech/mapping.js +227 -0
- package/dist-package/packages/runtime/src/speech/safe-cut-resolver.js +314 -0
- package/dist-package/packages/runtime/src/timeline/rational-time.js +63 -0
- package/dist-package/packages/runtime/src/verification/verification.js +712 -1
- package/dist-package/packages/testkit/src/fixture-analyzers.js +28 -0
- package/dist-package/packages/testkit/src/in-memory-editor.js +287 -3
- package/dist-package/packages/testkit/src/index.js +1 -0
- package/dist-package/packages/testkit/src/skill-fixtures.js +64 -0
- package/package.json +17 -8
- /package/dist-package/packages/runtime/src/{diff/diff.js → timeline/snapshot-diff.js} +0 -0
- /package/dist-package/packages/runtime/src/{snapshot-digest.js → timeline/snapshot-digest.js} +0 -0
|
@@ -1,5 +1,104 @@
|
|
|
1
|
+
export function assertValidVerificationPolicy(policy) {
|
|
2
|
+
if (!policy || typeof policy !== "object") {
|
|
3
|
+
throw new Error("INVALID_VERIFICATION_POLICY: policy must be an object");
|
|
4
|
+
}
|
|
5
|
+
if (policy.maxTruePeakDb !== undefined && !Number.isFinite(policy.maxTruePeakDb)) {
|
|
6
|
+
throw new Error("INVALID_VERIFICATION_POLICY: maxTruePeakDb must be finite");
|
|
7
|
+
}
|
|
8
|
+
if (policy.targetLufs !== undefined && !Number.isFinite(policy.targetLufs)) {
|
|
9
|
+
throw new Error("INVALID_VERIFICATION_POLICY: targetLufs must be finite");
|
|
10
|
+
}
|
|
11
|
+
if (policy.loudnessToleranceDb !== undefined
|
|
12
|
+
&& (!Number.isFinite(policy.loudnessToleranceDb) || policy.loudnessToleranceDb < 0)) {
|
|
13
|
+
throw new Error("INVALID_VERIFICATION_POLICY: loudnessToleranceDb must be non-negative and finite");
|
|
14
|
+
}
|
|
15
|
+
if (policy.assertions === undefined)
|
|
16
|
+
return;
|
|
17
|
+
if (!Array.isArray(policy.assertions)) {
|
|
18
|
+
throw new Error("INVALID_VERIFICATION_POLICY: assertions must be an array");
|
|
19
|
+
}
|
|
20
|
+
policy.assertions.forEach((assertion, index) => validateAssertion(assertion, index));
|
|
21
|
+
}
|
|
22
|
+
function validateAssertion(assertion, index) {
|
|
23
|
+
const path = `assertions[${index}]`;
|
|
24
|
+
if (assertion.type === "audio-audibility") {
|
|
25
|
+
if (assertion.minAudibleSamples !== undefined
|
|
26
|
+
&& (!Number.isInteger(assertion.minAudibleSamples) || assertion.minAudibleSamples <= 0)) {
|
|
27
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path}.minAudibleSamples must be a positive integer`);
|
|
28
|
+
}
|
|
29
|
+
if (assertion.maxSilenceMs !== undefined
|
|
30
|
+
&& (!Number.isFinite(assertion.maxSilenceMs) || assertion.maxSilenceMs < 0)) {
|
|
31
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path}.maxSilenceMs must be non-negative and finite`);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (assertion.type === "audio-coverage") {
|
|
36
|
+
if (!Number.isFinite(assertion.start) || assertion.start < 0
|
|
37
|
+
|| !Number.isFinite(assertion.duration) || assertion.duration <= 0
|
|
38
|
+
|| assertion.toleranceSeconds !== undefined
|
|
39
|
+
&& (!Number.isFinite(assertion.toleranceSeconds) || assertion.toleranceSeconds < 0)) {
|
|
40
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} has invalid coverage timing`);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (assertion.type === "audio-loudness") {
|
|
45
|
+
if (!Number.isFinite(assertion.targetLufs)
|
|
46
|
+
|| assertion.toleranceDb !== undefined
|
|
47
|
+
&& (!Number.isFinite(assertion.toleranceDb) || assertion.toleranceDb < 0)) {
|
|
48
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} has invalid loudness values`);
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (assertion.type === "audio-noise") {
|
|
53
|
+
if (!Number.isFinite(assertion.maxNoiseFloorDb)
|
|
54
|
+
|| assertion.minConfidence !== undefined
|
|
55
|
+
&& (!Number.isFinite(assertion.minConfidence) || assertion.minConfidence < 0 || assertion.minConfidence > 1)) {
|
|
56
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} has invalid noise values`);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (assertion.type === "audio-source") {
|
|
61
|
+
if (assertion.sourceDigest === undefined && assertion.source === undefined) {
|
|
62
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} requires sourceDigest or source`);
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (assertion.type === "visual-content") {
|
|
67
|
+
if (assertion.minConfidence !== undefined
|
|
68
|
+
&& (!Number.isFinite(assertion.minConfidence) || assertion.minConfidence < 0 || assertion.minConfidence > 1)) {
|
|
69
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path}.minConfidence must be between 0 and 1`);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (assertion.type === "duration") {
|
|
74
|
+
if (!Number.isFinite(assertion.expectedSeconds) || assertion.expectedSeconds < 0
|
|
75
|
+
|| assertion.toleranceSeconds !== undefined
|
|
76
|
+
&& (!Number.isFinite(assertion.toleranceSeconds) || assertion.toleranceSeconds < 0)) {
|
|
77
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} has invalid duration values`);
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (assertion.type === "stream")
|
|
82
|
+
return;
|
|
83
|
+
if (assertion.type === "structure") {
|
|
84
|
+
if ((assertion.requirement === "media-present" && assertion.mediaId === undefined)
|
|
85
|
+
|| (assertion.requirement === "occurrence-present" && assertion.occurrenceId === undefined)
|
|
86
|
+
|| (assertion.requirement === "operation-present" && assertion.operationType === undefined)) {
|
|
87
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} is missing its required identifier`);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (assertion.type === "color-correction") {
|
|
92
|
+
if (!assertion.clipId.trim() || !assertion.expected || typeof assertion.expected !== "object") {
|
|
93
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} has invalid color correction values`);
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
throw new Error(`INVALID_VERIFICATION_POLICY: ${path} has an unsupported assertion type`);
|
|
98
|
+
}
|
|
1
99
|
export class DefaultVerificationEngine {
|
|
2
100
|
async verify(transaction, policy) {
|
|
101
|
+
assertValidVerificationPolicy(policy);
|
|
3
102
|
const checks = [
|
|
4
103
|
{
|
|
5
104
|
name: "timeline-valid",
|
|
@@ -19,6 +118,13 @@ export class DefaultVerificationEngine {
|
|
|
19
118
|
detail: "the editor returned a newer revision after the write",
|
|
20
119
|
},
|
|
21
120
|
];
|
|
121
|
+
if (transaction.planned.some(isConstructionOperation)) {
|
|
122
|
+
checks.push({
|
|
123
|
+
name: "construction-state",
|
|
124
|
+
passed: constructionStateIsValid(transaction),
|
|
125
|
+
detail: constructionStateDetail(transaction),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
22
128
|
if (policy.requireExpectedChange !== false) {
|
|
23
129
|
checks.push({
|
|
24
130
|
name: "expected-change",
|
|
@@ -73,8 +179,443 @@ export class DefaultVerificationEngine {
|
|
|
73
179
|
detail: continuity ? "speech words remain inside their clip bounds" : "a speech word would be clipped",
|
|
74
180
|
});
|
|
75
181
|
}
|
|
76
|
-
|
|
182
|
+
checks.push(...(policy.assertions ?? []).map((assertion) => verifyAssertion(transaction, assertion)));
|
|
183
|
+
return {
|
|
184
|
+
passed: checks.every((check) => check.passed),
|
|
185
|
+
checks,
|
|
186
|
+
...(transaction.target ? { target: structuredClone(transaction.target) } : {}),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function verifyAssertion(transaction, assertion) {
|
|
191
|
+
if (assertion.type === "audio-coverage")
|
|
192
|
+
return verifyAudioCoverage(transaction, assertion);
|
|
193
|
+
if (assertion.type === "audio-loudness")
|
|
194
|
+
return verifyAudioLoudness(transaction, assertion);
|
|
195
|
+
if (assertion.type === "audio-noise")
|
|
196
|
+
return verifyAudioNoise(transaction, assertion);
|
|
197
|
+
if (assertion.type === "audio-source")
|
|
198
|
+
return verifyAudioSource(transaction, assertion);
|
|
199
|
+
if (assertion.type === "visual-content")
|
|
200
|
+
return verifyVisualContent(transaction, assertion);
|
|
201
|
+
if (assertion.type === "duration")
|
|
202
|
+
return verifyDuration(transaction, assertion);
|
|
203
|
+
if (assertion.type === "stream")
|
|
204
|
+
return verifyStream(transaction, assertion);
|
|
205
|
+
if (assertion.type === "structure")
|
|
206
|
+
return verifyStructure(transaction, assertion);
|
|
207
|
+
if (assertion.type === "color-correction")
|
|
208
|
+
return verifyColorCorrection(transaction, assertion);
|
|
209
|
+
return verifyAudioAudibility(transaction, assertion);
|
|
210
|
+
}
|
|
211
|
+
function verifyAudioAudibility(transaction, assertion) {
|
|
212
|
+
const expected = {
|
|
213
|
+
mediaId: assertion.mediaId,
|
|
214
|
+
minAudibleSamples: assertion.minAudibleSamples ?? 1,
|
|
215
|
+
...(assertion.maxSilenceMs !== undefined ? { maxSilenceMs: assertion.maxSilenceMs } : {}),
|
|
216
|
+
};
|
|
217
|
+
const media = transaction.attemptedAfter.media.find((candidate) => candidate.mediaId === assertion.mediaId);
|
|
218
|
+
if (!media) {
|
|
219
|
+
return {
|
|
220
|
+
name: assertion.type,
|
|
221
|
+
passed: false,
|
|
222
|
+
status: "failed",
|
|
223
|
+
expected,
|
|
224
|
+
observed: { mediaId: assertion.mediaId },
|
|
225
|
+
reason: "MEDIA_NOT_FOUND",
|
|
226
|
+
detail: `expected audio media ${assertion.mediaId}, but it was not observed`,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (!media.audio) {
|
|
230
|
+
return {
|
|
231
|
+
name: assertion.type,
|
|
232
|
+
passed: false,
|
|
233
|
+
status: "unavailable",
|
|
234
|
+
expected,
|
|
235
|
+
observed: { mediaId: assertion.mediaId },
|
|
236
|
+
reason: "AUDIO_ANALYZER_UNAVAILABLE",
|
|
237
|
+
detail: `audio analysis is unavailable for media ${assertion.mediaId}`,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const duration = Number.isFinite(media.audio.analyzedDurationSeconds) && media.audio.analyzedDurationSeconds > 0
|
|
241
|
+
? media.audio.analyzedDurationSeconds
|
|
242
|
+
: Number.isFinite(media.duration) && media.duration > 0
|
|
243
|
+
? media.duration
|
|
244
|
+
: undefined;
|
|
245
|
+
if (media.audio.audibleSamples === undefined
|
|
246
|
+
&& duration === undefined) {
|
|
247
|
+
return {
|
|
248
|
+
name: assertion.type,
|
|
249
|
+
passed: false,
|
|
250
|
+
status: "unavailable",
|
|
251
|
+
expected,
|
|
252
|
+
observed: { mediaId: assertion.mediaId, silenceMs: media.audio.silenceMs },
|
|
253
|
+
reason: "AUDIO_ANALYZER_UNAVAILABLE",
|
|
254
|
+
detail: `audio analysis for media ${assertion.mediaId} has no duration evidence`,
|
|
255
|
+
};
|
|
77
256
|
}
|
|
257
|
+
const observed = {
|
|
258
|
+
mediaId: assertion.mediaId,
|
|
259
|
+
...(media.audio.audibleSamples !== undefined ? { audibleSamples: media.audio.audibleSamples } : {}),
|
|
260
|
+
silenceMs: media.audio.silenceMs,
|
|
261
|
+
};
|
|
262
|
+
const minAudibleSamples = assertion.minAudibleSamples ?? 1;
|
|
263
|
+
const audible = media.audio.audibleSamples === undefined
|
|
264
|
+
? media.audio.silenceMs < duration * 1000
|
|
265
|
+
: media.audio.audibleSamples >= minAudibleSamples;
|
|
266
|
+
const silenceWithinLimit = assertion.maxSilenceMs === undefined || media.audio.silenceMs <= assertion.maxSilenceMs;
|
|
267
|
+
const passed = audible && silenceWithinLimit;
|
|
268
|
+
return {
|
|
269
|
+
name: assertion.type,
|
|
270
|
+
passed,
|
|
271
|
+
status: passed ? "passed" : "failed",
|
|
272
|
+
expected,
|
|
273
|
+
observed,
|
|
274
|
+
...(passed ? {} : { reason: audible ? "AUDIO_SILENCE_EXCEEDED" : "AUDIO_NOT_AUDIBLE" }),
|
|
275
|
+
detail: passed
|
|
276
|
+
? `observed audible audio for media ${assertion.mediaId}`
|
|
277
|
+
: audible
|
|
278
|
+
? `expected silence at or below ${assertion.maxSilenceMs}ms, observed ${media.audio.silenceMs}ms`
|
|
279
|
+
: "expected audible audio samples, observed none",
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function verifyAudioCoverage(transaction, assertion) {
|
|
283
|
+
const toleranceSeconds = assertion.toleranceSeconds ?? 0;
|
|
284
|
+
const expected = {
|
|
285
|
+
mediaId: assertion.mediaId,
|
|
286
|
+
start: assertion.start,
|
|
287
|
+
duration: assertion.duration,
|
|
288
|
+
toleranceSeconds,
|
|
289
|
+
};
|
|
290
|
+
const intervals = transaction.attemptedAfter.timeline.clips
|
|
291
|
+
.filter((clip) => clip.mediaId === assertion.mediaId)
|
|
292
|
+
.map((clip) => ({
|
|
293
|
+
start: Math.max(assertion.start, clip.start),
|
|
294
|
+
end: Math.min(assertion.start + assertion.duration, clip.start + clip.duration),
|
|
295
|
+
}))
|
|
296
|
+
.filter((range) => range.end > range.start)
|
|
297
|
+
.sort((left, right) => left.start - right.start);
|
|
298
|
+
const ranges = [];
|
|
299
|
+
for (const interval of intervals) {
|
|
300
|
+
const previous = ranges[ranges.length - 1];
|
|
301
|
+
if (previous && interval.start <= previous.end)
|
|
302
|
+
previous.end = Math.max(previous.end, interval.end);
|
|
303
|
+
else
|
|
304
|
+
ranges.push({ ...interval });
|
|
305
|
+
}
|
|
306
|
+
const observed = {
|
|
307
|
+
mediaId: assertion.mediaId,
|
|
308
|
+
ranges,
|
|
309
|
+
start: ranges[0]?.start ?? null,
|
|
310
|
+
end: ranges.at(-1)?.end ?? null,
|
|
311
|
+
duration: ranges.reduce((total, range) => total + range.end - range.start, 0),
|
|
312
|
+
};
|
|
313
|
+
const passed = ranges.length === 1
|
|
314
|
+
&& observed.start !== null
|
|
315
|
+
&& observed.start <= assertion.start + toleranceSeconds
|
|
316
|
+
&& observed.end !== null
|
|
317
|
+
&& observed.end >= assertion.start + assertion.duration - toleranceSeconds;
|
|
318
|
+
return {
|
|
319
|
+
name: assertion.type,
|
|
320
|
+
passed,
|
|
321
|
+
status: passed ? "passed" : "failed",
|
|
322
|
+
expected,
|
|
323
|
+
observed,
|
|
324
|
+
...(passed ? {} : { reason: "AUDIO_COVERAGE_INCOMPLETE" }),
|
|
325
|
+
detail: passed
|
|
326
|
+
? `observed continuous audio coverage for media ${assertion.mediaId}`
|
|
327
|
+
: `expected ${assertion.duration}s of continuous audio coverage, observed ${observed.duration}s`,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function verifyAudioLoudness(transaction, assertion) {
|
|
331
|
+
const toleranceDb = assertion.toleranceDb ?? 0.5;
|
|
332
|
+
const expected = {
|
|
333
|
+
mediaId: assertion.mediaId,
|
|
334
|
+
targetLufs: assertion.targetLufs,
|
|
335
|
+
toleranceDb,
|
|
336
|
+
};
|
|
337
|
+
const media = transaction.attemptedAfter.media.find((candidate) => candidate.mediaId === assertion.mediaId);
|
|
338
|
+
if (!media) {
|
|
339
|
+
return {
|
|
340
|
+
name: assertion.type,
|
|
341
|
+
passed: false,
|
|
342
|
+
status: "failed",
|
|
343
|
+
expected,
|
|
344
|
+
observed: { mediaId: assertion.mediaId },
|
|
345
|
+
reason: "MEDIA_NOT_FOUND",
|
|
346
|
+
detail: `expected audio media ${assertion.mediaId}, but it was not observed`,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
if (!media.audio) {
|
|
350
|
+
return {
|
|
351
|
+
name: assertion.type,
|
|
352
|
+
passed: false,
|
|
353
|
+
status: "unavailable",
|
|
354
|
+
expected,
|
|
355
|
+
observed: { mediaId: assertion.mediaId },
|
|
356
|
+
reason: "AUDIO_ANALYZER_UNAVAILABLE",
|
|
357
|
+
detail: `audio analysis is unavailable for media ${assertion.mediaId}`,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const observed = media.audio.integratedLufs;
|
|
361
|
+
const passed = Math.abs(observed - assertion.targetLufs) <= toleranceDb;
|
|
362
|
+
return {
|
|
363
|
+
name: assertion.type,
|
|
364
|
+
passed,
|
|
365
|
+
status: passed ? "passed" : "failed",
|
|
366
|
+
expected,
|
|
367
|
+
observed,
|
|
368
|
+
...(passed ? {} : { reason: "AUDIO_LOUDNESS_OUT_OF_RANGE" }),
|
|
369
|
+
detail: passed
|
|
370
|
+
? `observed ${observed} LUFS within ${toleranceDb} dB of ${assertion.targetLufs} LUFS`
|
|
371
|
+
: `expected ${assertion.targetLufs} LUFS ±${toleranceDb} dB, observed ${observed} LUFS`,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function verifyAudioNoise(transaction, assertion) {
|
|
375
|
+
const expected = {
|
|
376
|
+
mediaId: assertion.mediaId,
|
|
377
|
+
maxNoiseFloorDb: assertion.maxNoiseFloorDb,
|
|
378
|
+
...(assertion.minConfidence !== undefined ? { minConfidence: assertion.minConfidence } : {}),
|
|
379
|
+
};
|
|
380
|
+
const media = transaction.attemptedAfter.media.find((candidate) => candidate.mediaId === assertion.mediaId);
|
|
381
|
+
if (!media) {
|
|
382
|
+
return {
|
|
383
|
+
name: assertion.type,
|
|
384
|
+
passed: false,
|
|
385
|
+
status: "failed",
|
|
386
|
+
expected,
|
|
387
|
+
observed: { mediaId: assertion.mediaId },
|
|
388
|
+
reason: "MEDIA_NOT_FOUND",
|
|
389
|
+
detail: `expected audio media ${assertion.mediaId}, but it was not observed`,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
if (!media.noise) {
|
|
393
|
+
return {
|
|
394
|
+
name: assertion.type,
|
|
395
|
+
passed: false,
|
|
396
|
+
status: "unavailable",
|
|
397
|
+
expected,
|
|
398
|
+
observed: { mediaId: assertion.mediaId },
|
|
399
|
+
reason: "NOISE_ANALYZER_UNAVAILABLE",
|
|
400
|
+
detail: `noise analysis is unavailable for media ${assertion.mediaId}`,
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
const observed = {
|
|
404
|
+
mediaId: assertion.mediaId,
|
|
405
|
+
noiseFloorDb: media.noise.noiseFloorDb,
|
|
406
|
+
confidence: media.noise.confidence,
|
|
407
|
+
affectedRanges: media.noise.affectedRanges,
|
|
408
|
+
valid: media.noise.valid !== false,
|
|
409
|
+
};
|
|
410
|
+
const passed = observed.valid
|
|
411
|
+
&& observed.noiseFloorDb <= assertion.maxNoiseFloorDb
|
|
412
|
+
&& (assertion.minConfidence === undefined || observed.confidence >= assertion.minConfidence);
|
|
413
|
+
return {
|
|
414
|
+
name: assertion.type,
|
|
415
|
+
passed,
|
|
416
|
+
status: passed ? "passed" : "failed",
|
|
417
|
+
expected,
|
|
418
|
+
observed,
|
|
419
|
+
...(passed ? {} : { reason: observed.valid ? "AUDIO_NOISE_OUT_OF_RANGE" : "NOISE_MEASUREMENT_INVALID" }),
|
|
420
|
+
detail: passed
|
|
421
|
+
? `observed noise floor ${observed.noiseFloorDb} dB within the configured limit`
|
|
422
|
+
: `expected noise floor at or below ${assertion.maxNoiseFloorDb} dB with sufficient confidence`,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function verifyAudioSource(transaction, assertion) {
|
|
426
|
+
const expected = {
|
|
427
|
+
mediaId: assertion.mediaId,
|
|
428
|
+
...(assertion.sourceDigest !== undefined ? { sourceDigest: assertion.sourceDigest } : {}),
|
|
429
|
+
...(assertion.source !== undefined ? { source: assertion.source } : {}),
|
|
430
|
+
};
|
|
431
|
+
const media = transaction.attemptedAfter.media.find((candidate) => candidate.mediaId === assertion.mediaId);
|
|
432
|
+
const observed = media
|
|
433
|
+
? {
|
|
434
|
+
mediaId: assertion.mediaId,
|
|
435
|
+
...(media.sourceDigest !== undefined ? { sourceDigest: media.sourceDigest } : {}),
|
|
436
|
+
source: media.source,
|
|
437
|
+
}
|
|
438
|
+
: { mediaId: assertion.mediaId };
|
|
439
|
+
if (!media) {
|
|
440
|
+
return {
|
|
441
|
+
name: assertion.type,
|
|
442
|
+
passed: false,
|
|
443
|
+
status: "failed",
|
|
444
|
+
expected,
|
|
445
|
+
observed,
|
|
446
|
+
reason: "MEDIA_NOT_FOUND",
|
|
447
|
+
detail: `expected source media ${assertion.mediaId}, but it was not observed`,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const passed = (assertion.sourceDigest === undefined || media.sourceDigest === assertion.sourceDigest)
|
|
451
|
+
&& (assertion.source === undefined || media.source === assertion.source)
|
|
452
|
+
&& (assertion.sourceDigest !== undefined || assertion.source !== undefined);
|
|
453
|
+
return {
|
|
454
|
+
name: assertion.type,
|
|
455
|
+
passed,
|
|
456
|
+
status: passed ? "passed" : "failed",
|
|
457
|
+
expected,
|
|
458
|
+
observed,
|
|
459
|
+
...(passed ? {} : { reason: "AUDIO_SOURCE_MISMATCH" }),
|
|
460
|
+
detail: passed
|
|
461
|
+
? `observed the expected source identity for media ${assertion.mediaId}`
|
|
462
|
+
: `expected source identity for media ${assertion.mediaId}, but the observed identity differed`,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
function verifyVisualContent(transaction, assertion) {
|
|
466
|
+
const labelKind = assertion.labelKind ?? "subject";
|
|
467
|
+
const expected = {
|
|
468
|
+
mediaId: assertion.mediaId,
|
|
469
|
+
label: assertion.label,
|
|
470
|
+
labelKind,
|
|
471
|
+
...(assertion.minConfidence !== undefined ? { minConfidence: assertion.minConfidence } : {}),
|
|
472
|
+
};
|
|
473
|
+
const media = transaction.attemptedAfter.media.find((candidate) => candidate.mediaId === assertion.mediaId);
|
|
474
|
+
if (!media) {
|
|
475
|
+
return {
|
|
476
|
+
name: assertion.type,
|
|
477
|
+
passed: false,
|
|
478
|
+
status: "failed",
|
|
479
|
+
expected,
|
|
480
|
+
observed: { mediaId: assertion.mediaId },
|
|
481
|
+
reason: "MEDIA_NOT_FOUND",
|
|
482
|
+
detail: `expected visual media ${assertion.mediaId}, but it was not observed`,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
if (!media.visual) {
|
|
486
|
+
return {
|
|
487
|
+
name: assertion.type,
|
|
488
|
+
passed: false,
|
|
489
|
+
status: "unavailable",
|
|
490
|
+
expected,
|
|
491
|
+
observed: { mediaId: assertion.mediaId },
|
|
492
|
+
reason: "VISUAL_ANALYZER_UNAVAILABLE",
|
|
493
|
+
detail: `visual analysis is unavailable for media ${assertion.mediaId}`,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
const candidates = labelKind === "scene"
|
|
497
|
+
? media.visual.scenes.filter((scene) => scene.label !== undefined).map((scene) => ({
|
|
498
|
+
label: scene.label,
|
|
499
|
+
confidence: scene.confidence ?? 0,
|
|
500
|
+
}))
|
|
501
|
+
: media.visual.subjects.map((subject) => ({ label: subject.label, confidence: subject.confidence }));
|
|
502
|
+
const matching = candidates.find((candidate) => candidate.label.toLowerCase() === assertion.label.toLowerCase());
|
|
503
|
+
const passed = matching !== undefined && matching.confidence >= (assertion.minConfidence ?? 0);
|
|
504
|
+
return {
|
|
505
|
+
name: assertion.type,
|
|
506
|
+
passed,
|
|
507
|
+
status: passed ? "passed" : "failed",
|
|
508
|
+
expected,
|
|
509
|
+
observed: { mediaId: assertion.mediaId, matches: candidates },
|
|
510
|
+
...(passed ? {} : { reason: "VISUAL_CONTENT_NOT_FOUND" }),
|
|
511
|
+
detail: passed
|
|
512
|
+
? `observed ${labelKind} content ${assertion.label} in media ${assertion.mediaId}`
|
|
513
|
+
: `expected ${labelKind} content ${assertion.label} in media ${assertion.mediaId}`,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function verifyColorCorrection(transaction, assertion) {
|
|
517
|
+
const clip = transaction.attemptedAfter.timeline.clips.find((candidate) => candidate.id === assertion.clipId);
|
|
518
|
+
const observed = clip?.colorCorrection;
|
|
519
|
+
const expected = { clipId: assertion.clipId, correction: assertion.expected };
|
|
520
|
+
if (!clip) {
|
|
521
|
+
return {
|
|
522
|
+
name: assertion.type,
|
|
523
|
+
passed: false,
|
|
524
|
+
status: "failed",
|
|
525
|
+
expected,
|
|
526
|
+
observed: { clipId: assertion.clipId },
|
|
527
|
+
reason: "CLIP_NOT_FOUND",
|
|
528
|
+
detail: `expected color correction target ${assertion.clipId}, but it was not observed`,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
const passed = observed !== undefined
|
|
532
|
+
&& observed.exposure === assertion.expected.exposure
|
|
533
|
+
&& observed.contrast === assertion.expected.contrast
|
|
534
|
+
&& observed.saturation === assertion.expected.saturation
|
|
535
|
+
&& observed.temperature === assertion.expected.temperature
|
|
536
|
+
&& observed.tint === assertion.expected.tint
|
|
537
|
+
&& observed.preset === assertion.expected.preset;
|
|
538
|
+
return {
|
|
539
|
+
name: assertion.type,
|
|
540
|
+
passed,
|
|
541
|
+
status: passed ? "passed" : "failed",
|
|
542
|
+
expected,
|
|
543
|
+
observed: { clipId: assertion.clipId, correction: observed },
|
|
544
|
+
...(passed ? {} : { reason: "COLOR_CORRECTION_MISMATCH" }),
|
|
545
|
+
detail: passed
|
|
546
|
+
? `observed the requested color correction on clip ${assertion.clipId}`
|
|
547
|
+
: `the observed color correction on clip ${assertion.clipId} differed from the requested values`,
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function verifyDuration(transaction, assertion) {
|
|
551
|
+
const toleranceSeconds = assertion.toleranceSeconds ?? 0;
|
|
552
|
+
const expected = {
|
|
553
|
+
target: assertion.target,
|
|
554
|
+
expectedSeconds: assertion.expectedSeconds,
|
|
555
|
+
toleranceSeconds,
|
|
556
|
+
};
|
|
557
|
+
const observed = transaction.attemptedAfter.timeline.duration;
|
|
558
|
+
const passed = Math.abs(observed - assertion.expectedSeconds) <= toleranceSeconds;
|
|
559
|
+
return {
|
|
560
|
+
name: assertion.type,
|
|
561
|
+
passed,
|
|
562
|
+
status: passed ? "passed" : "failed",
|
|
563
|
+
expected,
|
|
564
|
+
observed,
|
|
565
|
+
...(passed ? {} : { reason: "DURATION_MISMATCH" }),
|
|
566
|
+
detail: passed
|
|
567
|
+
? `observed timeline duration ${observed}s`
|
|
568
|
+
: `expected timeline duration ${assertion.expectedSeconds}s ±${toleranceSeconds}s, observed ${observed}s`,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function verifyStream(transaction, assertion) {
|
|
572
|
+
const observed = transaction.attemptedAfter.timeline.clips.some((clip) => {
|
|
573
|
+
const media = clip.mediaId
|
|
574
|
+
? transaction.attemptedAfter.media.find((candidate) => candidate.mediaId === clip.mediaId)
|
|
575
|
+
: undefined;
|
|
576
|
+
if (assertion.target === "audio")
|
|
577
|
+
return media?.mediaKind === "audio" || media?.audio !== undefined;
|
|
578
|
+
return media?.mediaKind === "video" || media === undefined;
|
|
579
|
+
});
|
|
580
|
+
const passed = observed === assertion.expected;
|
|
581
|
+
return {
|
|
582
|
+
name: assertion.type,
|
|
583
|
+
passed,
|
|
584
|
+
status: passed ? "passed" : "failed",
|
|
585
|
+
expected: { target: assertion.target, expected: assertion.expected },
|
|
586
|
+
observed,
|
|
587
|
+
...(passed ? {} : { reason: "STREAM_PRESENCE_MISMATCH" }),
|
|
588
|
+
detail: passed
|
|
589
|
+
? `observed ${assertion.target} stream presence ${observed}`
|
|
590
|
+
: `expected ${assertion.target} stream presence ${assertion.expected}, observed ${observed}`,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function verifyStructure(transaction, assertion) {
|
|
594
|
+
const expected = {
|
|
595
|
+
requirement: assertion.requirement,
|
|
596
|
+
...(assertion.mediaId !== undefined ? { mediaId: assertion.mediaId } : {}),
|
|
597
|
+
...(assertion.occurrenceId !== undefined ? { occurrenceId: assertion.occurrenceId } : {}),
|
|
598
|
+
...(assertion.operationType !== undefined ? { operationType: assertion.operationType } : {}),
|
|
599
|
+
};
|
|
600
|
+
let observed = false;
|
|
601
|
+
if (assertion.requirement === "media-present" && assertion.mediaId !== undefined) {
|
|
602
|
+
observed = transaction.attemptedAfter.media.some((media) => media.mediaId === assertion.mediaId);
|
|
603
|
+
}
|
|
604
|
+
if (assertion.requirement === "occurrence-present" && assertion.occurrenceId !== undefined) {
|
|
605
|
+
observed = transaction.attemptedAfter.timeline.clips.some((clip) => clip.id === assertion.occurrenceId);
|
|
606
|
+
}
|
|
607
|
+
if (assertion.requirement === "operation-present" && assertion.operationType !== undefined) {
|
|
608
|
+
observed = transaction.planned.some((operation) => operation.type === assertion.operationType);
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
name: assertion.type,
|
|
612
|
+
passed: observed,
|
|
613
|
+
status: observed ? "passed" : "failed",
|
|
614
|
+
expected,
|
|
615
|
+
observed,
|
|
616
|
+
...(observed ? {} : { reason: "STRUCTURE_EXPECTATION_NOT_MET" }),
|
|
617
|
+
detail: observed ? "observed the expected project structure" : "expected project structure was not observed",
|
|
618
|
+
};
|
|
78
619
|
}
|
|
79
620
|
function audioStateIsValid(transaction) {
|
|
80
621
|
if (transaction.after.timeline.clips.some((clip) => {
|
|
@@ -111,3 +652,173 @@ function audioStateDetail(transaction) {
|
|
|
111
652
|
? "music placement, duration, gain, and fades match the planned audio state"
|
|
112
653
|
: "music placement, duration, gain, or fades do not match the planned audio state";
|
|
113
654
|
}
|
|
655
|
+
function isConstructionOperation(operation) {
|
|
656
|
+
return operation.type === "media.import"
|
|
657
|
+
|| operation.type === "timeline.media.add"
|
|
658
|
+
|| operation.type === "timeline.media.move"
|
|
659
|
+
|| operation.type === "timeline.media.replace"
|
|
660
|
+
|| operation.type === "timeline.media.remove"
|
|
661
|
+
|| operation.type === "timeline.transition.add"
|
|
662
|
+
|| operation.type === "timeline.audio.attach"
|
|
663
|
+
|| operation.type === "timeline.audio.mix";
|
|
664
|
+
}
|
|
665
|
+
function constructionStateIsValid(transaction) {
|
|
666
|
+
const expectedClips = expectedConstructionClips(transaction);
|
|
667
|
+
return transaction.planned.every((operation) => {
|
|
668
|
+
if (operation.type === "media.import") {
|
|
669
|
+
const media = transaction.after.media.find((candidate) => candidate.mediaId === operation.mediaId);
|
|
670
|
+
return media?.source === operation.source
|
|
671
|
+
&& media.mediaKind === operation.mediaKind
|
|
672
|
+
&& media.duration === operation.duration
|
|
673
|
+
&& media.sourceDigest === operation.sourceDigest;
|
|
674
|
+
}
|
|
675
|
+
if (operation.type === "timeline.media.add"
|
|
676
|
+
|| operation.type === "timeline.media.move"
|
|
677
|
+
|| operation.type === "timeline.media.replace"
|
|
678
|
+
|| operation.type === "timeline.media.remove"
|
|
679
|
+
|| operation.type === "timeline.audio.attach") {
|
|
680
|
+
const expected = expectedClips.get(operation.occurrenceId);
|
|
681
|
+
const actual = transaction.after.timeline.clips.find((candidate) => candidate.id === operation.occurrenceId);
|
|
682
|
+
return expected === undefined ? actual === undefined : actual !== undefined && sameConstructionClip(actual, expected);
|
|
683
|
+
}
|
|
684
|
+
if (operation.type === "timeline.transition.add") {
|
|
685
|
+
const element = transaction.after.timeline.storyElements.find(({ id }) => id === operation.transitionId);
|
|
686
|
+
return element?.kind === "transition"
|
|
687
|
+
&& element.assetId === operation.assetId
|
|
688
|
+
&& element.beforeClipId === operation.beforeClipId
|
|
689
|
+
&& element.afterClipId === operation.afterClipId
|
|
690
|
+
&& element.duration === operation.duration;
|
|
691
|
+
}
|
|
692
|
+
if (operation.type === "timeline.audio.mix") {
|
|
693
|
+
const clip = transaction.after.timeline.clips.find((candidate) => candidate.id === operation.clipId);
|
|
694
|
+
return clip !== undefined
|
|
695
|
+
&& (operation.gainDb === undefined || clip.gainDb === operation.gainDb)
|
|
696
|
+
&& (operation.fadeIn === undefined || clip.fadeIn === operation.fadeIn)
|
|
697
|
+
&& (operation.fadeOut === undefined || clip.fadeOut === operation.fadeOut);
|
|
698
|
+
}
|
|
699
|
+
return true;
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function constructionStateDetail(transaction) {
|
|
703
|
+
return constructionStateIsValid(transaction)
|
|
704
|
+
? "imported media and timeline construction operations match the requested state"
|
|
705
|
+
: "imported media or timeline construction operations do not match the requested state";
|
|
706
|
+
}
|
|
707
|
+
function timelineTrack(targetLane, fallback) {
|
|
708
|
+
return targetLane === "primary" ? 0 : targetLane ?? fallback;
|
|
709
|
+
}
|
|
710
|
+
function expectedConstructionClips(transaction) {
|
|
711
|
+
const clips = new Map(transaction.before.timeline.clips.map((clip) => [clip.id, {
|
|
712
|
+
mediaId: clip.mediaId,
|
|
713
|
+
start: clip.start,
|
|
714
|
+
duration: clip.duration,
|
|
715
|
+
track: clip.track,
|
|
716
|
+
attachedTo: clip.attachedTo,
|
|
717
|
+
}]));
|
|
718
|
+
const media = new Map(transaction.before.media.map((item) => [item.mediaId, item]));
|
|
719
|
+
for (const operation of transaction.planned) {
|
|
720
|
+
if (operation.type === "media.import") {
|
|
721
|
+
media.set(operation.mediaId, operation);
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
if (operation.type === "timeline.media.add") {
|
|
725
|
+
clips.set(operation.occurrenceId, {
|
|
726
|
+
mediaId: operation.mediaId,
|
|
727
|
+
start: operation.start,
|
|
728
|
+
duration: operation.duration,
|
|
729
|
+
track: timelineTrack(operation.targetLane, 0),
|
|
730
|
+
});
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
if (operation.type === "timeline.title.add") {
|
|
734
|
+
clips.set(operation.occurrenceId, {
|
|
735
|
+
start: operation.start,
|
|
736
|
+
duration: operation.duration,
|
|
737
|
+
track: operation.targetLane,
|
|
738
|
+
});
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
if (operation.type === "timeline.media.move") {
|
|
742
|
+
const clip = clips.get(operation.occurrenceId);
|
|
743
|
+
if (clip) {
|
|
744
|
+
clip.start = operation.start;
|
|
745
|
+
clip.track = timelineTrack(operation.targetLane, clip.track);
|
|
746
|
+
}
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
if (operation.type === "timeline.media.replace") {
|
|
750
|
+
const clip = clips.get(operation.occurrenceId);
|
|
751
|
+
if (clip) {
|
|
752
|
+
clip.mediaId = operation.mediaId;
|
|
753
|
+
if (operation.duration !== undefined)
|
|
754
|
+
clip.duration = operation.duration;
|
|
755
|
+
}
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
if (operation.type === "trim-clip") {
|
|
759
|
+
const clip = clips.get(operation.clipId);
|
|
760
|
+
if (clip) {
|
|
761
|
+
clip.duration = operation.durationTime
|
|
762
|
+
? Number(operation.durationTime.value) / Number(operation.durationTime.timescale)
|
|
763
|
+
: operation.duration;
|
|
764
|
+
}
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
if (operation.type === "timeline.audio.attach") {
|
|
768
|
+
const target = clips.get(operation.targetClipId);
|
|
769
|
+
const source = media.get(operation.mediaId);
|
|
770
|
+
const duration = operation.duration ?? source?.duration;
|
|
771
|
+
if (target && duration !== undefined) {
|
|
772
|
+
clips.set(operation.occurrenceId, {
|
|
773
|
+
mediaId: operation.mediaId,
|
|
774
|
+
start: target.start + (operation.startOffset ?? 0),
|
|
775
|
+
duration,
|
|
776
|
+
track: -1,
|
|
777
|
+
attachedTo: operation.targetClipId,
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (operation.type === "timeline.media.remove") {
|
|
783
|
+
const removedIds = new Set([operation.occurrenceId]);
|
|
784
|
+
for (const [id, clip] of clips) {
|
|
785
|
+
if (clip.attachedTo === operation.occurrenceId)
|
|
786
|
+
removedIds.add(id);
|
|
787
|
+
}
|
|
788
|
+
for (const id of removedIds)
|
|
789
|
+
clips.delete(id);
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
if (operation.type === "ripple-delete") {
|
|
793
|
+
applyExpectedRippleDelete(clips, operation.range.start, operation.range.end);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return clips;
|
|
797
|
+
}
|
|
798
|
+
function sameConstructionClip(actual, expected) {
|
|
799
|
+
return actual.mediaId === expected.mediaId
|
|
800
|
+
&& actual.start === expected.start
|
|
801
|
+
&& actual.duration === expected.duration
|
|
802
|
+
&& actual.track === expected.track
|
|
803
|
+
&& actual.attachedTo === expected.attachedTo;
|
|
804
|
+
}
|
|
805
|
+
function applyExpectedRippleDelete(clips, start, end) {
|
|
806
|
+
const removedDuration = end - start;
|
|
807
|
+
for (const [id, clip] of clips) {
|
|
808
|
+
const clipEnd = clip.start + clip.duration;
|
|
809
|
+
if (clipEnd <= start)
|
|
810
|
+
continue;
|
|
811
|
+
if (clip.start >= end) {
|
|
812
|
+
clip.start -= removedDuration;
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
const overlap = Math.min(clipEnd, end) - Math.max(clip.start, start);
|
|
816
|
+
clip.duration -= overlap;
|
|
817
|
+
if (clip.duration <= 0) {
|
|
818
|
+
clips.delete(id);
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
clip.start = clip.start < start ? clip.start : start;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|