@auscera/cleoedits 0.0.0-stage → 0.1.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/README.md +62 -2
- package/cli.mjs +149 -0
- package/lib/dependencies.mjs +384 -0
- package/lib/run.mjs +114 -0
- package/lib/workspace.mjs +167 -0
- package/package.json +240 -3
- package/workspace/.agents/skills/cleoedits/SKILL.md +29 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/audiogram.json +41 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/facebook.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/linkedin.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/podcast.json +23 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/reels.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/shorts.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/tiktok.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/x.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube-shorts.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube.json +48 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/LICENSE-SimpleIcons +30 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/logos.json +1 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Anton-Regular.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/ArchivoBlack-Regular.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/InstrumentSerif-Italic.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Inter.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/LICENSE-PermanentMarker.txt +202 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Montserrat.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Anton.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-ArchivoBlack.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-InstrumentSerif.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Inter.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Montserrat.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-PlayfairDisplay.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Poppins.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-SpaceMono.txt +93 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PermanentMarker-Regular.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay-Italic.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Black.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Bold.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-ExtraBold.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/SpaceMono-Bold.ttf +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-MediaPipe +218 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-YuNet +21 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/NOTICE.md +4 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/selfie_segmenter.tflite +0 -0
- package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/yunet.onnx +0 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/LICENSE +21 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/audio-app-ui/STYLE.md +65 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/STYLE.md +53 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/index.html +328 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/STYLE.md +65 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/index.html +575 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/design-app-ui/STYLE.md +68 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editor-ui/STYLE.md +73 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/STYLE.md +54 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/index.html +189 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/STYLE.md +64 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/index.html +620 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/STYLE.md +55 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/index.html +238 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/STYLE.md +66 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/index.html +602 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/STYLE.md +66 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/index.html +777 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/STYLE.md +56 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/index.html +186 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/motion-app-ui/STYLE.md +68 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/STYLE.md +56 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/index.html +244 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/STYLE.md +67 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/index.html +663 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/STYLE.md +59 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/index.html +395 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/STYLE.md +52 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/index.html +194 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/STYLE.md +58 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/index.html +242 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/STYLE.md +53 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/index.html +138 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/studio.js +57 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/STYLE.md +63 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/index.html +599 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/STYLE.md +65 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/index.html +1297 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/STYLE.md +69 -0
- package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/index.html +674 -0
- package/workspace/.agents/skills/cleoedits/references/audio-clearervoice-elevenlabs.md +11 -0
- package/workspace/.agents/skills/cleoedits/references/ffmpeg-and-reels.md +15 -0
- package/workspace/.agents/skills/cleoedits/references/hyperframes-workflows.md +13 -0
- package/workspace/.agents/skills/cleoedits/references/kdenlive-cli-and-mcp.md +12 -0
- package/workspace/.agents/skills/cleoedits/references/motion-design-pipeline.md +7 -0
- package/workspace/.agents/skills/cleoedits/references/motion-taste-emil.md +5 -0
- package/workspace/.agents/skills/cleoedits/references/playwright-demo-capture.md +9 -0
- package/workspace/.agents/skills/cleoedits/references/remotion-workflows.md +13 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/LICENSE +21 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_ass_overlay.py +399 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/__init__.py +235 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/alpha.py +560 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/asr.py +1237 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/color.py +540 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/decision.py +2452 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/drawtext.py +290 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emit.py +1309 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emoji.py +518 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/fonts.py +875 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing.py +263 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing_edit.py +432 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/probe.py +1613 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/runner.py +3994 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/text.py +73 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/timeline.py +721 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/wrap.py +981 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_contract.py +2454 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_platforms.py +258 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.html +754 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.py +258 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_smartcut.py +450 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/audio.py +867 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/background.py +136 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/batch.py +1409 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/broll.py +282 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/caption.py +2207 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/check.py +815 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/color.py +695 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/crop.py +91 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cropdetect.py +214 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cut.py +2076 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/deinterlace.py +90 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/denoise.py +94 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/export.py +1033 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/fit.py +729 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/freeze.py +197 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/graphics.py +920 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/grid.py +235 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/insert.py +142 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/join.py +1083 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/look.py +475 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loop.py +395 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loudness.py +397 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/metadata.py +416 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/multicam.py +414 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/overlay.py +766 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/pad.py +121 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/probe.py +145 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/proxy.py +93 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/redact.py +162 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/render.py +2424 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/report.py +354 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/reverse.py +114 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/scenes.py +439 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sequence.py +285 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/silence.py +945 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/speedramp.py +193 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sphere.py +137 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/stabilize.py +141 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/straighten.py +120 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sync.py +500 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/verify.py +411 -0
- package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/waveform.py +502 -0
- package/workspace/.agents/skills/cleoedits/scripts/kdenlive_builder.py +284 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-claude-motion +21 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-motion-design +21 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/_media.py +43 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/pacing_check.py +90 -0
- package/workspace/.agents/skills/cleoedits/scripts/motion/storyboard.py +77 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/LICENSE +26 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/fx.py +2717 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/logos.py +194 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/sfx.py +105 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/trim.py +99 -0
- package/workspace/.agents/skills/cleoedits/scripts/reel_effects/words.py +60 -0
- package/workspace/.claude/commands/blender-3d.md +12 -0
- package/workspace/.claude/commands/business-short-form-reels.md +12 -0
- package/workspace/.claude/commands/color-grade.md +12 -0
- package/workspace/.claude/commands/cutout-grid-reel.md +12 -0
- package/workspace/.claude/commands/depth-ui-reel.md +12 -0
- package/workspace/.claude/commands/explainer-panel-reel.md +12 -0
- package/workspace/.claude/commands/freeze-frame.md +12 -0
- package/workspace/.claude/commands/glass-graph.md +12 -0
- package/workspace/.claude/commands/over-the-shoulder.md +12 -0
- package/workspace/.claude/commands/personal-short-form-reels.md +12 -0
- package/workspace/.claude/commands/ranking-format.md +12 -0
- package/workspace/.claude/commands/relight.md +12 -0
- package/workspace/.claude/commands/reverse-engineer.md +12 -0
- package/workspace/.claude/commands/text-behind.md +12 -0
- package/workspace/.claude/commands/tier-list.md +12 -0
- package/workspace/.claude-plugin/plugin.json +8 -0
- package/workspace/.npmignore +15 -0
- package/workspace/AGENTS.md +30 -0
- package/workspace/README.md +63 -0
- package/workspace/assets/fonts/TikTokSans-OFL.txt +93 -0
- package/workspace/assets/fonts/TikTokSans-Variable.ttf +0 -0
- package/workspace/assets/luts/clean_warm.cube +4917 -0
- package/workspace/assets/luts/golden_hour.cube +4917 -0
- package/workspace/assets/luts/moody_dark.cube +4917 -0
- package/workspace/assets/luts/teal_orange.cube +4917 -0
- package/workspace/assets/sfx/NOTICE.txt +1 -0
- package/workspace/assets/sfx/click.wav +0 -0
- package/workspace/assets/sfx/pop.wav +0 -0
- package/workspace/assets/sfx/riser.wav +0 -0
- package/workspace/assets/sfx/whoosh.wav +0 -0
- package/workspace/generators/hyperframes/index.html +39 -0
- package/workspace/generators/hyperframes/package.json +15 -0
- package/workspace/generators/hyperframes/pnpm-lock.yaml +1181 -0
- package/workspace/generators/hyperframes/pnpm-workspace.yaml +10 -0
- package/workspace/generators/remotion/eslint.config.mjs +3 -0
- package/workspace/generators/remotion/package.json +36 -0
- package/workspace/generators/remotion/pnpm-lock.yaml +4179 -0
- package/workspace/generators/remotion/pnpm-workspace.yaml +10 -0
- package/workspace/generators/remotion/remotion.config.ts +13 -0
- package/workspace/generators/remotion/src/Root.tsx +52 -0
- package/workspace/generators/remotion/src/index.css +1 -0
- package/workspace/generators/remotion/src/index.ts +4 -0
- package/workspace/generators/remotion/tsconfig.json +15 -0
- package/workspace/pipeline/scripts/_codec.py +28 -0
- package/workspace/pipeline/scripts/ai_media_api.py +109 -0
- package/workspace/pipeline/scripts/blender_render.py +166 -0
- package/workspace/pipeline/scripts/composite.py +49 -0
- package/workspace/pipeline/scripts/melt.sh +68 -0
- package/workspace/pipeline/scripts/normalize_audio.py +39 -0
- package/workspace/pipeline/scripts/person_matte.py +216 -0
- package/workspace/pipeline/scripts/record_demo.py +69 -0
- package/workspace/pipeline/scripts/whisper_cut.py +98 -0
- package/workspace-manifest.json +908 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build a review page for a render project: the plan, the result, and fields to re-edit it.
|
|
3
|
+
|
|
4
|
+
python3 scripts/_review.py project.json [--result render.json] [-o project.review] [--overwrite]
|
|
5
|
+
npx ffmpeg-skill review project.json [--result render.json]
|
|
6
|
+
|
|
7
|
+
Standalone use only (#633): this is not one of the contract's tools and the MCP server does not
|
|
8
|
+
list it, so a caller that owns the review (Velisa) never reaches it. It writes a folder with an
|
|
9
|
+
index.html and the stills it shows; the page needs no network and runs nothing. "Save project"
|
|
10
|
+
in the page saves the edited project JSON; rendering it again is `render.py` as usual.
|
|
11
|
+
|
|
12
|
+
The page is an editor-style screen (sources with their probe facts, the work steps, a viewer that
|
|
13
|
+
plays the output, a timeline with clips, cues and the sound, the measured rows against what was
|
|
14
|
+
expected) in which every element has a number; pressing one adds a row to an instruction for an
|
|
15
|
+
agent, and each tool's own flags come from the contract. Its markup is `_review.html`; this file
|
|
16
|
+
measures and embeds one JSON document: each clip's stills at its in point, middle and out point,
|
|
17
|
+
ffprobe's facts about each source, the stages of `render.py --dry-run --json`, and (with --result,
|
|
18
|
+
the `render.py --json` document of a run) that document, stills and a waveform of the output. A
|
|
19
|
+
still that ffmpeg could not write is left out and says so; nothing is guessed.
|
|
20
|
+
"""
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import os
|
|
24
|
+
import shlex
|
|
25
|
+
import re
|
|
26
|
+
import subprocess
|
|
27
|
+
import sys
|
|
28
|
+
import tempfile
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
|
|
31
|
+
HERE = Path(__file__).resolve().parent
|
|
32
|
+
sys.path.insert(0, str(HERE))
|
|
33
|
+
from _common.runner import found_exe # noqa: E402
|
|
34
|
+
from _common.decision import parse_time # noqa: E402
|
|
35
|
+
from _common.asr import parse_srt # noqa: E402
|
|
36
|
+
from _platforms import PLATFORMS # noqa: E402
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
SOURCES: "set[str]" = set() # every media path the project or the result names, resolved
|
|
40
|
+
BASE = Path.cwd() # the project's folder, set in main(): a relative output is read from there
|
|
41
|
+
STILLS = "stills" # the stills live in a folder of their own, which only this tool writes
|
|
42
|
+
STILLS_MARK = ".ffmpeg-skill-review-stills"
|
|
43
|
+
STILL_TIMEOUT = 120 # seconds for one still or one probe: a stalled read is a missing still, not a hang
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def is_input(path) -> bool: # by name and by file identity: a hard link to an input has another name
|
|
47
|
+
return os.path.realpath(path) in SOURCES or (os.path.exists(path) and any(os.path.samefile(path, s) for s in SOURCES))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def shot(out: Path, *args: str) -> bool:
|
|
51
|
+
"""One picture written by ffmpeg to `out`; False when ffmpeg could not write it. An earlier
|
|
52
|
+
run's picture is removed first, so a seek that writes nothing is a missing still, not an old
|
|
53
|
+
picture; a name that is a source of this project is never written (review of #636)."""
|
|
54
|
+
if is_input(out):
|
|
55
|
+
return False
|
|
56
|
+
out.unlink(missing_ok=True)
|
|
57
|
+
try:
|
|
58
|
+
proc = subprocess.run([found_exe("ffmpeg"), "-v", "error", "-y", *args, str(out)], capture_output=True, timeout=STILL_TIMEOUT)
|
|
59
|
+
except subprocess.TimeoutExpired:
|
|
60
|
+
return False
|
|
61
|
+
return proc.returncode == 0 and out.is_file() and out.stat().st_size > 0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def still(folder: Path, name: str, src: str, at: "float | None") -> "str | None":
|
|
65
|
+
"""A 320 px wide JPEG of `src` at `at` seconds, as the name the page loads, or None."""
|
|
66
|
+
ok = at is not None and shot(folder / STILLS / name, "-ss", f"{max(at, 0):.3f}", "-i", src, "-frames:v", "1", "-vf", "scale=320:-2", "-q:v", "4")
|
|
67
|
+
return f"{STILLS}/{name}" if ok else None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def write_new(path: Path, text: str) -> None:
|
|
71
|
+
"""Write `path` as a new file: into a temporary file created beside it, then renamed over it.
|
|
72
|
+
Writing in place followed a symlink or a hard link at that name into whatever it pointed to (a
|
|
73
|
+
project input), and truncated it; a rename replaces the name only. The temporary file is
|
|
74
|
+
created exclusively, so a link already standing at a guessable name is never written through
|
|
75
|
+
either (review of #636)."""
|
|
76
|
+
fd, tmp = tempfile.mkstemp(prefix=f".{path.name}.", suffix=".tmp", dir=str(path.parent))
|
|
77
|
+
with os.fdopen(fd, "w", encoding="utf-8") as fh:
|
|
78
|
+
fh.write(text)
|
|
79
|
+
os.chmod(tmp, 0o644) # mkstemp makes it owner-only; a page and its marker are ordinary files
|
|
80
|
+
os.replace(tmp, path)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def facts(src: str) -> dict:
|
|
84
|
+
"""ffprobe's own words about `src` (format duration, each stream's codec, size, rate), or {}."""
|
|
85
|
+
try:
|
|
86
|
+
proc = subprocess.run([found_exe("ffprobe"), "-v", "error", "-show_entries",
|
|
87
|
+
"format=duration:stream=codec_type,codec_name,width,height,r_frame_rate,channels,sample_rate", "-of", "json", src],
|
|
88
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=STILL_TIMEOUT)
|
|
89
|
+
doc = json.loads(proc.stdout or "{}")
|
|
90
|
+
except (subprocess.TimeoutExpired, ValueError):
|
|
91
|
+
return {}
|
|
92
|
+
return doc if isinstance(doc, dict) else {}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def length(doc: dict) -> "tuple[float | None, float]":
|
|
96
|
+
"""The source's duration (None when unknown) and its frame rate (30 when unknown), which a
|
|
97
|
+
frame-based time such as 00:00:05:45 is read at."""
|
|
98
|
+
try:
|
|
99
|
+
duration = float((doc.get("format") or {}).get("duration"))
|
|
100
|
+
except (TypeError, ValueError):
|
|
101
|
+
duration = None
|
|
102
|
+
try:
|
|
103
|
+
video = [s for s in doc.get("streams") or [] if s.get("codec_type") == "video"]
|
|
104
|
+
num, den = ((video or [{}])[0].get("r_frame_rate") or "30/1").split("/")
|
|
105
|
+
fps = float(num) / float(den) if float(den) else 30.0
|
|
106
|
+
except (ValueError, ZeroDivisionError):
|
|
107
|
+
fps = 30.0
|
|
108
|
+
return duration, fps or 30.0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def seconds(value, fps: float = 30.0) -> "float | None":
|
|
112
|
+
try: # a null bound reads as "None", which is not a time
|
|
113
|
+
return float(parse_time(str(value), fps))
|
|
114
|
+
except (ValueError, TypeError):
|
|
115
|
+
return None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def clips_and_sources(project: dict, folder: Path) -> "tuple[list, list]":
|
|
119
|
+
"""Each clip with its bounds in seconds and its three stills, and each distinct source file
|
|
120
|
+
with what ffprobe says about it."""
|
|
121
|
+
sources, clips, seen = [], [], {}
|
|
122
|
+
for i, clip in enumerate(project.get("clips") or []):
|
|
123
|
+
src = str(clip.get("src", ""))
|
|
124
|
+
path = src if os.path.isabs(src) else str(BASE / src)
|
|
125
|
+
if path not in seen:
|
|
126
|
+
seen[path] = len(sources)
|
|
127
|
+
sources.append({"path": src, "probe": facts(path)})
|
|
128
|
+
total, fps = length(sources[seen[path]]["probe"])
|
|
129
|
+
start = seconds(clip.get("in"), fps) or 0.0
|
|
130
|
+
end = seconds(clip.get("out"), fps)
|
|
131
|
+
end = end if end is not None else total
|
|
132
|
+
at = [] if end is None else [start, (start + end) / 2, max(end - 0.05, start)]
|
|
133
|
+
clips.append({"s": seen[path], "a": start, "b": end, "stills": [still(folder, f"clip{i}_{k}.jpg", path, t) for k, t in enumerate(at)]})
|
|
134
|
+
return clips, sources
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def output_media(result: dict, folder: Path) -> dict:
|
|
138
|
+
"""The rendered file as the page plays it, six stills of it and a picture of its sound.
|
|
139
|
+
Read where the safety check read it (the project's folder), never against the caller's cwd."""
|
|
140
|
+
path, dur = result.get("output"), (result.get("probe") or {}).get("duration")
|
|
141
|
+
path = str((BASE / path).resolve()) if path else None
|
|
142
|
+
if not (path and os.path.isfile(path)):
|
|
143
|
+
return {"video": None, "stills": [], "wave": None}
|
|
144
|
+
wave = (result.get("probe") or {}).get("audio") and shot(folder / STILLS / "wave.png", "-i", path, "-filter_complex",
|
|
145
|
+
"showwavespic=s=2400x96:colors=0xa3a9b4:scale=sqrt", "-frames:v", "1")
|
|
146
|
+
return {"video": Path(path).as_uri(), "wave": f"{STILLS}/wave.png" if wave else None,
|
|
147
|
+
"stills": [{"t": dur * (k + 0.5) / 6, "file": still(folder, f"out_{k}.jpg", path, dur * (k + 0.5) / 6)} for k in range(6)] if dur else []}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def cues(project: dict, result: "dict | None") -> "tuple[str | None, list]":
|
|
151
|
+
"""The cue file the captions came from (the run's delivered .srt, else the project's own) and
|
|
152
|
+
its cues; a file that cannot be read is no cues, which the page shows as no caption track."""
|
|
153
|
+
caps = project.get("captions") if isinstance(project.get("captions"), dict) else {}
|
|
154
|
+
name = (result or {}).get("caption_srt") or next((v for v in (caps.get("srt"), caps.get("text")) if isinstance(v, str)
|
|
155
|
+
and v.lower().endswith((".srt", ".vtt"))), None)
|
|
156
|
+
try:
|
|
157
|
+
return name, [list(c) for c in parse_srt(str(BASE / name))] if name else []
|
|
158
|
+
except (SystemExit, OSError, ValueError):
|
|
159
|
+
return name, []
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def main(argv=None) -> int:
|
|
163
|
+
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
164
|
+
ap.add_argument("project", help="the render.py project JSON")
|
|
165
|
+
ap.add_argument("--result", help="the render.py --json document of a run of this project")
|
|
166
|
+
ap.add_argument("-o", "--output", help="the folder to write (default: <project>.review next to the project)")
|
|
167
|
+
ap.add_argument("--overwrite", action="store_true", help="replace a review page already in that folder")
|
|
168
|
+
a = ap.parse_args(argv)
|
|
169
|
+
proj_path = Path(a.project).resolve()
|
|
170
|
+
try:
|
|
171
|
+
project = json.loads(proj_path.read_text(encoding="utf-8"))
|
|
172
|
+
result = json.loads(Path(a.result).read_text(encoding="utf-8")) if a.result else None
|
|
173
|
+
except (OSError, ValueError) as exc:
|
|
174
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
175
|
+
return 1
|
|
176
|
+
global BASE
|
|
177
|
+
BASE = proj_path.parent
|
|
178
|
+
folder = Path(a.output).resolve() if a.output else proj_path.with_suffix(".review")
|
|
179
|
+
if folder == proj_path: # a project named x.review: its folder cannot be the project itself
|
|
180
|
+
folder = proj_path.with_name(proj_path.name + "-review")
|
|
181
|
+
if (folder / "index.html").exists() and not a.overwrite:
|
|
182
|
+
print(f"error: {folder / 'index.html'} exists; pass --overwrite to replace it", file=sys.stderr)
|
|
183
|
+
return 1
|
|
184
|
+
if folder.exists() and not folder.is_dir():
|
|
185
|
+
print(f"error: {folder} exists and is not a folder", file=sys.stderr)
|
|
186
|
+
return 1
|
|
187
|
+
if folder.is_dir() and not (folder / "index.html").exists() and any(folder.iterdir()):
|
|
188
|
+
# a folder of other files (a media folder given as -o) is not a review folder: its files
|
|
189
|
+
# could share a still's name (review of #636)
|
|
190
|
+
print(f"error: {folder} holds other files and no review page; give an empty or new folder", file=sys.stderr)
|
|
191
|
+
return 1
|
|
192
|
+
# every string in the project that names a file (a clip, an overlay, a cue file, music) and
|
|
193
|
+
# the result's output: none of them may be in the stills folder (review of #636)
|
|
194
|
+
def strings(value):
|
|
195
|
+
if isinstance(value, str):
|
|
196
|
+
yield value
|
|
197
|
+
elif isinstance(value, (dict, list)):
|
|
198
|
+
for v in (value.values() if isinstance(value, dict) else value):
|
|
199
|
+
yield from strings(v)
|
|
200
|
+
for text in list(strings(project)) + ([str(result["output"])] if result and result.get("output") else []):
|
|
201
|
+
try:
|
|
202
|
+
candidate = Path(text) if os.path.isabs(text) else proj_path.parent / text
|
|
203
|
+
if candidate.exists():
|
|
204
|
+
SOURCES.add(os.path.realpath(candidate))
|
|
205
|
+
except (OSError, ValueError):
|
|
206
|
+
continue # literal text (an overlay line, a title) that cannot be a file name
|
|
207
|
+
# the two documents this run reads are inputs too
|
|
208
|
+
SOURCES.update(os.path.realpath(p) for p in [proj_path] + ([a.result] if a.result else []))
|
|
209
|
+
# nothing is written over an input: not the page, not a still (checked before any write)
|
|
210
|
+
if is_input(folder / "index.html"):
|
|
211
|
+
print(f"error: {folder / 'index.html'} is an input of this run; give another -o", file=sys.stderr)
|
|
212
|
+
return 1
|
|
213
|
+
stills = folder / STILLS
|
|
214
|
+
if os.path.lexists(stills):
|
|
215
|
+
# only a stills folder this tool made is cleared; anything else in its place is someone's
|
|
216
|
+
mark = stills / STILLS_MARK
|
|
217
|
+
if not (stills.is_dir() and not stills.is_symlink() and mark.is_file() and not mark.is_symlink()):
|
|
218
|
+
print(f"error: {stills} exists and was not made by the review page; move it or give another -o", file=sys.stderr)
|
|
219
|
+
return 1
|
|
220
|
+
inside = [p for p in SOURCES if Path(p).is_relative_to(stills.resolve())]
|
|
221
|
+
if inside:
|
|
222
|
+
print(f"error: the project uses {inside[0]}, which is in {stills}; give another -o", file=sys.stderr)
|
|
223
|
+
return 1
|
|
224
|
+
# only this tool's stills are removed, one by one: never the folder, never another file in it
|
|
225
|
+
for entry in stills.iterdir():
|
|
226
|
+
if (re.fullmatch(r"(clip\d+_\d|out_\d)\.jpg|wave\.png", entry.name) and entry.is_file() and not entry.is_symlink()
|
|
227
|
+
and not is_input(entry)):
|
|
228
|
+
entry.unlink()
|
|
229
|
+
stills.mkdir(parents=True, exist_ok=True)
|
|
230
|
+
write_new(stills / STILLS_MARK, "made by scripts/_review.py; cleared on each run\n")
|
|
231
|
+
# a dry run writes nothing, so --overwrite only keeps an output from an earlier run from refusing it
|
|
232
|
+
dry = subprocess.run([sys.executable, str(HERE / "render.py"), str(proj_path), "--dry-run", "--overwrite", "--json"],
|
|
233
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", cwd=str(proj_path.parent))
|
|
234
|
+
try:
|
|
235
|
+
doc = json.loads(dry.stdout)
|
|
236
|
+
stages, note = ((doc.get("stages") or [], "") if doc.get("status") == "completed"
|
|
237
|
+
else ([], "the dry run failed: " + str((doc.get("error") or {}).get("message", "no message"))))
|
|
238
|
+
except ValueError:
|
|
239
|
+
stages, note = [], "the dry run did not complete: " + (dry.stderr.strip().splitlines() or ["no message"])[-1]
|
|
240
|
+
contract = subprocess.run([sys.executable, str(HERE / "_contract.py"), "--json", "--static"], capture_output=True, text=True, encoding="utf-8")
|
|
241
|
+
clips, sources = clips_and_sources(project, folder)
|
|
242
|
+
cue_file, cue_list = cues(project, result)
|
|
243
|
+
data = {"name": proj_path.name, "project_path": str(proj_path), "project": project, "result": result, "stages": stages, "stages_note": note,
|
|
244
|
+
"clips": clips, "sources": sources, "cue_file": cue_file, "cues": cue_list, "out": output_media(result or {}, folder),
|
|
245
|
+
"safe": {k: v["safe"] for k, v in PLATFORMS.items() if v.get("safe")},
|
|
246
|
+
"tools": {t["name"]: {"d": t["description"], "p": t["input_schema"]["properties"]} for t in json.loads(contract.stdout)["tools"]},
|
|
247
|
+
# runnable from anywhere: this copy's render.py, both paths quoted for a shell
|
|
248
|
+
"run": f"python3 {shlex.quote(str(HERE / 'render.py'))} {shlex.quote(str(proj_path))} --overwrite --json"}
|
|
249
|
+
# the page is the template with this one document in it, as a script's own value (the page never
|
|
250
|
+
# reads its data back out of the DOM); no "<" of the data reaches the HTML parser
|
|
251
|
+
page = (HERE / "_review.html").read_text(encoding="utf-8").replace("/*DATA*/", json.dumps(data, ensure_ascii=False).replace("<", "\\u003c"), 1)
|
|
252
|
+
write_new(folder / "index.html", page)
|
|
253
|
+
print(folder / "index.html")
|
|
254
|
+
return 0
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
if __name__ == "__main__":
|
|
258
|
+
sys.exit(main())
|