makaron-cli 0.17.0 → 0.18.0
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/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +5 -4
- package/README.md +47 -1
- package/bin/makaron.mjs +22 -8
- package/craft/manifest.json +2877 -0
- package/craft/prompts/agent-coding.md +220 -0
- package/craft/prompts/agent.md +86 -0
- package/craft/prompts/animate.md +448 -0
- package/craft/prompts/audio.md +261 -0
- package/craft/prompts/captions.md +220 -0
- package/craft/prompts/coding-submission.md +31 -0
- package/craft/prompts/coding-workflow.md +26 -0
- package/craft/prompts/creative.md +108 -0
- package/craft/prompts/cutout.md +81 -0
- package/craft/prompts/enhance.md +123 -0
- package/craft/prompts/generate_image_tool.md +26 -0
- package/craft/prompts/image.md +222 -0
- package/craft/prompts/legacy/agent.md +123 -0
- package/craft/prompts/legacy/coding-tool.md +31 -0
- package/craft/prompts/legacy/video-tool.md +38 -0
- package/craft/prompts/legacy/workspace-authoring.md +13 -0
- package/craft/prompts/niji.md +117 -0
- package/craft/prompts/pony_translate.md +42 -0
- package/craft/prompts/remotion-composition.md +405 -0
- package/craft/prompts/video-reverse.md +170 -0
- package/craft/prompts/video-submission.md +44 -0
- package/craft/prompts/video-workflow.md +42 -0
- package/craft/prompts/wai_translate.md +28 -0
- package/craft/prompts/web-search.md +1 -0
- package/craft/prompts/wild.md +119 -0
- package/craft/prompts/workspace-authoring.md +13 -0
- package/craft/skills/SKILL_README.md +249 -0
- package/craft/skills/_shared/aesthetic-lens-contract.md +68 -0
- package/craft/skills/_shared/native-audiovisual.md +44 -0
- package/craft/skills/_shared/remotion-director-contract.md +133 -0
- package/craft/skills/_shared/remotion-video-director/README.md +140 -0
- package/craft/skills/_shared/remotion-video-director/SKILL.md +391 -0
- package/craft/skills/_shared/remotion-video-director/references/component-library.md +608 -0
- package/craft/skills/_shared/remotion-video-director/references/expert-definitions.md +214 -0
- package/craft/skills/_shared/remotion-video-director/references/music-and-audio.md +186 -0
- package/craft/skills/_shared/remotion-video-director/references/remotion-patterns.md +439 -0
- package/craft/skills/_shared/remotion-video-director/references/video-archetypes.md +395 -0
- package/craft/skills/_shared/speech-clock.md +63 -0
- package/craft/skills/_shared/spoken-caption.md +75 -0
- package/craft/skills/_shared/studio-production/audio-direction.md +60 -0
- package/craft/skills/_shared/studio-production/production-contract.md +188 -0
- package/craft/skills/_shared/studio-production/reference-analysis.md +37 -0
- package/craft/skills/_shared/studio-production/review-contract.md +77 -0
- package/craft/skills/_shared/studio-production/taste-direction.md +114 -0
- package/craft/skills/_shared/visual-asset-bridge/SKILL.md +57 -0
- package/craft/skills/_shared/visual-direction/SKILL.md +98 -0
- package/craft/skills/_shared/voice-translation.md +55 -0
- package/craft/skills/aesthetic-disney-character-motion/SKILL.md +66 -0
- package/craft/skills/aesthetic-lottiefiles-motion/SKILL.md +78 -0
- package/craft/skills/aesthetic-rampstack-direction/SKILL.md +68 -0
- package/craft/skills/ai-video-gen/SKILL.md +48 -0
- package/craft/skills/animated-explainer/SKILL.md +53 -0
- package/craft/skills/animation/SKILL.md +53 -0
- package/craft/skills/avatar-spokesperson/SKILL.md +66 -0
- package/craft/skills/canvas-procedural-animation/SKILL.md +48 -0
- package/craft/skills/character-animation/SKILL.md +57 -0
- package/craft/skills/character-animation-qa/SKILL.md +48 -0
- package/craft/skills/character-rigging/SKILL.md +48 -0
- package/craft/skills/cinematic/SKILL.md +53 -0
- package/craft/skills/cinematic-video/SKILL.md +65 -0
- package/craft/skills/clip-factory/SKILL.md +53 -0
- package/craft/skills/comfyui/SKILL.md +48 -0
- package/craft/skills/content-repurpose/SKILL.md +54 -0
- package/craft/skills/create-video/SKILL.md +48 -0
- package/craft/skills/documentary-montage/SKILL.md +53 -0
- package/craft/skills/doubao-tts/SKILL.md +51 -0
- package/craft/skills/explainer-aesthetic-disney/SKILL.md +33 -0
- package/craft/skills/explainer-aesthetic-lottiefiles/SKILL.md +33 -0
- package/craft/skills/explainer-aesthetic-rampstack/SKILL.md +33 -0
- package/craft/skills/explainer-video/SKILL.md +423 -0
- package/craft/skills/ffmpeg/SKILL.md +48 -0
- package/craft/skills/grok-media/SKILL.md +47 -0
- package/craft/skills/hybrid/SKILL.md +53 -0
- package/craft/skills/localization-dub/SKILL.md +59 -0
- package/craft/skills/long-video-anchor/SKILL.md +111 -0
- package/craft/skills/long-video-director/SKILL.md +217 -0
- package/craft/skills/long-video-storyboard/SKILL.md +102 -0
- package/craft/skills/makaron-mascot/SKILL.md +83 -0
- package/craft/skills/makaron-mascot/assets/character-sheet.jpg +0 -0
- package/craft/skills/makaron-mascot/assets/makaron-spark-pixel-wizard-concepts.png +0 -0
- package/craft/skills/media-use/SKILL.md +47 -0
- package/craft/skills/motion-design-video/SKILL.md +64 -0
- package/craft/skills/motion-graphics/SKILL.md +48 -0
- package/craft/skills/multi-angle-video/SKILL.md +533 -0
- package/craft/skills/music/SKILL.md +47 -0
- package/craft/skills/music-to-video/SKILL.md +60 -0
- package/craft/skills/photo-to-video/SKILL.md +60 -0
- package/craft/skills/podcast-repurpose/SKILL.md +53 -0
- package/craft/skills/pose-library-design/SKILL.md +48 -0
- package/craft/skills/reference-video-studio/SKILL.md +55 -0
- package/craft/skills/remotion/SKILL.md +48 -0
- package/craft/skills/remotion-best-practices/SKILL.md +48 -0
- package/craft/skills/screen-demo/SKILL.md +61 -0
- package/craft/skills/seedance-2-0/SKILL.md +48 -0
- package/craft/skills/seedance-2-5/SKILL.md +48 -0
- package/craft/skills/sound-effects/SKILL.md +47 -0
- package/craft/skills/source-video-studio/SKILL.md +68 -0
- package/craft/skills/speech-to-text/SKILL.md +47 -0
- package/craft/skills/sticker-maker/SKILL.md +178 -0
- package/craft/skills/svg-character-animation/SKILL.md +48 -0
- package/craft/skills/synthetic-screen-recording/SKILL.md +48 -0
- package/craft/skills/talking-head/SKILL.md +106 -0
- package/craft/skills/text-to-speech/SKILL.md +50 -0
- package/craft/skills/threejs-animation/SKILL.md +48 -0
- package/craft/skills/threejs-fundamentals/SKILL.md +48 -0
- package/craft/skills/threejs-geometry/SKILL.md +48 -0
- package/craft/skills/threejs-lighting/SKILL.md +48 -0
- package/craft/skills/threejs-materials/SKILL.md +48 -0
- package/craft/skills/threejs-shaders/SKILL.md +48 -0
- package/craft/skills/threejs-textures/SKILL.md +48 -0
- package/craft/skills/tiktok-video/SKILL.md +188 -0
- package/craft/skills/tiktok-video/references/audio-sync.md +58 -0
- package/craft/skills/tiktok-video/references/caption-direction.md +36 -0
- package/craft/skills/tiktok-video/references/delivery-qa.md +84 -0
- package/craft/skills/tiktok-video/references/platform-layout.md +62 -0
- package/craft/skills/video-edit/SKILL.md +144 -0
- package/craft/skills/video-edit/references/direct-reference-route.md +141 -0
- package/craft/skills/video-edit/references/editing-protocol.md +79 -0
- package/craft/skills/video-edit/references/frame-location.md +85 -0
- package/craft/skills/video-edit/references/replication-protocol.md +67 -0
- package/craft/skills/video-edit/references/shot-blueprint.md +116 -0
- package/craft/skills/video-edit/references/shot-blueprint.schema.json +143 -0
- package/craft/skills/video-edit/references/similarity-qa.md +47 -0
- package/craft/skills/video-edit/scripts/extract-shot-blueprint.mjs +313 -0
- package/craft/skills/video-ffmpeg-lab/SKILL.md +220 -0
- package/craft/skills/video-mature-themes/SKILL.md +175 -0
- package/craft/skills/video-segment-edit/SKILL.md +16 -0
- package/craft/skills/video-translate/SKILL.md +148 -0
- package/craft/skills/video-understand/SKILL.md +48 -0
- package/craft/skills/visual-style/SKILL.md +47 -0
- package/craft/skills/wan-3-0/SKILL.md +59 -0
- package/craft/skills/web-design-guidelines/SKILL.md +47 -0
- package/craft/skills/website-to-video/SKILL.md +61 -0
- package/craft-source.json +7 -0
- package/package.json +12 -5
- package/runtime/adapter.mjs +615 -0
- package/runtime/configure.mjs +28 -0
- package/runtime/tool-catalog.json +807 -0
- package/runtime/tool-cli.mjs +98 -0
- package/skills/makaron/SKILL.md +12 -0
- package/skills/makaron-native/SKILL.md +89 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://makaron.ai/schemas/shot-blueprint-0.1.0.json",
|
|
4
|
+
"title": "Makaron Shot Blueprint",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schema_version", "reference", "analysis", "global_dna", "boundaries", "shots", "route", "qa_targets"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schema_version": { "const": "0.1.0" },
|
|
10
|
+
"reference": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"additionalProperties": false,
|
|
13
|
+
"required": ["source_name", "duration_sec", "width", "height", "fps", "video_codec", "audio"],
|
|
14
|
+
"properties": {
|
|
15
|
+
"source_name": { "type": "string", "minLength": 1 },
|
|
16
|
+
"duration_sec": { "type": "number", "exclusiveMinimum": 0 },
|
|
17
|
+
"width": { "type": "integer", "minimum": 1 },
|
|
18
|
+
"height": { "type": "integer", "minimum": 1 },
|
|
19
|
+
"fps": { "type": "number", "exclusiveMinimum": 0 },
|
|
20
|
+
"video_codec": { "type": ["string", "null"] },
|
|
21
|
+
"audio": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"additionalProperties": false,
|
|
24
|
+
"required": ["present", "codec", "sample_rate"],
|
|
25
|
+
"properties": {
|
|
26
|
+
"present": { "type": "boolean" },
|
|
27
|
+
"codec": { "type": ["string", "null"] },
|
|
28
|
+
"sample_rate": { "type": ["integer", "null"], "minimum": 1 }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"analysis": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"required": ["boundary_method", "asr_status", "beat_status", "model_review_status", "unresolved_boundary_candidates", "warnings"],
|
|
37
|
+
"properties": {
|
|
38
|
+
"boundary_method": { "type": "string" },
|
|
39
|
+
"asr_status": { "enum": ["not_run", "complete", "failed", "not_applicable"] },
|
|
40
|
+
"beat_status": { "enum": ["not_run", "complete", "failed", "not_applicable"] },
|
|
41
|
+
"model_review_status": { "enum": ["required", "complete", "failed"] },
|
|
42
|
+
"scene_score_threshold": { "type": "number", "minimum": 0 },
|
|
43
|
+
"scene_candidate_count": { "type": "integer", "minimum": 0 },
|
|
44
|
+
"black_candidate_count": { "type": "integer", "minimum": 0 },
|
|
45
|
+
"unresolved_boundary_candidates": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"items": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"required": ["time_sec", "kind", "confidence", "evidence"],
|
|
50
|
+
"properties": {
|
|
51
|
+
"time_sec": { "type": "number", "minimum": 0 },
|
|
52
|
+
"kind": { "enum": ["cut", "fade_or_black", "dissolve", "unknown"] },
|
|
53
|
+
"confidence": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
54
|
+
"evidence": { "type": "array", "items": { "type": "object" } }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"warnings": { "type": "array", "items": { "type": "string" } }
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"global_dna": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"required": ["aspect_ratio", "shot_duration_curve_sec", "cut_rate_per_min", "style", "audio_arc"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"aspect_ratio": { "type": "string", "pattern": "^[1-9][0-9]*:[1-9][0-9]*$" },
|
|
67
|
+
"shot_duration_curve_sec": { "type": "array", "items": { "type": "number", "exclusiveMinimum": 0 } },
|
|
68
|
+
"cut_rate_per_min": { "type": "number", "minimum": 0 },
|
|
69
|
+
"style": { "type": ["object", "null"] },
|
|
70
|
+
"audio_arc": { "type": ["object", "null"] }
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"boundaries": {
|
|
74
|
+
"type": "array",
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"additionalProperties": false,
|
|
78
|
+
"required": ["time_sec", "kind", "confidence", "evidence"],
|
|
79
|
+
"properties": {
|
|
80
|
+
"time_sec": { "type": "number", "minimum": 0 },
|
|
81
|
+
"kind": { "enum": ["cut", "fade_or_black", "dissolve", "unknown"] },
|
|
82
|
+
"confidence": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
83
|
+
"evidence": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"minItems": 1,
|
|
86
|
+
"items": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"additionalProperties": false,
|
|
89
|
+
"required": ["method", "time_sec"],
|
|
90
|
+
"properties": {
|
|
91
|
+
"method": { "type": "string" },
|
|
92
|
+
"time_sec": { "type": "number", "minimum": 0 },
|
|
93
|
+
"score": { "type": "number", "minimum": 0 },
|
|
94
|
+
"start_sec": { "type": "number", "minimum": 0 },
|
|
95
|
+
"end_sec": { "type": "number", "minimum": 0 },
|
|
96
|
+
"frame_index": { "type": "integer", "minimum": 0 },
|
|
97
|
+
"note": { "type": "string" }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"shots": {
|
|
105
|
+
"type": "array",
|
|
106
|
+
"minItems": 1,
|
|
107
|
+
"items": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": false,
|
|
110
|
+
"required": ["id", "order", "source_range", "duration_sec", "narrative_role", "subject_action", "composition", "camera_motion", "transition_in", "transition_out", "text_layers", "audio", "style", "preserve", "replace", "confidence", "needs_model_review"],
|
|
111
|
+
"properties": {
|
|
112
|
+
"id": { "type": "string", "pattern": "^shot-[0-9]{3,}$" },
|
|
113
|
+
"order": { "type": "integer", "minimum": 1 },
|
|
114
|
+
"source_range": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"required": ["start_sec", "end_sec"],
|
|
118
|
+
"properties": {
|
|
119
|
+
"start_sec": { "type": "number", "minimum": 0 },
|
|
120
|
+
"end_sec": { "type": "number", "exclusiveMinimum": 0 }
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"duration_sec": { "type": "number", "exclusiveMinimum": 0 },
|
|
124
|
+
"narrative_role": { "type": ["string", "null"] },
|
|
125
|
+
"subject_action": { "type": ["string", "null"] },
|
|
126
|
+
"composition": { "type": ["object", "null"] },
|
|
127
|
+
"camera_motion": { "type": ["object", "null"] },
|
|
128
|
+
"transition_in": { "type": ["object", "null"] },
|
|
129
|
+
"transition_out": { "type": ["object", "null"] },
|
|
130
|
+
"text_layers": { "type": "array", "items": { "type": "object" } },
|
|
131
|
+
"audio": { "type": ["object", "null"] },
|
|
132
|
+
"style": { "type": ["object", "null"] },
|
|
133
|
+
"preserve": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
|
|
134
|
+
"replace": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
|
|
135
|
+
"confidence": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
136
|
+
"needs_model_review": { "type": "boolean" }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"route": { "type": ["object", "null"] },
|
|
141
|
+
"qa_targets": { "type": ["object", "null"] }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Video Replication Similarity QA
|
|
2
|
+
|
|
3
|
+
Acceptance is a vector, never one opaque "looks similar" score. Before
|
|
4
|
+
materialization, save available measurements, thresholds, and visual evidence in
|
|
5
|
+
the Studio Run Composition artifact. Normalize comparisons to the locked
|
|
6
|
+
reference/output FPS and dimensions. Final encoded-file metrics require a
|
|
7
|
+
durable post-export verifier; until it exists, mark them `unverified`.
|
|
8
|
+
|
|
9
|
+
## P0 Gates
|
|
10
|
+
|
|
11
|
+
| Dimension | Machine measure | Suggested P0 gate |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| File truth | proposed post-export FFprobe plus full decode to a null sink | MP4 decodes; expected H.264/AAC or intentional no-audio; duration error <= 1 output frame |
|
|
14
|
+
| Shot count/order | matched monotonic boundary sequence | exact count and order for route A; generated shots may be flagged rather than hidden |
|
|
15
|
+
| Boundary timing | median and P95 absolute boundary error | median <= 2 frames; P95 <= 5 frames for deterministic edits |
|
|
16
|
+
| Duration curve | mean absolute percentage error per matched shot | <= 5% for deterministic edits; report provider-originated misses separately |
|
|
17
|
+
| Cut/transition | class match plus transition duration error | exact class for hard cut/fade; duration error <= 3 frames |
|
|
18
|
+
| Caption timing/layout | cue start/end error, text box IoU, baseline/size deltas | timing <= 2 frames; IoU >= 0.85 for deterministic overlays |
|
|
19
|
+
| Beat alignment | nearest beat/onset distance for locked edit events | median <= 50 ms; P95 <= 100 ms |
|
|
20
|
+
| Composition | subject box center/scale, horizon and salient-point deltas | center <= 5% frame diagonal; scale error <= 10% after allowed replacement |
|
|
21
|
+
| Camera/motion | global-motion direction, magnitude curve, optical-flow trajectory | direction match and normalized curve correlation >= 0.8 when measurable |
|
|
22
|
+
| Color/style | palette distance and luminance/contrast distribution | report Delta E / histogram distance; threshold is project-specific |
|
|
23
|
+
|
|
24
|
+
For route B/C, calculate structural metrics on the final Remotion timeline and
|
|
25
|
+
visual metrics on each generated shot. Do not average away a failed hook,
|
|
26
|
+
identity error, broken hand, unreadable caption, or seam discontinuity.
|
|
27
|
+
|
|
28
|
+
## Repair Loop
|
|
29
|
+
|
|
30
|
+
1. Classify every miss as `timeline`, `asset_map`, `generated_pixels`,
|
|
31
|
+
`caption`, `audio`, or `file`.
|
|
32
|
+
2. Patch timeline/caption/audio/file misses deterministically first.
|
|
33
|
+
3. Re-map a source asset before generating a replacement.
|
|
34
|
+
4. Re-generate only the failing shot, with the measured delta in the prompt or
|
|
35
|
+
reference plan. One blind reroll is not a correction.
|
|
36
|
+
5. Stop the batch when the representative shot fails its threshold or the
|
|
37
|
+
approved attempt/cost ceiling is reached.
|
|
38
|
+
|
|
39
|
+
## Dimensions That Cannot Be Guaranteed
|
|
40
|
+
|
|
41
|
+
No current provider can guarantee pixel identity, exact stochastic camera
|
|
42
|
+
trajectory, actor performance, occluded geometry, physics, lip-sync, or
|
|
43
|
+
sample-accurate music generation from an arbitrary reference. A model also
|
|
44
|
+
cannot recover hidden lenses, rigs, edits, or author intent from pixels alone.
|
|
45
|
+
Copyright, publicity, trademark, and music rights are legal/provenance gates,
|
|
46
|
+
not similarity metrics. Report these limitations instead of converting them
|
|
47
|
+
into a false pass score.
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
4
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { basename, join, resolve } from 'node:path';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
|
|
8
|
+
const round = (value, places = 3) => Number(value.toFixed(places));
|
|
9
|
+
|
|
10
|
+
function usage() {
|
|
11
|
+
return 'Usage: node extract-shot-blueprint.mjs <input.mp4> --output <blueprint.json> [--ffmpeg PATH] [--ffprobe PATH]';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function parseArgs(argv) {
|
|
15
|
+
if (argv.includes('--help') || argv.includes('-h')) return { help: true };
|
|
16
|
+
const input = argv[0];
|
|
17
|
+
const outputIndex = argv.indexOf('--output');
|
|
18
|
+
if (!input || outputIndex < 0 || !argv[outputIndex + 1]) {
|
|
19
|
+
throw new Error(usage());
|
|
20
|
+
}
|
|
21
|
+
const valueAfter = (flag, fallback) => {
|
|
22
|
+
const index = argv.indexOf(flag);
|
|
23
|
+
return index >= 0 && argv[index + 1] ? argv[index + 1] : fallback;
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
input: resolve(input),
|
|
27
|
+
output: resolve(argv[outputIndex + 1]),
|
|
28
|
+
ffmpeg: valueAfter('--ffmpeg', 'ffmpeg'),
|
|
29
|
+
ffprobe: valueAfter('--ffprobe', 'ffprobe'),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function run(binary, args, options = {}) {
|
|
34
|
+
try {
|
|
35
|
+
return execFileSync(binary, args, {
|
|
36
|
+
encoding: 'utf8',
|
|
37
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
38
|
+
...options,
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
const stderr = error?.stderr?.toString?.() || error?.message || String(error);
|
|
42
|
+
throw new Error(`${binary} failed: ${stderr.trim()}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function rational(value) {
|
|
47
|
+
if (!value || typeof value !== 'string') return null;
|
|
48
|
+
const [numerator, denominator] = value.split('/').map(Number);
|
|
49
|
+
if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator === 0) return null;
|
|
50
|
+
return numerator / denominator;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function percentile(values, fraction) {
|
|
54
|
+
if (!values.length) return 0;
|
|
55
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
56
|
+
const index = Math.min(sorted.length - 1, Math.max(0, Math.floor((sorted.length - 1) * fraction)));
|
|
57
|
+
return sorted[index];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function parseSceneScores(metadataText) {
|
|
61
|
+
const frames = [];
|
|
62
|
+
let currentTime = null;
|
|
63
|
+
for (const line of metadataText.split(/\r?\n/)) {
|
|
64
|
+
const frame = line.match(/pts_time:([0-9.]+)/);
|
|
65
|
+
if (frame) currentTime = Number(frame[1]);
|
|
66
|
+
const score = line.match(/lavfi\.scene_score=([0-9.]+)/);
|
|
67
|
+
if (score && Number.isFinite(currentTime)) {
|
|
68
|
+
frames.push({ time_sec: currentTime, score: Number(score[1]) });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return frames;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sceneCandidates(frames, duration) {
|
|
75
|
+
const positive = frames.map((frame) => frame.score).filter((score) => score > 0);
|
|
76
|
+
const adaptiveThreshold = Math.max(0.001, percentile(positive, 0.985));
|
|
77
|
+
const threshold = Math.min(0.02, adaptiveThreshold);
|
|
78
|
+
const candidates = [];
|
|
79
|
+
for (let index = 1; index < frames.length - 1; index += 1) {
|
|
80
|
+
const frame = frames[index];
|
|
81
|
+
if (frame.score < threshold) continue;
|
|
82
|
+
if (frame.score < frames[index - 1].score || frame.score < frames[index + 1].score) continue;
|
|
83
|
+
if (frame.time_sec < 0.75 || duration - frame.time_sec < 0.75) continue;
|
|
84
|
+
candidates.push({
|
|
85
|
+
method: 'adaptive_scene_score',
|
|
86
|
+
time_sec: round(frame.time_sec),
|
|
87
|
+
score: round(frame.score, 6),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return { threshold: round(threshold, 6), candidates };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function parseBlackRanges(stderrText, duration) {
|
|
94
|
+
const ranges = [];
|
|
95
|
+
const pattern = /black_start:([0-9.]+)\s+black_end:([0-9.]+)\s+black_duration:([0-9.]+)/g;
|
|
96
|
+
for (const match of stderrText.matchAll(pattern)) {
|
|
97
|
+
const start = Number(match[1]);
|
|
98
|
+
const end = Number(match[2]);
|
|
99
|
+
const span = Number(match[3]);
|
|
100
|
+
if (start <= 0.05 || duration - end <= 0.05 || span > 2.5) continue;
|
|
101
|
+
ranges.push({
|
|
102
|
+
method: 'blackdetect',
|
|
103
|
+
time_sec: round((start + end) / 2),
|
|
104
|
+
start_sec: round(start),
|
|
105
|
+
end_sec: round(end),
|
|
106
|
+
score: round(Math.min(1, span / 1.5), 6),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return ranges;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function boundarySets(sceneEvidence, blackEvidence, duration) {
|
|
113
|
+
const scenes = sceneEvidence.filter((item) => item.time_sec >= 0.1 && duration - item.time_sec >= 0.1);
|
|
114
|
+
const consumedSceneIndices = new Set();
|
|
115
|
+
const candidates = blackEvidence.map((black) => {
|
|
116
|
+
const nearby = scenes.filter((scene, index) => {
|
|
117
|
+
const withinSpan = scene.time_sec >= black.start_sec - 0.5 && scene.time_sec <= black.end_sec + 0.5;
|
|
118
|
+
if (withinSpan) consumedSceneIndices.add(index);
|
|
119
|
+
return withinSpan;
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
time_sec: black.time_sec,
|
|
123
|
+
kind: 'fade_or_black',
|
|
124
|
+
confidence: nearby.length ? 0.7 : 0.6,
|
|
125
|
+
evidence: [black, ...nearby],
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
scenes.forEach((scene, index) => {
|
|
130
|
+
if (consumedSceneIndices.has(index)) return;
|
|
131
|
+
const strongCut = scene.score >= 0.02;
|
|
132
|
+
candidates.push({
|
|
133
|
+
time_sec: scene.time_sec,
|
|
134
|
+
kind: strongCut ? 'cut' : 'unknown',
|
|
135
|
+
confidence: strongCut ? (scene.score >= 0.08 ? 0.75 : 0.65) : 0.45,
|
|
136
|
+
evidence: [scene],
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const sorted = candidates.sort((left, right) => left.time_sec - right.time_sec);
|
|
141
|
+
const deduped = [];
|
|
142
|
+
for (const candidate of sorted) {
|
|
143
|
+
const previous = deduped.at(-1);
|
|
144
|
+
if (previous && candidate.time_sec - previous.time_sec < 0.1) {
|
|
145
|
+
if (candidate.confidence > previous.confidence) deduped[deduped.length - 1] = candidate;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
deduped.push(candidate);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
confirmed: deduped.filter((candidate) => candidate.confidence >= 0.6),
|
|
152
|
+
unresolved: deduped.filter((candidate) => candidate.confidence < 0.6),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function gcd(left, right) {
|
|
157
|
+
let a = Math.abs(left);
|
|
158
|
+
let b = Math.abs(right);
|
|
159
|
+
while (b) [a, b] = [b, a % b];
|
|
160
|
+
return a || 1;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function buildBlueprint(probe, sourceName, sceneResult, blackEvidence) {
|
|
164
|
+
const video = probe.streams.find((stream) => stream.codec_type === 'video');
|
|
165
|
+
if (!video) throw new Error('The source has no video stream.');
|
|
166
|
+
const audio = probe.streams.find((stream) => stream.codec_type === 'audio');
|
|
167
|
+
const duration = Number(probe.format?.duration || video.duration);
|
|
168
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('The source duration is missing or invalid.');
|
|
169
|
+
const width = Number(video.width);
|
|
170
|
+
const height = Number(video.height);
|
|
171
|
+
const divisor = gcd(width, height);
|
|
172
|
+
const boundaryResult = boundarySets(sceneResult.candidates, blackEvidence, duration);
|
|
173
|
+
const boundaries = boundaryResult.confirmed.map((boundary) => ({
|
|
174
|
+
...boundary,
|
|
175
|
+
confidence: round(boundary.confidence, 2),
|
|
176
|
+
}));
|
|
177
|
+
const unresolvedCandidates = boundaryResult.unresolved.map((boundary) => ({
|
|
178
|
+
...boundary,
|
|
179
|
+
confidence: round(boundary.confidence, 2),
|
|
180
|
+
}));
|
|
181
|
+
const times = [0, ...boundaries.map((boundary) => boundary.time_sec), round(duration)];
|
|
182
|
+
const shots = times.slice(0, -1).map((start, index) => {
|
|
183
|
+
const end = times[index + 1];
|
|
184
|
+
return {
|
|
185
|
+
id: `shot-${String(index + 1).padStart(3, '0')}`,
|
|
186
|
+
order: index + 1,
|
|
187
|
+
source_range: { start_sec: round(start), end_sec: round(end) },
|
|
188
|
+
duration_sec: round(end - start),
|
|
189
|
+
narrative_role: null,
|
|
190
|
+
subject_action: null,
|
|
191
|
+
composition: null,
|
|
192
|
+
camera_motion: null,
|
|
193
|
+
transition_in: null,
|
|
194
|
+
transition_out: null,
|
|
195
|
+
text_layers: [],
|
|
196
|
+
audio: null,
|
|
197
|
+
style: null,
|
|
198
|
+
preserve: ['duration', 'order'],
|
|
199
|
+
replace: ['subject', 'brand', 'copy'],
|
|
200
|
+
confidence: index === 0 || index === times.length - 2 ? 0.55 : 0.5,
|
|
201
|
+
needs_model_review: true,
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
schema_version: '0.1.0',
|
|
206
|
+
reference: {
|
|
207
|
+
source_name: sourceName,
|
|
208
|
+
duration_sec: round(duration),
|
|
209
|
+
width,
|
|
210
|
+
height,
|
|
211
|
+
fps: round(rational(video.avg_frame_rate) || rational(video.r_frame_rate) || 0),
|
|
212
|
+
video_codec: video.codec_name || null,
|
|
213
|
+
audio: {
|
|
214
|
+
present: Boolean(audio),
|
|
215
|
+
codec: audio?.codec_name || null,
|
|
216
|
+
sample_rate: audio?.sample_rate ? Number(audio.sample_rate) : null,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
analysis: {
|
|
220
|
+
boundary_method: 'adaptive_scene_plus_black',
|
|
221
|
+
asr_status: audio ? 'not_run' : 'not_applicable',
|
|
222
|
+
beat_status: audio ? 'not_run' : 'not_applicable',
|
|
223
|
+
model_review_status: 'required',
|
|
224
|
+
scene_score_threshold: sceneResult.threshold,
|
|
225
|
+
scene_candidate_count: sceneResult.candidates.length,
|
|
226
|
+
black_candidate_count: blackEvidence.length,
|
|
227
|
+
unresolved_boundary_candidates: unresolvedCandidates,
|
|
228
|
+
warnings: [
|
|
229
|
+
'Boundaries are adaptive candidates, not semantic ground truth.',
|
|
230
|
+
'Smooth motion graphics and dark scenes require frame-level model review.',
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
global_dna: {
|
|
234
|
+
aspect_ratio: `${width / divisor}:${height / divisor}`,
|
|
235
|
+
shot_duration_curve_sec: shots.map((shot) => shot.duration_sec),
|
|
236
|
+
cut_rate_per_min: round(boundaries.length / duration * 60, 2),
|
|
237
|
+
style: null,
|
|
238
|
+
audio_arc: null,
|
|
239
|
+
},
|
|
240
|
+
boundaries,
|
|
241
|
+
shots,
|
|
242
|
+
route: null,
|
|
243
|
+
qa_targets: null,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function validateBlueprint(blueprint) {
|
|
248
|
+
const tolerance = 0.002;
|
|
249
|
+
const { boundaries, shots, global_dna: globalDna, reference } = blueprint;
|
|
250
|
+
if (shots.length !== boundaries.length + 1) throw new Error('Blueprint shot/boundary counts are inconsistent.');
|
|
251
|
+
if (globalDna.shot_duration_curve_sec.length !== shots.length) throw new Error('Blueprint duration curve length is inconsistent.');
|
|
252
|
+
for (const [index, shot] of shots.entries()) {
|
|
253
|
+
const expectedStart = index === 0 ? 0 : shots[index - 1].source_range.end_sec;
|
|
254
|
+
if (shot.order !== index + 1) throw new Error(`Blueprint shot order is invalid at ${shot.id}.`);
|
|
255
|
+
if (Math.abs(shot.source_range.start_sec - expectedStart) > tolerance) {
|
|
256
|
+
throw new Error(`Blueprint coverage is discontinuous at ${shot.id}.`);
|
|
257
|
+
}
|
|
258
|
+
if (shot.source_range.end_sec <= shot.source_range.start_sec) throw new Error(`Blueprint range is invalid at ${shot.id}.`);
|
|
259
|
+
if (Math.abs(shot.duration_sec - (shot.source_range.end_sec - shot.source_range.start_sec)) > tolerance) {
|
|
260
|
+
throw new Error(`Blueprint duration is inconsistent at ${shot.id}.`);
|
|
261
|
+
}
|
|
262
|
+
if (Math.abs(globalDna.shot_duration_curve_sec[index] - shot.duration_sec) > tolerance) {
|
|
263
|
+
throw new Error(`Blueprint duration curve is inconsistent at ${shot.id}.`);
|
|
264
|
+
}
|
|
265
|
+
if (index < boundaries.length && Math.abs(boundaries[index].time_sec - shot.source_range.end_sec) > tolerance) {
|
|
266
|
+
throw new Error(`Blueprint boundary is inconsistent after ${shot.id}.`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (Math.abs(shots.at(-1).source_range.end_sec - reference.duration_sec) > tolerance) {
|
|
270
|
+
throw new Error('Blueprint does not cover the full reference duration.');
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function main(argv) {
|
|
275
|
+
const args = parseArgs(argv);
|
|
276
|
+
if (args.help) {
|
|
277
|
+
process.stdout.write(`${usage()}\n`);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const work = mkdtempSync(join(tmpdir(), 'makaron-shot-blueprint-'));
|
|
281
|
+
try {
|
|
282
|
+
const probe = JSON.parse(run(args.ffprobe, [
|
|
283
|
+
'-v', 'error',
|
|
284
|
+
'-show_streams',
|
|
285
|
+
'-show_format',
|
|
286
|
+
'-of', 'json',
|
|
287
|
+
args.input,
|
|
288
|
+
]));
|
|
289
|
+
const duration = Number(probe.format?.duration || probe.streams?.find((stream) => stream.codec_type === 'video')?.duration);
|
|
290
|
+
const metadataPath = join(work, 'scene-metadata.txt');
|
|
291
|
+
run(args.ffmpeg, [
|
|
292
|
+
'-hide_banner', '-nostdin', '-v', 'error', '-i', args.input,
|
|
293
|
+
'-an', '-vf', `select=gte(scene\\,0),metadata=print:file=${metadataPath}`,
|
|
294
|
+
'-f', 'null', '-',
|
|
295
|
+
]);
|
|
296
|
+
const sceneResult = sceneCandidates(parseSceneScores(readFileSync(metadataPath, 'utf8')), duration);
|
|
297
|
+
const blackResult = spawnSync(args.ffmpeg, [
|
|
298
|
+
'-hide_banner', '-nostdin', '-v', 'info', '-i', args.input,
|
|
299
|
+
'-an', '-vf', 'blackdetect=d=0.15:pic_th=0.99', '-f', 'null', '-',
|
|
300
|
+
], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
|
301
|
+
if (blackResult.error) throw blackResult.error;
|
|
302
|
+
if (blackResult.status !== 0) throw new Error(`ffmpeg blackdetect failed: ${(blackResult.stderr || '').trim()}`);
|
|
303
|
+
const blackStderr = blackResult.stderr || '';
|
|
304
|
+
const blueprint = buildBlueprint(probe, basename(args.input), sceneResult, parseBlackRanges(blackStderr, duration));
|
|
305
|
+
validateBlueprint(blueprint);
|
|
306
|
+
writeFileSync(args.output, `${JSON.stringify(blueprint, null, 2)}\n`);
|
|
307
|
+
process.stdout.write(`${args.output}\n`);
|
|
308
|
+
} finally {
|
|
309
|
+
rmSync(work, { recursive: true, force: true });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
main(process.argv.slice(2));
|