@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,2454 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Machine-readable execution contract for ffmpeg-skill (internal module, not a tool).
|
|
3
|
+
|
|
4
|
+
python3 scripts/_contract.py --json # the contract, with detected capabilities
|
|
5
|
+
python3 scripts/_contract.py --json --static # same, without environment detection
|
|
6
|
+
python3 scripts/_contract.py --json --tool cut # only cut under `tools` (repeatable)
|
|
7
|
+
python3 scripts/_contract.py doctor [--json] # which required capabilities this machine has
|
|
8
|
+
ffmpeg-skill contract --json # the same through the npm entry point
|
|
9
|
+
|
|
10
|
+
The contract describes every public tool in scripts/ (one ToolSpec per script that does
|
|
11
|
+
not start with "_"): what it needs, what it takes, what it writes, how to verify the
|
|
12
|
+
result, and whether an agent can plan it with --dry-run. Input schemas are generated
|
|
13
|
+
from each script's argparse parser, so the CLI stays the single source of truth; the
|
|
14
|
+
per-tool facts that cannot be read from a parser (role, verification policy, required
|
|
15
|
+
ffmpeg components) live in TOOL_META below and are checked against the scripts by
|
|
16
|
+
tests/test_contract.py.
|
|
17
|
+
|
|
18
|
+
The contract has its own version (CONTRACT_VERSION) that only changes when the shape of
|
|
19
|
+
this document changes; the skill version comes from package.json.
|
|
20
|
+
"""
|
|
21
|
+
import argparse
|
|
22
|
+
import functools
|
|
23
|
+
import importlib.metadata
|
|
24
|
+
import importlib.util
|
|
25
|
+
import json
|
|
26
|
+
import os
|
|
27
|
+
import platform
|
|
28
|
+
import re
|
|
29
|
+
import shutil
|
|
30
|
+
import subprocess
|
|
31
|
+
import sys
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import Any, Dict, List, Optional
|
|
34
|
+
|
|
35
|
+
HERE = Path(__file__).resolve().parent
|
|
36
|
+
ROOT = HERE.parent
|
|
37
|
+
SKILL_ID = "ffmpeg-skill"
|
|
38
|
+
CONTRACT_VERSION = "2.0"
|
|
39
|
+
# `doctor`'s own introspection calls (-filters/-encoders/-bsfs/-version) are meant to be fast,
|
|
40
|
+
# bounded, non-media operations; a hang here would silently freeze the one tool meant to report
|
|
41
|
+
# whether the machine is broken. Media-processing scripts (cut, fit, ...) are NOT bounded this
|
|
42
|
+
# way -- a legitimate --accurate re-encode of a long file can take a long time, so no timeout is
|
|
43
|
+
# applied there (see README, "Development").
|
|
44
|
+
_DETECT_TIMEOUT = 10
|
|
45
|
+
|
|
46
|
+
ROLES = {
|
|
47
|
+
"analysis": "reads media and reports measurements; writes no media",
|
|
48
|
+
"analysis_and_execution": "measures by default or with a flag, and can also write a transformed artifact",
|
|
49
|
+
"execution": "writes a new media artifact from the input(s); the input is never modified",
|
|
50
|
+
"verification": "checks or shows an artifact (probe numbers, compliance rows, contact sheets); writes no media",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Facts that are not derivable from the argparse parsers. Capability names:
|
|
54
|
+
# ffmpeg / ffprobe the binaries on PATH
|
|
55
|
+
# encoder:<name> `ffmpeg -encoders`
|
|
56
|
+
# decoder:<name> `ffmpeg -decoders`
|
|
57
|
+
# filter:<name> `ffmpeg -filters`
|
|
58
|
+
# bsf:<name> `ffmpeg -bsfs`
|
|
59
|
+
# external:whisper a local whisper engine (whisper.cpp / faster-whisper / openai-whisper)
|
|
60
|
+
# external:parakeet a local Parakeet engine (parakeet-mlx, or parakeet-cli with a .gguf model);
|
|
61
|
+
# English. Either external engine satisfies --transcribe.
|
|
62
|
+
# "optional" entries name the flag or condition under which the capability is needed.
|
|
63
|
+
FF = ["ffmpeg", "ffprobe"]
|
|
64
|
+
X264 = "encoder:libx264"
|
|
65
|
+
X265 = "encoder:libx265"
|
|
66
|
+
# --codec (1.8, every tool that re-encodes): the encoder the flag names, on top of the tool's own list
|
|
67
|
+
CODEC_CAPS = [{"capability": X265, "when": "--codec hevc"},
|
|
68
|
+
{"capability": "encoder:libsvtav1", "when": "--codec av1 (libaom-av1 is the fallback)"},
|
|
69
|
+
{"capability": "encoder:prores_ks", "when": "--codec prores"}]
|
|
70
|
+
AAC = "encoder:aac"
|
|
71
|
+
HDR_X265 = {"capability": X265, "when": "the source is HDR (kept as HEVC Main10)"}
|
|
72
|
+
AUDIO_OUT = [
|
|
73
|
+
{"capability": "encoder:libmp3lame", "when": "output extension is .mp3"},
|
|
74
|
+
{"capability": "encoder:libopus", "when": "output extension is .opus"},
|
|
75
|
+
{"capability": "encoder:libvorbis", "when": "output extension is .ogg"},
|
|
76
|
+
{"capability": "encoder:flac", "when": "encoding audio for a .flac or .mka output"},
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
TOOL_META: Dict[str, Dict[str, Any]] = {
|
|
80
|
+
"probe": dict(role="analysis", inputs=["media (video or audio, any container ffprobe reads)"], outputs=["measurement JSON on stdout (no file)"],
|
|
81
|
+
required=["ffprobe"], optional=[{"capability": "ffmpeg", "when": "--analyze"}, {"capability": "filter:signalstats", "when": "--analyze"}],
|
|
82
|
+
video_required=False, audio_only=True, visual=False, verify=[], produces_artifact=False, idempotency="bit_exact", deterministic=True),
|
|
83
|
+
"cut": dict(role="execution", inputs=["video or audio asset"], outputs=["cut video/audio artifact (same container family, or audio extracted when -o has an audio extension)"],
|
|
84
|
+
required=FF, optional=[{"capability": X264, "when": "re-encode: --accurate, VFR source, or a keyframe farther than --tolerance; --smart (the partial GOPs at the cut points)"},
|
|
85
|
+
{"capability": "bsf:filter_units", "when": "--smart"}, {"capability": "bsf:h264_mp4toannexb", "when": "--smart"},
|
|
86
|
+
dict(HDR_X265, when=HDR_X265["when"] + "; on an SDR HEVC source (the default since 3.0.0; --no-keep-hevc uses x264)"), {"capability": AAC, "when": "re-encode of a video container"}] + AUDIO_OUT,
|
|
87
|
+
video_required=False, audio_only=True, visual=False, verify=["probe"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
88
|
+
"fit": dict(role="execution", inputs=["video asset"], outputs=["video artifact at the requested duration / aspect / fps"],
|
|
89
|
+
required=FF + [X264, AAC], optional=[HDR_X265, {"capability": "filter:minterpolate", "when": "--smooth interpolate"},
|
|
90
|
+
{"capability": "filter:boxblur", "when": "--pad-fill blur or --fit blur"},
|
|
91
|
+
{"capability": "filter:eq", "when": "--fit blur (the background copy is dimmed)"}],
|
|
92
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
93
|
+
"crop": dict(role="execution", inputs=["video asset"], outputs=["video artifact cropped to the given pixel rectangle"],
|
|
94
|
+
required=FF + [X264, AAC], optional=[HDR_X265],
|
|
95
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
96
|
+
"deinterlace": dict(role="execution", inputs=["video asset"], outputs=["deinterlaced (progressive) video artifact"],
|
|
97
|
+
required=FF + [X264, AAC, "filter:yadif"], optional=[HDR_X265],
|
|
98
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
99
|
+
"denoise": dict(role="execution", inputs=["video asset"], outputs=["denoised video artifact"],
|
|
100
|
+
required=FF + [X264, AAC, "filter:hqdn3d"], optional=[HDR_X265],
|
|
101
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
102
|
+
"cropdetect": dict(role="analysis", inputs=["video asset"], outputs=["detected crop rectangle JSON on stdout (no file)"],
|
|
103
|
+
required=FF + ["filter:cropdetect"], optional=[],
|
|
104
|
+
video_required=True, audio_only=False, visual=False, verify=[], produces_artifact=False, idempotency="environment_dependent", deterministic=False),
|
|
105
|
+
"redact": dict(role="execution", inputs=["video asset"], outputs=["video artifact with the given pixel rectangle blurred, pixelated, or interpolated away (--mode delogo)"],
|
|
106
|
+
required=FF + [X264, AAC, "filter:boxblur"],
|
|
107
|
+
optional=[HDR_X265, {"capability": "filter:delogo", "when": "--mode delogo"}],
|
|
108
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
109
|
+
"waveform": dict(role="execution", inputs=["audio or video asset (audio track only)"], outputs=["waveform or spectrum video, or waveform PNGs at supplied times"],
|
|
110
|
+
required=FF + [X264, AAC, "filter:showwaves"], optional=[{"capability": "filter:showspectrum", "when": "--style spectrum"},
|
|
111
|
+
{"capability": "filter:showwavespic", "when": "--at"},
|
|
112
|
+
{"capability": "filter:drawtext", "when": "--title (graphics.py draws it) or --at"},
|
|
113
|
+
{"capability": "filter:subtitles", "when": "--srt (caption.py burns it)"}],
|
|
114
|
+
video_required=False, audio_only=True, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
115
|
+
"sphere": dict(role="execution", inputs=["360/spherical video asset"], outputs=["flat rectilinear video artifact of the chosen viewport"],
|
|
116
|
+
required=FF + [X264, AAC, "filter:v360"], optional=[HDR_X265],
|
|
117
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
118
|
+
"grid": dict(role="execution", inputs=["cols*rows video assets, filled left-to-right top-to-bottom"], outputs=["composited grid video artifact"],
|
|
119
|
+
required=FF + [X264, "filter:xstack"], optional=[{"capability": "filter:drawtext", "when": "--label auto (the default; without drawtext the cells are not labelled, fallback grid_no_drawtext)"}, {"capability": AAC, "when": "--audio-from"}],
|
|
120
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
121
|
+
"straighten": dict(role="execution", inputs=["video asset"], outputs=["video artifact rotated by the given angle (horizon correction)"],
|
|
122
|
+
required=FF + [X264, AAC, "filter:rotate"], optional=[HDR_X265],
|
|
123
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
124
|
+
"freeze": dict(role="execution", inputs=["video asset"], outputs=["video artifact with a frame held for the given duration"],
|
|
125
|
+
required=FF + [X264, AAC, "filter:tpad"], optional=[HDR_X265],
|
|
126
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
127
|
+
"pad": dict(role="execution", inputs=["video asset"], outputs=["video artifact with black/silent padding added at the start/end"],
|
|
128
|
+
required=FF + [X264, AAC, "filter:tpad"], optional=[HDR_X265],
|
|
129
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
130
|
+
"speedramp": dict(role="execution", inputs=["video asset"], outputs=["video artifact with a stepped speed ramp applied across segments"],
|
|
131
|
+
required=FF + [X264, AAC], optional=[HDR_X265],
|
|
132
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
133
|
+
"broll": dict(role="execution", inputs=["A-roll video asset", "one or more B-roll video assets (--insert)"], outputs=["video artifact of exactly the A-roll's length with the B-roll shown during each cutaway window"],
|
|
134
|
+
required=FF + [X264, AAC, "filter:overlay", "filter:amix"], optional=[HDR_X265],
|
|
135
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
136
|
+
"metadata": dict(role="execution", inputs=["video or audio asset", "chapters text file (--chapters)"], outputs=["the same streams, stream-copied, with chapter markers and/or title/artist/comment tags written", "proposed chapter list and YouTube description block (--auto-chapters --chapters-out/--description-out)"],
|
|
137
|
+
required=FF, optional=[{"capability": "filter:silencedetect", "when": "--auto-chapters"},
|
|
138
|
+
{"capability": "filter:scdet", "when": "--auto-chapters --from scenes|both"}],
|
|
139
|
+
video_required=False, audio_only=True, visual=False, verify=["probe"], produces_artifact=True, idempotency="bit_exact", deterministic=True),
|
|
140
|
+
"loop": dict(role="execution", inputs=["video asset"], outputs=["video artifact repeated to the requested count or duration (--boomerang: played forward then backward, silent)"],
|
|
141
|
+
required=FF + [X264, AAC], optional=[HDR_X265, {"capability": "filter:reverse", "when": "--boomerang"}, {"capability": "filter:loop", "when": "--boomerang"}, {"capability": "filter:xfade", "when": "--crossfade"}, {"capability": "encoder:ffv1", "when": "--crossfade"}, {"capability": "encoder:flac", "when": "--crossfade"}],
|
|
142
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
143
|
+
"insert": dict(role="execution", inputs=["still image"], outputs=["silent video artifact of the requested duration / frame size / fps"],
|
|
144
|
+
required=FF + [X264], optional=[{"capability": "filter:zoompan", "when": "--zoom / --pan"}],
|
|
145
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
146
|
+
"background": dict(role="execution", inputs=[], outputs=["generated solid-colour or gradient video artifact", "transparent canvas in an alpha line (--transparent)"],
|
|
147
|
+
required=FF + [X264], optional=[{"capability": "filter:gradients", "when": "--gradient"}],
|
|
148
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="bit_exact", deterministic=True),
|
|
149
|
+
"reverse": dict(role="execution", inputs=["video asset"], outputs=["reversed video artifact"],
|
|
150
|
+
required=FF + [X264, "filter:reverse"], optional=[HDR_X265, {"capability": "filter:areverse", "when": "the input has audio and --no-audio is not given"}, {"capability": AAC, "when": "the input has audio and --no-audio is not given"}],
|
|
151
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
152
|
+
"stabilize": dict(role="execution", inputs=["video asset"], outputs=["motion-stabilised video artifact"],
|
|
153
|
+
required=FF + [X264, "filter:vidstabdetect", "filter:vidstabtransform"], optional=[HDR_X265, {"capability": AAC, "when": "the input has audio"}],
|
|
154
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
155
|
+
"sequence": dict(role="execution", inputs=["a directory of numbered/globbed still images"], outputs=["video artifact built from the frame sequence"],
|
|
156
|
+
required=FF + [X264], optional=[],
|
|
157
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
158
|
+
"caption": dict(role="execution", inputs=["video asset", "SRT/ASS file or timed text (--text)"], outputs=["video artifact with burnt-in captions (--mode burn)", "video artifact with one or several language-tagged soft subtitle streams (--mode mux, --srt file:lang repeated)", "generated .srt / .ass sidecar"],
|
|
159
|
+
required=FF + [X264, AAC, "filter:subtitles"], optional=[{"capability": "filter:ass", "when": "--animate / --karaoke"}, HDR_X265, {"capability": "external:whisper", "when": "--transcribe"}, {"capability": "external:parakeet", "when": "--transcribe (English; either engine family satisfies it)"},
|
|
160
|
+
{"capability": "encoder:mov_text", "when": "--mode mux with a .mp4/.m4v/.mov output"}, {"capability": "encoder:webvtt", "when": "--mode mux with a .webm output"}, {"capability": "encoder:srt", "when": "--mode mux with a .mkv output"}],
|
|
161
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
162
|
+
"overlay": dict(role="execution", inputs=["video asset", "image (--image / --logo), text (--text), or a second video (--video) to composite"], outputs=["video artifact with the overlay composited"],
|
|
163
|
+
required=FF + [X264, AAC], optional=[{"capability": "filter:drawtext", "when": "--text"}, {"capability": "filter:chromakey", "when": "--chromakey"}, HDR_X265],
|
|
164
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
165
|
+
"graphics": dict(role="execution", inputs=["video asset"], outputs=["video artifact with the drawn template"],
|
|
166
|
+
required=FF + [X264, AAC, "filter:drawtext"],
|
|
167
|
+
optional=[HDR_X265, {"capability": "filter:ass", "when": "--text-render ass, a script drawtext cannot shape, or emoji drawn through libass or as PNGs"}],
|
|
168
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
169
|
+
"sync": dict(role="analysis_and_execution", inputs=["reference recording (video or audio)", "second recording (video or audio)"], outputs=["offset / drift JSON on stdout", "aligned artifact with --replace-audio / --trim-second / --fix-drift -o"],
|
|
170
|
+
required=FF, optional=[{"capability": AAC, "when": "writing a video container"}] + AUDIO_OUT,
|
|
171
|
+
video_required=False, audio_only=True, visual=False, verify=["probe"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
172
|
+
"multicam": dict(role="execution", inputs=["reference camera", "other cameras / recorders"], outputs=["switched multicam video artifact"],
|
|
173
|
+
required=FF + [X264, AAC], optional=[HDR_X265],
|
|
174
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
175
|
+
"audio": dict(role="execution", inputs=["video or audio asset", "music bed (--music) or replacement track (--replace)", "effects/atmos track (--effects)"], outputs=["artifact with the processed audio (video stream-copied, or dropped when -o has an audio extension)"],
|
|
176
|
+
required=FF, optional=[{"capability": "filter:afftdn", "when": "--denoise / --voice"}, {"capability": "filter:sidechaingate", "when": "--duck"}, {"capability": "filter:dcshift", "when": "--duck"},
|
|
177
|
+
{"capability": "filter:acompressor", "when": "--compress / --voice"}, {"capability": "filter:alimiter", "when": "--limit / --voice strong"}, {"capability": "filter:agate", "when": "--gate"},
|
|
178
|
+
{"capability": "filter:deesser", "when": "--voice medium (the default) / --voice strong"},
|
|
179
|
+
{"capability": "filter:extrastereo", "when": "--stereo-widen"},
|
|
180
|
+
{"capability": "filter:atempo", "when": "--tempo"},
|
|
181
|
+
{"capability": AAC, "when": "output extension isn't .wav/.aif/.aiff/.caf/.mp3/.opus/.ogg/.flac/.mka (audio_codec_for()'s default)"}] + AUDIO_OUT,
|
|
182
|
+
video_required=False, audio_only=True, visual=False, verify=["probe"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
183
|
+
"loudness": dict(role="analysis_and_execution", inputs=["video or audio asset"], outputs=["loudness measurement JSON (--measure-only)", "normalised artifact (video copied when the output keeps picture, audio extracted for an audio-only extension)"],
|
|
184
|
+
required=FF + ["filter:loudnorm"], optional=[{"capability": AAC, "when": "output extension isn't .wav/.aif/.aiff/.caf/.mp3/.opus/.ogg/.flac/.mka (audio_codec_for()'s default)"}] + AUDIO_OUT,
|
|
185
|
+
video_required=False, audio_only=True, visual=False, verify=["probe", "check"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
186
|
+
"silence": dict(role="analysis_and_execution", inputs=["video or audio asset"], outputs=["silence list JSON (--list)", "artifact with silences removed", "EDL text (--edl)", "pacing-profile@1 (--extract-profile)", "pacing-cut-plan@1 and verified MKV master or MP4 delivery (--profile)"],
|
|
187
|
+
required=FF + ["filter:silencedetect"], optional=[{"capability": "encoder:ffv1", "when": "--profile renders a master"},
|
|
188
|
+
{"capability": "bsf:setts", "when": "--profile preserves the kept final frame duration"},
|
|
189
|
+
{"capability": "filter:scdet", "when": "--extract-profile on video"},
|
|
190
|
+
{"capability": "filter:loudnorm", "when": "--extract-profile"},
|
|
191
|
+
{"capability": X264, "when": "editing an ordinary video or encoding a pacing MP4 delivery"}, HDR_X265, {"capability": AAC, "when": "removing silences from a video"},
|
|
192
|
+
{"capability": "external:whisper", "when": "--transcribe (with --filler or a sentence flag)"},
|
|
193
|
+
{"capability": "external:parakeet", "when": "--transcribe (with --filler or a sentence flag; English; either engine family satisfies it)"}] + AUDIO_OUT,
|
|
194
|
+
video_required=False, audio_only=True, visual=False, verify=["probe"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
195
|
+
"join": dict(role="execution", inputs=["two or more video assets, or two or more audio-only assets"], outputs=["concatenated video artifact", "concatenated audio artifact (audio-only inputs, audio output extension)"],
|
|
196
|
+
required=FF + ["filter:xfade", "filter:acrossfade"],
|
|
197
|
+
optional=[{"capability": X264, "when": "joining video inputs"}, {"capability": AAC, "when": "joining video inputs, or an audio-only join whose output extension isn't .wav/.aif/.aiff/.caf/.mp3/.opus/.ogg/.flac/.mka"}, HDR_X265] + AUDIO_OUT,
|
|
198
|
+
video_required=False, audio_only=True, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
199
|
+
"color": dict(role="execution", inputs=["video asset", ".cube LUT (--lut)"], outputs=["video artifact with converted colour"],
|
|
200
|
+
required=FF, optional=[{"capability": X264, "when": "--to-sdr / --lut / --correct"}, {"capability": "filter:zscale", "when": "--to-sdr"}, {"capability": "filter:tonemap", "when": "--to-sdr"},
|
|
201
|
+
{"capability": "filter:lut3d", "when": "--lut"}, {"capability": "filter:lutyuv", "when": "--legalize"}, {"capability": "filter:signalstats", "when": "--legalize (the measurement of the written file)"}, {"capability": "bsf:filter_units", "when": "--strip-dovi"}, {"capability": "bsf:h264_metadata", "when": "--retag on H.264 (without it the video is re-encoded)"},
|
|
202
|
+
{"capability": "bsf:hevc_metadata", "when": "--retag on HEVC (without it the video is re-encoded)"},
|
|
203
|
+
{"capability": "bsf:mpeg2_metadata", "when": "--retag on MPEG-2 (without it the video is re-encoded)"}, {"capability": "bsf:av1_metadata", "when": "--retag on AV1 (without it the video is re-encoded)"},
|
|
204
|
+
{"capability": "bsf:vp9_metadata", "when": "--retag on VP9 (without it the video is re-encoded)"}, {"capability": X265, "when": "--lut on an HDR source"}, {"capability": AAC, "when": "re-encode"},
|
|
205
|
+
{"capability": "filter:exposure", "when": "--correct"}, {"capability": "filter:eq", "when": "--correct"},
|
|
206
|
+
{"capability": "filter:colorbalance", "when": "--correct"}, {"capability": "filter:colortemperature", "when": "--correct"},
|
|
207
|
+
{"capability": "filter:colorlevels", "when": "--correct with any --levels-*"}, {"capability": "filter:curves", "when": "--correct --curves"}],
|
|
208
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
209
|
+
"proxy": dict(role="execution", inputs=["video asset"], outputs=["low-resolution, low-bitrate proxy artifact for downstream analysis, preview or editing decisions"],
|
|
210
|
+
required=FF + [X264, AAC], optional=[HDR_X265],
|
|
211
|
+
video_required=True, audio_only=False, visual=True, verify=["probe", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
212
|
+
"export": dict(role="execution", inputs=["video asset"], outputs=["delivery artifact in the preset's format"],
|
|
213
|
+
required=FF, optional=[{"capability": X264, "when": "preset youtube / youtube4k / reels / x"}, {"capability": AAC, "when": "preset youtube / youtube4k / reels / x / h265 (prores and dnxhr-* use pcm_s16le, copy stream-copies, gif has no audio)"},
|
|
214
|
+
{"capability": X265, "when": "preset h265 / youtube-hdr"}, {"capability": "encoder:libsvtav1", "when": "preset youtube-av1 (libaom-av1 is the fallback)"}, {"capability": "encoder:prores_ks", "when": "preset prores"}, {"capability": "encoder:dnxhd", "when": "preset dnxhr-lb / dnxhr-sq / dnxhr-hq / dnxhr-hqx / dnxhr-444"}, {"capability": "encoder:prores_ks", "when": "preset prores4444 / prores4444xq / key-fill"}, {"capability": "encoder:qtrle", "when": "preset qtrle"}, {"capability": "encoder:libvpx-vp9", "when": "preset vp9-alpha"}, {"capability": "encoder:hap", "when": "preset hap-alpha (an ffmpeg built with snappy)"}, {"capability": "filter:alphaextract", "when": "an alpha preset (the alpha is read back)"},
|
|
215
|
+
{"capability": "filter:palettegen", "when": "preset gif"}, {"capability": "encoder:gif", "when": "preset gif"}, {"capability": "filter:boxblur", "when": "--pad-fill blur or --fit blur"},
|
|
216
|
+
{"capability": "filter:eq", "when": "--fit blur (the background copy is dimmed)"},
|
|
217
|
+
{"capability": "filter:loudnorm", "when": "preset youtube / youtube4k / reels / x with audio: the written file is measured against the platform's loudness target (result `loudness`)"}],
|
|
218
|
+
video_required=True, audio_only=False, visual=False, verify=["probe", "check"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
219
|
+
"check": dict(role="verification", inputs=["media artifact"], outputs=["compliance rows JSON on stdout (no file)"],
|
|
220
|
+
required=["ffprobe"], optional=[{"capability": "ffmpeg", "when": "loudness rows (default); the audio row's volumedetect silence test when loudness is skipped"}, {"capability": "filter:loudnorm", "when": "loudness rows (default)"},
|
|
221
|
+
{"capability": "filter:blackdetect", "when": "--content (black row)"}, {"capability": "filter:freezedetect", "when": "--content (frozen row)"},
|
|
222
|
+
{"capability": "filter:silencedetect", "when": "--content (silence row)"},
|
|
223
|
+
{"capability": "filter:signalstats", "when": "--levels (legal levels row)"}, {"capability": "filter:lutyuv", "when": "--levels (legal levels row)"},
|
|
224
|
+
{"capability": "filter:blend", "when": "--expect-changed (change_scope row)"}],
|
|
225
|
+
video_required=False, audio_only=True, visual=False, verify=[], produces_artifact=False, idempotency="bit_exact", deterministic=True),
|
|
226
|
+
"scenes": dict(role="analysis", inputs=["video asset", "audio asset (after 3.2.0: one scene; --beats, --audio-peaks, --speech, --highlights; --sheet and --shots need a picture)"], outputs=["scene / audio-peak / highlight JSON on stdout", "EDL text (--edl)", "per-scene contact sheet PNG (--sheet)"],
|
|
227
|
+
required=FF + ["filter:scdet"], optional=[{"capability": "filter:drawtext", "when": "--sheet"}, {"capability": "filter:tile", "when": "--sheet"},
|
|
228
|
+
{"capability": "ffmpeg", "when": "--beats (one audio decode for the onset pass)"}],
|
|
229
|
+
video_required=False, audio_only=True, visual=False, verify=[], produces_artifact=True, idempotency="bit_exact", deterministic=True),
|
|
230
|
+
"look": dict(role="verification", inputs=["video artifact"], outputs=["PNG contact sheet / frames / side-by-side"],
|
|
231
|
+
required=FF + ["filter:tile"], optional=[{"capability": "filter:drawtext", "when": "timecode stamps (default; without drawtext the sheet is drawn without them, fallback look_no_drawtext)"},
|
|
232
|
+
{"capability": "filter:drawbox", "when": "--safe NAME (the platform's occluded zones)"}, {"capability": "filter:zscale", "when": "HDR source"}, {"capability": "filter:tonemap", "when": "HDR source"}],
|
|
233
|
+
video_required=True, audio_only=False, visual=False, verify=[], produces_artifact=True, idempotency="bit_exact", deterministic=True),
|
|
234
|
+
"render": dict(role="execution", inputs=["project.json (clips, transitions, captions, overlays, audio, loudness, export, check)", "media asset plus --template NAME (a shipped delivery template)"], outputs=["final video artifact", "one artifact per destination plus a pack table (--template all)", "work directory of stage outputs (--keep / --work)", "editor timeline (.fcpxml / .edl / .otio) instead of a render (--export-timeline)"],
|
|
235
|
+
required=FF, optional=[{"capability": "delegated", "when": "each stage (and each destination of --template) runs cut / join / fit / caption / graphics / overlay / audio / loudness / export / check with their capabilities"}],
|
|
236
|
+
video_required=False, audio_only=True, visual=True, verify=["probe", "check", "look"], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
237
|
+
"batch": dict(role="execution", inputs=["folder of media", "batch.json recipe (steps or a render project)"], outputs=["one artifact per input file in the recipe's output_dir (none for a steps recipe, not a render project, in which no step names {out}: its rows carry written: false)", "content-hash cache"],
|
|
238
|
+
required=FF, optional=[{"capability": "delegated", "when": "each recipe step runs the named script with its capabilities"}],
|
|
239
|
+
video_required=False, audio_only=True, visual=False, verify=["probe"], produces_artifact=True, idempotency="cached", deterministic=True),
|
|
240
|
+
"verify": dict(role="verification", inputs=["media files and/or folders"], outputs=["PASS/FAIL JSON per step", "Markdown report (--report)", "step outputs (--out / --keep)"],
|
|
241
|
+
required=FF, optional=[{"capability": "delegated", "when": "runs cut / fit / caption / export / loudness / color on each file"}],
|
|
242
|
+
video_required=False, audio_only=True, visual=False, verify=[], produces_artifact=True, idempotency="environment_dependent", deterministic=False),
|
|
243
|
+
"report": dict(role="verification", inputs=["deliverable (--after)", "source (--before)", "commands / notes text"], outputs=["single-file HTML delivery report"],
|
|
244
|
+
required=FF + ["filter:loudnorm"], optional=[{"capability": "delegated", "when": "runs look (sheets) and check (--platform)"}],
|
|
245
|
+
video_required=False, audio_only=True, visual=False, verify=[], produces_artifact=True, idempotency="content_equivalent", deterministic=True),
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
# Dry-run behaviour a parser cannot express (measured in tests/test_contract.py with a fake ffmpeg
|
|
249
|
+
# on PATH). "analysis_only": ffmpeg still decodes/measures the input under --dry-run, but nothing
|
|
250
|
+
# is encoded and no file is written. Every other tool with the flag runs no ffmpeg at all.
|
|
251
|
+
DRY_RUN_ANALYSIS = {
|
|
252
|
+
# #466 A193: probe was "none" with an ffprobe note while --analyze decoded with ffmpeg
|
|
253
|
+
"probe": "read-only tool; --dry-run changes nothing: ffprobe still runs, and only with --analyze ffmpeg decodes the first 20 s of each video input to sample picture levels",
|
|
254
|
+
"sync": "audio is decoded to find the offset; the aligned output is not written",
|
|
255
|
+
"multicam": "audio is decoded to align the cameras; the switched output is not written",
|
|
256
|
+
"scenes": "scene and audio-peak measurement runs; --sheet and --edl are not written",
|
|
257
|
+
"report": "probe and loudness measurements run (and check.py, with --platform); contact sheets are not drawn under --dry-run (a report_section_dry_run skip); the HTML is not written",
|
|
258
|
+
"cropdetect": "the cropdetect filter runs over the sampled windows to measure bars; this tool never writes a file regardless of --dry-run",
|
|
259
|
+
"silence": "with --profile or --extract-profile, pacing measurements run without publishing any file; otherwise silencedetect runs so the reported silences and keep ranges are real; the cut output is not written. --filler --transcribe also runs the speech engine (its word timings are what the filler spans are planned on), which may download a model on first use; so does --transcribe with --sentence-min-silence or --sentence-margin-tail",
|
|
260
|
+
"loudness": "the loudnorm measurement pass runs so input_i and the planned pass-2 command are real; the normalised output is not written",
|
|
261
|
+
"check": "read-only tool; the loudness measurement (or, when it is skipped, the audio row's volumedetect) and the --content decode run under --dry-run too, so every row is present",
|
|
262
|
+
"stabilize": "vidstabdetect (pass 1, into a temp file) runs; the stabilised output (pass 2) is not written",
|
|
263
|
+
"metadata": "only with --auto-chapters: its silence and scene measurement decodes the input so the proposed chapters are real; otherwise no ffmpeg runs, and the tagged output is never written",
|
|
264
|
+
"cut": "only with --snap beats (and no --snap-source): the audio is decoded to find the beat grid the in/out points snap to; otherwise no ffmpeg runs, and the cut is never written",
|
|
265
|
+
"render": "each stage runs as its own --dry-run, so a stage whose input exists measures it as that tool does under --dry-run (a clip's --snap beats cut, a loudness or silence pass on a source); a stage whose input an earlier stage would write is not measured (measurement_input_pending); nothing is written",
|
|
266
|
+
"batch": "each recipe step runs as its own --dry-run on the item's source, so a step that measures (loudness, silence, check, a --snap beats cut, a render project's stages) measures it; an item a real run would serve from the cache is served as that run serves it (cached: true, its row as the run that stored it measured, no step planned); nothing is written",
|
|
267
|
+
"overlay": "only for a multi-line --text on FFmpeg 8.0, 8.0.1 or 8.1.0: one drawtext measures each line on a generated one-frame picture (the input is not read), so the planned per-line positions are the ones a run uses; otherwise no ffmpeg runs and the composited output is never written",
|
|
268
|
+
}
|
|
269
|
+
DRY_RUN_NOTES = {
|
|
270
|
+
"verify": "in the legacy footage suite the flag is accepted but the steps run and outputs are written; --profile runs a read-only source/output gate, including under --dry-run",
|
|
271
|
+
"sequence": "no ffmpeg runs; ffprobe decodes every frame of the sequence once, and when that check completes a frame that does not decode as an image is refused (still_unreadable) as in a real run; when ffprobe fails on the frame list or reads back no frame, a note says the frames were not checked and the dry run completes; the video is not written",
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
# Whether a tool re-encodes each stream *when that stream is present in the input* -- not whether
|
|
275
|
+
# the tool touches the file at all. "always"/"never" are unconditional given that stream exists;
|
|
276
|
+
# "conditional" means it depends on flags or on how far a lossless attempt misses (see "note").
|
|
277
|
+
# Read from each script's actual encode/copy args, not from role or intent, since several tools
|
|
278
|
+
# (fit, caption, overlay, graphics, color, join, multicam, silence) always transcode audio to AAC
|
|
279
|
+
# alongside a video filter even though the audio itself is untouched content -- there is no
|
|
280
|
+
# "-c:a copy while re-encoding video" path in this codebase, so a soft-subtitle-style passthrough
|
|
281
|
+
# of the original audio codec never happens on those tools.
|
|
282
|
+
REENCODE_META: Dict[str, Dict[str, str]] = {
|
|
283
|
+
"probe": dict(video="never", audio="never", note="analysis only, no artifact"),
|
|
284
|
+
"cut": dict(video="conditional", audio="conditional", note="lossless -c copy preferred; --smart copies the whole GOPs inside a cut and re-encodes the partial ones at its ends; re-encodes on --accurate, --codec, a VFR source (--vfr-guard), a keyframe snap past --tolerance, or a --segments join the parts cannot stream-copy (see cut.py --json: mode, reencode_reason, keyframe_snapped)"),
|
|
285
|
+
"fit": dict(video="always", audio="always", note="always re-encodes to AAC when audio is present, even if only --fps or --aspect was asked for"),
|
|
286
|
+
"crop": dict(video="always", audio="always", note="the crop filter always forces a re-encode of both streams"),
|
|
287
|
+
"deinterlace": dict(video="always", audio="always", note="the yadif filter always forces a re-encode of the video stream; audio is re-encoded to AAC when present"),
|
|
288
|
+
"denoise": dict(video="always", audio="always", note="the hqdn3d filter always forces a re-encode of the video stream; audio is re-encoded to AAC when present"),
|
|
289
|
+
"cropdetect": dict(video="never", audio="never", note="analysis only, no artifact"),
|
|
290
|
+
"redact": dict(video="always", audio="always", note="the boxblur, pixelate or delogo graph always forces a re-encode of the video stream; audio is re-encoded to AAC when present"),
|
|
291
|
+
"waveform": dict(video="always", audio="conditional", note="a visualization clip is always encoded fresh, and the source audio re-encoded to AAC in it; --at writes waveform PNGs and no audio at all"),
|
|
292
|
+
"sphere": dict(video="always", audio="always", note="the v360 filter always forces a re-encode of the video stream; audio is passed through to AAC unchanged"),
|
|
293
|
+
"straighten": dict(video="always", audio="always", note="the rotate filter always forces a re-encode of the video stream; audio is re-encoded to AAC when present"),
|
|
294
|
+
"grid": dict(video="always", audio="conditional", note="the xstack composite always forces a re-encode of the video stream; there is no audio at all unless --audio-from picks one input's track, which is then re-encoded to AAC"),
|
|
295
|
+
"freeze": dict(video="always", audio="always", note="the tpad/concat filter graph always forces a re-encode of the video stream; audio is re-encoded to AAC when present"),
|
|
296
|
+
"pad": dict(video="always", audio="always", note="the tpad filter always forces a re-encode of the video stream; audio is re-encoded to AAC when present"),
|
|
297
|
+
"speedramp": dict(video="always", audio="always", note="setpts/atempo per segment always forces a re-encode of both streams"),
|
|
298
|
+
"broll": dict(video="always", audio="conditional", note="the overlay graph always re-encodes the video stream; A's audio is stream-copied under --audio a and re-encoded to AAC under --audio b/mix"),
|
|
299
|
+
"metadata": dict(video="never", audio="never", note="-c copy on every stream; only the container's chapters and tags change -- --auto-chapters decodes to measure, but still writes with -c copy"),
|
|
300
|
+
"loop": dict(video="always", audio="conditional", note="the repeats (the concat demuxer, the file listed once per repeat) always re-encode both streams; the audio codec is always AAC when present. --crossfade first writes one repeat losslessly (FFV1 + FLAC, a temporary file) and repeats that, so the output still has one lossy encode. --boomerang re-encodes the video through reverse/loop filters and drops the audio"),
|
|
301
|
+
"insert": dict(video="always", audio="never", note="always encodes a fresh silent clip from the still image; there is no audio stream to touch"),
|
|
302
|
+
"background": dict(video="always", audio="never", note="always encodes a fresh generated clip; there is no input to copy from"),
|
|
303
|
+
"reverse": dict(video="always", audio="conditional", note="video always re-encodes (reverse buffers and re-emits every frame); audio re-encodes to AAC when present and not dropped by --no-audio"),
|
|
304
|
+
"stabilize": dict(video="always", audio="conditional", note="video always re-encodes (two-pass vidstab); audio is re-encoded to AAC when present, never touched by the stabilization filters themselves"),
|
|
305
|
+
"sequence": dict(video="always", audio="never", note="always encodes a fresh clip from the frame sequence; there is no audio stream"),
|
|
306
|
+
"caption": dict(video="conditional", audio="conditional", note="--mode burn (default) always re-encodes both streams to render pixels; --mode mux copies video and audio untouched and only adds a subtitle stream"),
|
|
307
|
+
"overlay": dict(video="always", audio="always"),
|
|
308
|
+
"graphics": dict(video="always", audio="always"),
|
|
309
|
+
"sync": dict(video="conditional", audio="conditional", note="video is -c:v copy only for --replace-audio (the reference picture) while that copy succeeds; --trim-second always re-encodes a video second file, since a copy would start at the keyframe before the trim point; a sound-only second file that started earlier is stream-copied"),
|
|
310
|
+
"multicam": dict(video="always", audio="always"),
|
|
311
|
+
"audio": dict(video="never", audio="always", note="video stream is always -c:v copy when present; this tool's job is the audio"),
|
|
312
|
+
"loudness": dict(video="never", audio="always"),
|
|
313
|
+
"silence": dict(video="always", audio="always", note="removing gaps requires cutting on non-keyframe boundaries"),
|
|
314
|
+
"join": dict(video="conditional", audio="conditional", note="--copy --transition none is -c copy of the first video and audio stream (clips with matching parameters only); every other join re-encodes both"),
|
|
315
|
+
"color": dict(video="conditional", audio="conditional", note="--strip-dovi and --retag (when the stream copy succeeds) are -c copy of both streams; --retag falls back to re-encoding only if the copy attempt fails or ffprobe still reads the old tags on the copy (a codec with no metadata bitstream filter here); --to-sdr / --lut / --correct always re-encode both"),
|
|
316
|
+
"proxy": dict(video="always", audio="conditional", note="video is always re-encoded at proxy-grade quality; audio is re-encoded when present, dropped entirely with --no-audio or when the source has none"),
|
|
317
|
+
"export": dict(video="conditional", audio="conditional", note="--preset copy is -c:v copy -c:a copy (no re-encode); every other preset re-encodes both"),
|
|
318
|
+
"check": dict(video="never", audio="never", note="read-only, no artifact"),
|
|
319
|
+
"scenes": dict(video="never", audio="never", note="analysis only; --sheet renders a new contact-sheet PNG, not a re-encode of the source"),
|
|
320
|
+
"look": dict(video="never", audio="never", note="renders a new contact-sheet/frame PNG, not a re-encode of the source"),
|
|
321
|
+
"render": dict(video="conditional", audio="conditional", note="delegated: depends on which stages a project.json runs and how each one behaves"),
|
|
322
|
+
"batch": dict(video="conditional", audio="conditional", note="delegated: depends on which script each recipe step runs"),
|
|
323
|
+
"verify": dict(video="conditional", audio="conditional", note="delegated: runs cut/fit/caption/export/loudness/color internally as checks"),
|
|
324
|
+
"report": dict(video="never", audio="never", note="measures via look/check; produces an HTML report, not a re-encoded artifact"),
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
IDEMPOTENCY = {
|
|
328
|
+
"bit_exact": "same inputs and flags give byte-identical output (with the CPU encoders: under --hw / $FFMPEG_SKILL_HW a "
|
|
329
|
+
"VideoToolbox encode is content_equivalent at best)",
|
|
330
|
+
"content_equivalent": "same inputs and flags give the same media content; bytes may differ between encoder builds",
|
|
331
|
+
"cached": "re-runs skip inputs whose content hash and recipe are unchanged",
|
|
332
|
+
"environment_dependent": "output includes timings or machine state and differs between runs",
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
# ----------------------------------------------------------------------------- parsers
|
|
337
|
+
class _Captured(Exception):
|
|
338
|
+
def __init__(self, parser: argparse.ArgumentParser) -> None:
|
|
339
|
+
self.parser = parser
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def _capture_parser(script: Path) -> argparse.ArgumentParser:
|
|
343
|
+
"""Import the script and run main() until parse_args() to get its live parser."""
|
|
344
|
+
original = argparse.ArgumentParser.parse_args
|
|
345
|
+
|
|
346
|
+
def fake_parse(self: argparse.ArgumentParser, *a: Any, **k: Any) -> Any:
|
|
347
|
+
raise _Captured(self)
|
|
348
|
+
|
|
349
|
+
argparse.ArgumentParser.parse_args = fake_parse # type: ignore[assignment]
|
|
350
|
+
sys_argv = sys.argv
|
|
351
|
+
try:
|
|
352
|
+
sys.argv = [str(script)]
|
|
353
|
+
spec = importlib.util.spec_from_file_location("ffskill_tool_" + script.stem, script)
|
|
354
|
+
module = importlib.util.module_from_spec(spec)
|
|
355
|
+
assert spec.loader is not None
|
|
356
|
+
spec.loader.exec_module(module)
|
|
357
|
+
module.main()
|
|
358
|
+
except _Captured as cap:
|
|
359
|
+
return cap.parser
|
|
360
|
+
finally:
|
|
361
|
+
argparse.ArgumentParser.parse_args = original # type: ignore[assignment]
|
|
362
|
+
sys.argv = sys_argv
|
|
363
|
+
raise RuntimeError(f"{script.name}: main() returned before parse_args()")
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def _json_type(action: argparse.Action) -> Dict[str, Any]:
|
|
367
|
+
if isinstance(action, argparse._StoreTrueAction):
|
|
368
|
+
return {"type": "boolean"}
|
|
369
|
+
if isinstance(action, argparse._AppendAction) or action.nargs in ("+", "*"):
|
|
370
|
+
return {"type": "array", "items": {"type": "string"}}
|
|
371
|
+
if action.type is int:
|
|
372
|
+
return {"type": "integer"}
|
|
373
|
+
if action.type is float:
|
|
374
|
+
return {"type": "number"}
|
|
375
|
+
return {"type": "string"}
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def input_schema(parser: argparse.ArgumentParser) -> Dict[str, Any]:
|
|
379
|
+
props: Dict[str, Any] = {}
|
|
380
|
+
required: List[str] = []
|
|
381
|
+
positional: List[str] = []
|
|
382
|
+
common = {"dry_run", "json", "progress", "fast", "timeout", "overwrite", "plan", "codec", "quality", "hw", "no_hw"}
|
|
383
|
+
for action in parser._actions:
|
|
384
|
+
if isinstance(action, argparse._HelpAction):
|
|
385
|
+
continue
|
|
386
|
+
prop: Dict[str, Any] = _json_type(action)
|
|
387
|
+
default = action.default
|
|
388
|
+
if action.help and action.help != argparse.SUPPRESS:
|
|
389
|
+
prop["description"] = action.help % {"default": default} if "%(default)" in action.help else action.help
|
|
390
|
+
if action.choices:
|
|
391
|
+
prop["enum"] = list(action.choices)
|
|
392
|
+
if default not in (None, False, argparse.SUPPRESS):
|
|
393
|
+
prop["default"] = default
|
|
394
|
+
if action.option_strings:
|
|
395
|
+
prop["cli"] = list(action.option_strings)
|
|
396
|
+
if action.required:
|
|
397
|
+
required.append(action.dest)
|
|
398
|
+
else:
|
|
399
|
+
prop["cli"] = "positional"
|
|
400
|
+
positional.append(action.dest)
|
|
401
|
+
if action.nargs not in ("?", "*"):
|
|
402
|
+
required.append(action.dest)
|
|
403
|
+
if action.dest in common:
|
|
404
|
+
prop["common"] = True
|
|
405
|
+
if action.dest in props:
|
|
406
|
+
# one property per dest: a second action (a store_false --no-x beside a store_true --x)
|
|
407
|
+
# would replace the first, and the contract and MCP would publish only the second flag
|
|
408
|
+
# under the first one's name -- an MCP `x: true` would then send --no-x
|
|
409
|
+
first = props[action.dest]["cli"]
|
|
410
|
+
raise RuntimeError(f"{parser.prog}: {'/'.join(action.option_strings) or action.dest} shares dest {action.dest!r} "
|
|
411
|
+
f"with {'/'.join(first) if isinstance(first, list) else 'a positional'}; give each flag its own dest")
|
|
412
|
+
props[action.dest] = prop
|
|
413
|
+
groups = [g for g in getattr(parser, "_mutually_exclusive_groups", []) if g._group_actions]
|
|
414
|
+
schema: Dict[str, Any] = {"type": "object", "properties": props, "required": required, "positional": positional, "additionalProperties": False}
|
|
415
|
+
if groups:
|
|
416
|
+
schema["mutually_exclusive"] = [[a.dest for a in g._group_actions] for g in groups]
|
|
417
|
+
schema["one_of_required"] = [[a.dest for a in g._group_actions] for g in groups if g.required]
|
|
418
|
+
return schema
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
# The collector's records (docs/design-decisions.md, "Nothing happens silently"): on success and
|
|
422
|
+
# failure documents alike, present only when one list is not empty.
|
|
423
|
+
DIAGNOSTICS_SCHEMA = {
|
|
424
|
+
"type": "object",
|
|
425
|
+
"description": "what the run decided on its own, recorded as it happened (each also a stderr line): warnings (something went "
|
|
426
|
+
"other than asked), fallbacks (another route was taken and the run went on), skipped (a step that would "
|
|
427
|
+
"normally run did not). Each entry is {code, message, ...facts}; an entry a render.py stage reported carries "
|
|
428
|
+
"`stage`. Absent when all three are empty",
|
|
429
|
+
"properties": {k: {"type": "array", "items": {"type": "object", "properties": {"code": {"type": "string"}, "message": {"type": "string"}}}}
|
|
430
|
+
for k in ("warnings", "fallbacks", "skipped")},
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
# error.reason: a stable code for why a refusal happened, beside `kind` (which says what class of
|
|
434
|
+
# failure it is). Every refuse() call in scripts/ names one of these (a test reads the sources).
|
|
435
|
+
ERROR_REASONS = {
|
|
436
|
+
"step_writes_without_out": "kind input: batch.py: a recipe step names no {out} (and no -o of its own) but its --json document reports an output file, its own default output, which the next step does not read and the batch does not deliver; the batch stops at that item (later items: skipped recipe_refused). Under --dry-run nothing is written; a real run has written that one file and leaves it. details: {step, tool, file, written, files, written_files, not_started}",
|
|
437
|
+
"disk_full": "kind ffmpeg: ffmpeg reported \"No space left on device\" while writing; the hint says to free space or write elsewhere; details: {}",
|
|
438
|
+
"filter_missing": "kind ffmpeg: this ffmpeg build lacks a filter the command names: for a command run() is given (not a run_analysis() measurement pass), refused before ffmpeg runs, dry runs included, when the build's filter list was read and lacks it, else ffmpeg's own \"No such filter\"; render.py and waveform.py with a title or captions run their own dry run first and are refused with its document (the stage's message, details and stage) before the first stage encodes; details: {name}; the hint points at doctor",
|
|
439
|
+
"input_incomplete": "kind ffmpeg: the input has no index (\"moov atom not found\") or the demuxer reports premature EOF/partial file, even with exit 0; missing media cannot be rebuilt; details: {}",
|
|
440
|
+
"input_unreadable": "kind ffmpeg: ffmpeg could not read the input as media (\"Invalid data found when processing input\"); details: {}",
|
|
441
|
+
"ffmpeg_unsupported": "kind missing_tool: the ffmpeg/ffprobe on PATH reports a version older than 6.1, which 3.0.0 no longer supports (5.x was deprecated in 2.14.0); details: {version, required}",
|
|
442
|
+
"read_only_plan_refused": "--plan in a process run with FFMPEG_SKILL_READ_ONLY=1 (mcp/server.py sets it for the tools annotated readOnlyHint: probe, check, cropdetect), which must write no file; details: {plan}",
|
|
443
|
+
"output_exists": "an output already exists and --overwrite was not given; details.outputs: [{path, resolved, size, mtime_ns}]",
|
|
444
|
+
"output_is_input": "the output resolves to the same file as an input; details: {output, input, resolved}",
|
|
445
|
+
"output_is_directory": "the output path is a directory; details: {output}",
|
|
446
|
+
"media_path_is_playlist": "an input is a playlist that ffmpeg would follow to the files or URLs it names: HLS .m3u8/.m3u or an ffconcat list (by name or by its first bytes), a DASH manifest or an IMF composition playlist (by name or by the content ffmpeg's own probe looks for, whatever the file is called); the skill takes media files only; details: {path}",
|
|
447
|
+
"media_path_has_line_break": "a path written into a concat list (loop.py, join.py --copy, sequence.py, multi-part cuts) contains a line break, which the concat format cannot hold: each line is a directive, so the name would add entries to the list; details: {path}",
|
|
448
|
+
"still_unreadable": "an input read by an image demuxer (a .png, .jpg, ... name) has a picture stream with no frame size: the file is not an image ffmpeg can decode (a text file named .png); details: {path, format, codec}. sequence.py: a frame of the sequence that does not decode (every frame is decoded once before the encode; when that check cannot be made, a note says so and nothing is refused); details: {path (the first), frames, frames_unreadable, frames_total}",
|
|
449
|
+
"input_is_directory": "an input given where a media file is read is a directory; details: {path}",
|
|
450
|
+
"input_empty": "an input is an empty file (0 bytes): the trace of a recording, download or render step that wrote nothing; details: {path}",
|
|
451
|
+
"input_not_media": "ffprobe could not read an input as media (a text file, a file cut short): the message carries ffprobe's own lines without their context addresses; details: {path}",
|
|
452
|
+
"input_permission_denied": "an input exists or may exist but the user this runs as may not read it, or may not search a directory on the way to it (EACCES, as opposed to a path that is not there, which stays \"input not found\" with no reason); dry runs included; details: {path}",
|
|
453
|
+
"media_path_not_a_file": "an input exists but is not a regular file (a FIFO or a device), which ffmpeg would block on or read as a stream; details: {path}",
|
|
454
|
+
"join_copy_mismatch": "join.py --copy: a clip's streams do not match the first clip's, it hides pre-roll frames with an edit list, or its picture and sound end more than 50 ms apart, or (AAC) a copy join would put the sound more than 50 ms behind or ahead of the picture at some clip (each later clip's priming played at its seam plus the difference between each clip's sound and picture; details also aac_drift_ms, negative when ahead, and tolerance_ms); details: {clips: [{index?, path, differs}]}",
|
|
455
|
+
"source_alpha_mode_needs_keep_alpha": "kind input: color.py --source-alpha-mode without --keep-alpha: the alpha is not kept, so there is no colour to divide it from",
|
|
456
|
+
"audio_cut_transition": "join.py --audio-lead/--audio-lag with a transition: the J-cut or L-cut is a plain cut (--transition none)",
|
|
457
|
+
"audio_cut_copy": "join.py --audio-lead/--audio-lag with --copy: picture and sound are cut at different times, which a stream copy cannot do",
|
|
458
|
+
"audio_cut_both_flags": "join.py --audio-lead and --audio-lag together: a J-cut and an L-cut are two different cuts",
|
|
459
|
+
"audio_cut_too_long": "join.py --audio-lead/--audio-lag under one frame of the output rate, or not shorter than a clip it takes from",
|
|
460
|
+
"track_container": "audio.py --track with an output that cannot hold several named audio streams: anything but .mov, .mkv or .mp4 (a WAV, FLAC or MP3 holds one stream; FFmpeg's MXF muxer writes no track names or languages and cuts every track to the shortest); details: {output, extension}",
|
|
461
|
+
"track_rebuilds_sound": "audio.py --track beside a flag that changes the sound (--voice, --gain, --music, --replace, --stereo, --sample-rate, ...): --track writes every track as it is; details: {flags}",
|
|
462
|
+
"track_labels": "audio.py: more --track-name or --track-lang values than tracks (the input's own sound is track 0, then each --track); details: {flag, given, tracks}",
|
|
463
|
+
"track_language": "audio.py --track-lang is not an ISO 639-2 code (three lowercase letters); details: {language}",
|
|
464
|
+
"fit_method_required":"fit.py --duration would retime the clip beyond 1.15x in either direction without a method or an explicit slow-motion filter; details: {factor, threshold, source_duration, target_duration}",
|
|
465
|
+
"output_path_taken": "two files one run writes (a side file and the output, or two side files) resolve to the same path, so the second would replace the first; details: {output, other}",
|
|
466
|
+
"output_looks_like_option": "the output starts with '-' (other than '-' for stdout), which ffmpeg would read as an option; ./name writes a file of that name; details: {output}",
|
|
467
|
+
"media_path_is_url": "an input or output has a protocol prefix (tcp:, http://, file:, ...) that ffmpeg would open as a URL; the skill reads and writes local files only; details: {path, scheme}",
|
|
468
|
+
"output_dir_missing": "the output's directory does not exist; details: {output, directory}",
|
|
469
|
+
"output_extension_missing": "a media output with no file extension (and no -f naming its format), so ffmpeg could not choose a container; refused before ffmpeg runs, dry runs included; details: {output}",
|
|
470
|
+
"output_extension_unknown": "a media output whose extension this ffmpeg build maps to no muxer (out.xyz), with no -f naming its format: ffmpeg chooses the container by the extension alone, so it could not; judged from the build's own muxer list (`ffmpeg -muxers`, each muxer's common extensions), asked only for an extension outside the common ones, and not refused when the build cannot be asked; refused before ffmpeg runs, dry runs included; the hint names extensions the tools write; details: {output, extension}",
|
|
471
|
+
"output_extension_unsupported": "an output name ffmpeg would split into files it names itself (.m3u8, .m3u, .mpd, or a numbered pattern such as frame%03d.png in an image name: the skill writes one file per -o); or a media output named .wma (from -o or the input's default name) that the run would encode into: the skill has no WMA encoder line and writes .wma only as a stream copy of WMA sound (wmav1, wmav2, wmapro, wmalossless, wmavoice) with no picture; the hint names the audio extensions it writes (.wav, .flac, .mp3, .m4a, .aac, .ogg, .opus, .aif, .aiff, .caf, .mka); refused before ffmpeg runs (loudness.py and silence.py before their measuring pass), dry runs included; details: {output, extension, written}",
|
|
472
|
+
"output_extension_audio_only": "a media output named with an audio-only extension (.wav, .m4a, .mp3, ...: every one the skill reads) whose command encodes a picture, that export.py, metadata.py or render.py would copy a picture into, or given to waveform.py: refused before delivery, dry runs included; name a video container, or extract the sound with cut.py or audio.py; details: {output, extension, encoders (empty for a copy and for waveform.py)}",
|
|
473
|
+
"output_dir_not_writable": "the output's directory is not writable; details: {output, directory}",
|
|
474
|
+
"output_container_codecs": "a .webm output whose command encodes video or sound WebM cannot hold (H.264/HEVC, AAC; WebM takes VP8/VP9/AV1 and Opus/Vorbis), refused before ffmpeg runs; details: {output, container, encoders}",
|
|
475
|
+
"timemap_path_taken": "silence.py --timemap names the same file as -o, --edl or --plan; details: {timemap, flag, path}",
|
|
476
|
+
"output_locked": "another run holds the output's lock, or is taking a stale one over (why: takeover_in_progress), or a stale lock cannot be taken over safely because the filesystem gives no OS file lock (why: takeover_unavailable: delete it by hand); details: {lock, output, pid, pid_alive, deadline, why}",
|
|
477
|
+
"plan_inputs_changed": "render.py PLAN: a fingerprinted input is missing or changed, or the ordered sequence differs; details: {plan, plan_sha256, checked_at, "
|
|
478
|
+
"inputs: [{path, status: unchanged|changed|missing, expected: {size, sha256_head_tail}, actual: {size, "
|
|
479
|
+
"sha256_head_tail} | \"missing\"}], unbound_inputs, audit_log}; sequence rows include sha256_full "
|
|
480
|
+
"when the plan records it. A sequence selection mismatch can instead "
|
|
481
|
+
"report {expected_frame_digest, actual_frame_digest}",
|
|
482
|
+
"plan_version_unsupported": "render.py PLAN: plan_version is not one this version executes; details: {plan, plan_sha256, checked_at, plan_version, supported, audit_log}",
|
|
483
|
+
"plan_unknown_tool": "render.py PLAN: the plan names no tool render.py can run; details: {plan, plan_sha256, checked_at, tool, audit_log}",
|
|
484
|
+
"plan_cwd_missing": "render.py PLAN: the directory the plan was made in is gone; details: {plan, plan_sha256, checked_at, cwd, audit_log}",
|
|
485
|
+
"plan_argv_invalid": "render.py PLAN: argv is not a list; details: {plan, plan_sha256, checked_at, argv_type, audit_log}",
|
|
486
|
+
"plan_field_invalid": "render.py PLAN: inputs, unbound_inputs, verify (objects), commands (strings) or cwd has the wrong JSON type, "
|
|
487
|
+
"or sequence_frames_sha256 is not a SHA-256 digest; "
|
|
488
|
+
"details: {plan, plan_sha256, checked_at, field, field_type, audit_log}",
|
|
489
|
+
"decoder_missing": "color.py / graphics.py / overlay.py: a VP9 source or --video layer stored with an alpha layer, on a build with no libvpx-vp9 decoder (FFmpeg's own VP9 decoder drops the alpha), kind missing_tool; details: {name}",
|
|
490
|
+
"encoder_missing": "--codec av1/prores: the build's encoder list was read and has no encoder for the codec (kind missing_tool; details: {codec, encoders}); or a command run() is given names an encoder the build lacks for a stream the output keeps (an HDR source kept as HEVC, --codec hevc, a preset's encoder; not -c:a for a source with no sound, or with -an): refused before ffmpeg runs, dry runs included, when the build's encoder list was read and lacks it, else ffmpeg's own \"Unknown encoder\" (kind ffmpeg; details: {name}; the hint points at doctor); render.py and waveform.py with a title or captions run their own dry run first and are refused with its document before the first stage encodes",
|
|
491
|
+
"asr_engine_missing": "kind missing_tool: --transcribe (caption.py; silence.py with --filler or a sentence flag) found no local speech-to-text engine; the message lists the install lines; details: {}",
|
|
492
|
+
"encoder_list_unreadable": "--codec av1/prores: the build's encoder list could not be read, so whether it has the encoder is unknown (kind ffmpeg); details: {codec, encoders, error}",
|
|
493
|
+
"audio_too_short": "kind input: loudness.py: the audio has a true peak but is shorter than one 400 ms gating block, so it has no integrated loudness to normalise from (not silence); details: {input_tp}",
|
|
494
|
+
"no_speech": "kind input: --transcribe (caption.py; silence.py with --filler or a sentence flag) ran a local speech engine that heard no speech in the input; details: {engine}; also top-level reason and engine",
|
|
495
|
+
"engine_failed": "kind input: --transcribe: an installed speech engine ran and failed (a named --engine, or every engine --engine auto found); details: {engine, detail | engines: [{engine, reason, detail}]}; also top-level reason, engine and detail/engines",
|
|
496
|
+
"english_only": "kind input: --transcribe under --engine auto found only Parakeet engines, which it runs for English speech only, and the language is not English or (4.0.0) is not known: no language was named, none could be detected, and the model is English-only; details: {engine, engines}; also top-level reason, engine and engines",
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
# The codes of the collector's records (docs/design-decisions.md, "Nothing happens silently"):
|
|
500
|
+
# code -> (bucket, what it records). Every warn()/record_fallback()/record_skip() literal under
|
|
501
|
+
# scripts/ is listed here under its bucket (a test reads the sources), so a caller can switch on
|
|
502
|
+
# a code the contract publishes.
|
|
503
|
+
DIAGNOSTIC_CODES = {
|
|
504
|
+
# infrastructure (part 1)
|
|
505
|
+
"stale_lock_taken_over": ("fallbacks", "a dead or past-deadline writer's output lock was taken over; {lock, output, pid, pid_alive, deadline, why}"),
|
|
506
|
+
"output_unlocked": ("warnings", "no output lock could be created and the run went on without one; {lock, output, error}"),
|
|
507
|
+
"lock_deadline_unset": ("warnings", "the lock's deadline (its mtime) could not be set; {lock, error}"),
|
|
508
|
+
"audit_log_unwritable": ("warnings", "an audit record could not be appended; never fails the run; {path, event, error}"),
|
|
509
|
+
"plan_unbound_inputs": ("warnings", "render.py PLAN: inputs that did not exist when the plan was made, so were not checked; {paths}"),
|
|
510
|
+
"plan_sequence_unbound": ("warnings", "render.py PLAN: an older sequence plan does not bind the ordered frame list"),
|
|
511
|
+
# the runner
|
|
512
|
+
"odd_dimensions_scaled_even": ("fallbacks", "an encode that failed on odd dimensions was run again scaled to even ones, or a graph the retry cannot reach (broll.py's filter_complex) was scaled to even ones up front (the frame loses a row or column); {output, scale}"),
|
|
513
|
+
"measurement_input_pending": ("skipped", "--dry-run: a measurement skipped because its input is an earlier stage's output that does not exist yet; {path}"),
|
|
514
|
+
"non_av_streams_dropped": ("fallbacks", "a subtitle or data stream could not be written into the output's container, so the command ran again without it; one record per retry: {output, returncode, error: the failed attempt's last stderr lines, dropped: the stream types that retry leaves out (data alone first, then subtitle too)}. dropped_non_av_streams says whether a stream is missing from the written file. metadata.py records it when a copied timecode track is refused by the MP4 muxer and the copy runs again without that track (the muxer writes it from the picture's timecode tag)"),
|
|
515
|
+
"ffmpeg_list_unreadable": ("warnings", "`ffmpeg -encoders` / `-bsfs` could not be read; what needs the list says so instead of 'the build lacks it'; {list, tool, error}"),
|
|
516
|
+
"timeout_env_invalid": ("warnings", "FFMPEG_SKILL_TIMEOUT was not a number (the default was used), or was negative or above 500000 s (read as 0, no limit); {value, timeout}"),
|
|
517
|
+
# encoder decisions
|
|
518
|
+
"av1_encoder_libaom": ("fallbacks", "--codec av1 on a build without libsvtav1: libaom-av1 encoded instead; {wanted, used}"),
|
|
519
|
+
"crf_clamped": ("warnings", "the CRF handed to the encoder was above its maximum and was capped (the HEVC HDR line adds 2); {encoder, requested, asked, used}"),
|
|
520
|
+
"large_speed_change": ("warnings", "fit.py: the requested whole-clip retime is beyond 1.15x in either direction; {factor, threshold, source_duration, target_duration}"),
|
|
521
|
+
# fonts and text
|
|
522
|
+
"emoji_not_drawn": ("warnings", "caption.py / graphics.py --emoji auto: no glyph, colour path or PNG asset draws these emoji here (doctor fonts.emoji mode none), so they were left out of the drawn text; also graphics.py --text-render drawtext, which has no font fallback; {count, reason}"),
|
|
523
|
+
"emoji_mono_drawn_in_colour": ("warnings", "caption.py / graphics.py --emoji mono on a build whose libass draws the emoji face in colour: nothing makes the glyph monochrome, so the result's emoji.mode is color (graphics.py --text-render drawtext draws none: mode none, emoji_not_drawn)"),
|
|
524
|
+
"hdr10_metadata_dropped": ("warnings", "a PQ output measured without the source's HDR10 mastering-display and/or content-light metadata (an encoder with no option for it, e.g. prores_ks or libaom on FFmpeg before 7); {dropped, codec}"),
|
|
525
|
+
"source_items_dropped": ("warnings", "the written file lacks a subtitle track, chapters, a cover picture, surround channels, attached files or a second video stream the first input carried (source_carry lists everything kept and dropped, tags included); not repeated for a subtitle track the tool already reports through dropped_non_av_streams; {dropped}"),
|
|
526
|
+
"audio_tracks_dropped": ("warnings", "the source has more audio tracks than the output kept (the tools write one; cut.py also reports dropped_audio_streams). Not compared when two or more inputs have sound (grid --audio-from, a mix): which source the output carries is the tool's choice; {source, kept, dropped}"),
|
|
527
|
+
"audio_lead_dropped": ("warnings", "cut.py: an audio-only stream copy of a source whose sound starts after --start (by at least one frame of its picture) begins at the sound's first packet, so that much silence is left out and the extraction is early against the picture; kept as a copy within --tolerance, as a start that snaps is (--accurate pads it); a dry run reports it from the source, also where a run may re-encode instead (length_unjudged); {seconds: the total, segments: [{index, seconds}]}"),
|
|
528
|
+
"grid_no_drawtext": ("fallbacks", "grid.py --label auto on a build without the drawtext filter: the cells were not labelled, as with --label none"),
|
|
529
|
+
"scenes_sheet_no_drawtext": ("fallbacks", "scenes.py --sheet on a build without the drawtext filter: the sheet was drawn without timecode stamps, as with --no-timecode"),
|
|
530
|
+
"look_no_drawtext": ("fallbacks", "look.py on a build without the drawtext filter: the sheet was drawn without timecode stamps, as with --no-timecode"),
|
|
531
|
+
"font_substituted": ("fallbacks", "the asked font family is not installed: fontconfig or the Windows Fonts folder gave another (font_used names it); {asked, file, family, via}"),
|
|
532
|
+
"font_lacks_script": ("warnings", "an explicit --font does not cover the text's script and is kept as asked; {font, script}"),
|
|
533
|
+
"font_coverage_unverified": ("warnings", "whether a font covers the text's script could not be checked (no fontconfig / fc-scan); {script, fonts_dir?}"),
|
|
534
|
+
"font_path_copied": ("fallbacks", "a --font-file under a non-ASCII path was copied to an ASCII one, because drawtext cannot open it on Windows; {font, file}"),
|
|
535
|
+
"font_path_not_ascii": ("warnings", "a --font-file under a non-ASCII path could not be given an ASCII form on Windows; drawtext may not open it; {font}"),
|
|
536
|
+
"fonts_dir_lacks_script": ("fallbacks", "no face in --fonts-dir covers the text's script, so one was picked by script; {fonts_dir, script}"),
|
|
537
|
+
"font_variant_missing": ("fallbacks", "--lang named Traditional Chinese but no Traditional face is installed, so a Simplified one draws it (some glyph forms differ); {lang, file}"),
|
|
538
|
+
"emoji_monochrome": ("warnings", "caption.py / graphics.py: emoji drawn monochrome through libass (no colour path here). overlay.py --text: emoji left to the one font drawtext loads, which has no fallback, so a font without the glyph draws an empty box"),
|
|
539
|
+
"words_outside_input": ("warnings", "silence.py --filler --words: word timings that start at or after the end of the input (a transcript of another file, or times in milliseconds); {count, words, duration}"),
|
|
540
|
+
"emoji_stripped": ("warnings", "overlay.py --emoji none: emoji removed from the drawn text; {mode}"),
|
|
541
|
+
"emoji_assets_missing": ("warnings", "--emoji-assets has no PNG for these clusters; they stay in the text for libass, and the message says whether libass draws an emoji glyph on this build; {missing}"),
|
|
542
|
+
"drawtext_newline_glyph": ("warnings", "graphics.py --text-render drawtext on FFmpeg 8.0-8.0.1/8.1.0: a box is drawn at each line break of a multi-line label; {text_render}"),
|
|
543
|
+
"timeline_parse_failed": ("warnings", "render.py --export-timeline: the written file does not read back as its format (the parse step is ok: false); {path, format, error}"),
|
|
544
|
+
# captions
|
|
545
|
+
"ass_lines_unshifted": ("warnings", "caption.py --ass --offset: Dialogue lines whose timestamps could not be read were copied unshifted; {path, count, offset}"),
|
|
546
|
+
"ass_lines_malformed": ("warnings", "caption.py --ass: Dialogue lines that could not be read (fields or start/end) are not counted as cues; {path, count}"),
|
|
547
|
+
"cues_outside_video": ("warnings", "caption.py: cues wholly outside the video are not drawn; {count, duration}"),
|
|
548
|
+
# analysis
|
|
549
|
+
"speed_length_placeholder": ("skipped", "render.py --dry-run: a clip's length could not be read before its cut exists, so its speed stage was planned on a stand-in 10 s; {stage, clip, path, placeholder_seconds}"),
|
|
550
|
+
"drift_correction_skipped": ("skipped", "sync.py / multicam.py --fix-drift not applied for a source (drift_skipped_reason); {path, reason: too_short | low_confidence, ...}"),
|
|
551
|
+
"sync_low_confidence": ("warnings", "sync.py / multicam.py: a source's offset has a correlation confidence below 0.1; {path, confidence}"),
|
|
552
|
+
"cropdetect_windows_failed": ("warnings", "cropdetect.py: sampled windows ffmpeg could not decode (windows_failed); {failed, windows, starts}"),
|
|
553
|
+
"crop_content_off_centre": ("warnings", "fit.py --fit crop: aggregate or per-point luma motion/detail crosses the crop threshold. Up to 9 pairs of gray frames over the kept source range contribute. With motion: motion_outside exceeds discarded_fraction by >= 0.15. With no motion: detail_outside exceeds discarded_fraction by >= 0.15. Advisory. The warning carries the crop_check measurement keys, including the kept range and review_points."),
|
|
554
|
+
"filler_words_untimed": ("warnings", "silence.py --filler: listed words in the transcript with no usable timing were not removed (filler.matched_untimed); {count}"),
|
|
555
|
+
"sentence_ends_not_found": ("warnings", "silence.py --sentence-min-silence / --sentence-margin-tail: the transcript has no sentence-final punctuation, so every silence used --min-silence and --margin-tail (sentence.sentence_end_words is 0)"),
|
|
556
|
+
"cut_near_sound": ("warnings", "silence.py: a cut point's level is within CUT_SOUND_MARGIN_DB of --threshold, so it may land in a breath or a word's weak tail (cut_warnings lists them)"),
|
|
557
|
+
"cut_levels_unmeasured": ("warnings", "silence.py: the source could not be decoded to measure the level at each cut; cut_points and cut_warnings are null (unmeasured, not silent)"),
|
|
558
|
+
"filler_removal_caution": ("warnings", "silence.py --filler: a removed word that is often an ordinary word, or a discourse marker added with --filler-extra (also in filler.warnings)"),
|
|
559
|
+
# media and defaults
|
|
560
|
+
"track_longer_than_picture": ("warnings", "audio.py --track: a track is longer than the picture (by more than one frame); it is kept whole; {tracks, picture_seconds}"),
|
|
561
|
+
"silent_track_mixed": ("warnings", "audio.py --on-silent warn: a silent track was mixed anyway; {tracks}"),
|
|
562
|
+
"silent_inputs": ("warnings", "join.py --on-silent warn: silent inputs joined anyway (silent); {count}"),
|
|
563
|
+
"silent_input": ("warnings", "waveform.py: the input audio is silent and the visualisation is a flat line; {path, peak_db}"),
|
|
564
|
+
"short_inputs": ("warnings", "join.py: inputs shorter than two frames joined anyway (short_segments); {count}"),
|
|
565
|
+
"duplicate_inputs": ("warnings", "join.py: an input listed more than once is joined each time (duplicates); {count}"),
|
|
566
|
+
"sequence_gap": ("warnings", "sequence.py: a frame is missing from the numbering and the frames after it are not in the video; {missing, frames_left_out, first_left_out}"),
|
|
567
|
+
"memory_heavy": ("warnings", "reverse.py / loop.py --boomerang hold every decoded frame in memory and this input is large"),
|
|
568
|
+
"dovi_not_detected": ("warnings", "color.py --strip-dovi on a stream with no Dolby Vision metadata: unregistered SEI removed anyway"),
|
|
569
|
+
"frame_from_export_preset": ("warnings", "render.py: frame.width/height taken from the export preset for a frame given only an aspect; {preset, width, height}"),
|
|
570
|
+
"normalize_on_by_default": ("warnings", "render.py: a platform export preset with no loudness stage got export.py --normalize by default; {preset}"),
|
|
571
|
+
# degraded or partial results (part 2)
|
|
572
|
+
"colour_not_converted": ("warnings", "export.py: an HDR or wide-gamut source written by a preset that tags SDR BT.709 without converting it; {preset, hdr_format}"),
|
|
573
|
+
"output_audio_silent": ("warnings", "export.py: the written audio is silent (-inf LUFS and no true peak above the silence floor), so no gain meets the platform's loudness; {platform}"),
|
|
574
|
+
"flash_pass_failed": ("warnings", "check.py --content: the flash pass failed, so the flashes row is not measured (WARN, could not measure); the other rows stand"),
|
|
575
|
+
"repair_incomplete": ("warnings", "export.py --repair: decode errors remain after the remux (a damaged frame needs a re-encode); {timestamp_warnings, decode_errors}"),
|
|
576
|
+
"legalize_residual": ("warnings", "color.py --legalize: samples of the encoded file are still outside the legal range after the clamp (the encoder's error around clamped areas); the shares are in legalize.output"),
|
|
577
|
+
"picture_small_in_frame": ("warnings", "export.py, fit.py (--fit pad with a solid colour): the picture fills less than half of the frame it was padded into, as a 9:16 clip in a 16:9 preset does (32%); the file is the frame asked for; {fraction, source, frame}"),
|
|
578
|
+
"picture_mostly_cropped": ("warnings", "export.py, fit.py, join.py (--fit crop): the crop keeps less than half of the picture, as a 16:9 clip cropped to 9:16 keeps 32%; {fraction, source, frame}. The file is what was asked; --fit pad or blur keeps all of it (#688)"),
|
|
579
|
+
"chapters_not_retimed": ("warnings", "any tool: the output's length differs from the source's by more than 0.1 s and its chapters were carried at the source's times by a tool that declared no time map; {source_chapters, output_chapters}. The guard of the time class (docs/defect-guards.json): a tool that moves the picture in time maps its chapters (runner.with_mapped_chapters) or says why FFmpeg's own handling is right (runner.declare_time_map)"),
|
|
580
|
+
"size_over_limit": ("warnings", "export.py --max-mb: the written file is over the size asked for (the encoder overshot its bitrate); {size, limit}"),
|
|
581
|
+
"loudness_outside_spec": ("warnings", "export.py: the written file's loudness is outside the platform's spec (normalized: after --normalize too); {platform, lufs, tp, normalized}"),
|
|
582
|
+
"smart_fallback": ("fallbacks", "cut.py --smart could not make or verify the smart cut, so the whole cut was re-encoded as --accurate would (smart.reason says why); {reason_code}"),
|
|
583
|
+
"camera_not_started": ("fallbacks", "multicam.py: a range asked for a camera that had not started; camera 0 played it ({start, end, requested_camera, camera, starts_at}); `cuts` names the camera rendered"),
|
|
584
|
+
"loudness_not_measured": ("warnings", "export.py: the written file's loudness could not be read, or the audio is shorter than one 400 ms gating block (loudness.too_short), so the platform's loudness was not verified (loudness.ok null, a failing loudness verification step)"),
|
|
585
|
+
"loudness_no_audio": ("skipped", "export.py: a platform preset's loudness check, on a source with no audio"),
|
|
586
|
+
"report_section_missing": ("warnings", "report.py: a loudness, compliance or contact-sheet section could not be built (also a failing verification step naming the section)"),
|
|
587
|
+
"report_section_dry_run": ("skipped", "report.py --dry-run draws no contact sheet"),
|
|
588
|
+
"check_dry_run": ("skipped", "render.py --dry-run does not run a check stage or a plan's check step"),
|
|
589
|
+
"caption_timecode_rate_mismatch": ("warnings", "caption.py: an SMPTE cue rate differs from the probed video rate; {cue_fps, source_fps, cue_timecode, drift_seconds}. Drift compares the chosen time to reading the same label at the source rate, or null when that reading is unavailable or the source is suspected VFR"),
|
|
590
|
+
"caption_srt_not_delivered": ("skipped", "render.py: the captions stage's generated SRT is not delivered beside the output: the stage was served from --cache (reason cached), or a later stage changed the timeline (reason timeline_changed: the export trimmed the delivery); {reason, path, trimmed}"),
|
|
591
|
+
"batch_cache_inputs_changed": ("skipped", "batch.py: an item's source or a side input changed while it was processed (its cache key, made again when the item ends, is not the one it was looked up with), so its output is not stored in the cache; {file}"),
|
|
592
|
+
"batch_side_file_not_delivered": ("skipped", "batch.py: a step before the last wrote side files beside its intermediate (caption.py's .srt, an .ass), which go with the item's work directory; only the last step's side files land beside the output; {file, step, tool, files}"),
|
|
593
|
+
"check_no_output": ("skipped", "render.py PLAN: the tool reported no output for the plan's check step"),
|
|
594
|
+
"check_nothing_to_check": ("skipped", "render.py: a \"check\" stage with neither \"platform\" nor \"content\": true"),
|
|
595
|
+
"check_output_unparsed": ("warnings", "render.py: check.py printed no JSON document; `check` is a failure document (error.reason check_output_unparsed)"),
|
|
596
|
+
"cache_entry_damaged": ("warnings", "render.py --cache: a sidecar that does not parse or an artifact of the wrong size (also an audit line in the cache directory); the stage runs again"),
|
|
597
|
+
"cache_store_failed": ("warnings", "render.py --cache: a stage's artifact could not be stored; the run is unaffected"),
|
|
598
|
+
"cache_input_unreadable": ("warnings", "render.py --cache: an input could not be fingerprinted and is keyed as \"missing\""),
|
|
599
|
+
"cache_ffmpeg_banner_unreadable": ("fallbacks", "render.py --cache: the ffprobe banner could not be read; keyed on major.minor, so builds of one release share entries"),
|
|
600
|
+
"cache_inputs_changed": ("skipped", "render.py --cache: a stage's inputs (its files, a --brand file's logo or font) changed while it ran (its key, made again when the stage ends, is not the one it was looked up with), so its artifact is not stored; {stage}"),
|
|
601
|
+
"cache_result_unrecorded": ("skipped", "render.py --cache: a hit from an entry that recorded no stage result, so what that stage verified is unknown"),
|
|
602
|
+
"recipe_project_unreadable": ("warnings", "batch.py: recipe.project could not be read; the cache key covers the recipe only"),
|
|
603
|
+
"batch_cache_reset": ("warnings", "batch.py: .ffskill_cache.json did not parse and was started empty (also an audit line)"),
|
|
604
|
+
"batch_cache_output_changed": ("warnings", "batch.py: a cached item's output was replaced or edited since the batch wrote it; the item runs again"),
|
|
605
|
+
"batch_cache_entry_unverifiable": ("warnings", "batch.py: a cache entry from before output identities; the item runs again"),
|
|
606
|
+
"alpha_dropped": ("warnings", "color.py / graphics.py / overlay.py: the source's alpha channel is used and the output does not keep it (no --keep-alpha); the `alpha` verification step fails with reason alpha_dropped, and --drop-alpha says an opaque output is wanted"),
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
# The alpha path beyond export.py (_common.alpha): --keep-alpha on the tools that grade or
|
|
611
|
+
# composite, --transparent on background.py. One description, so the four cannot drift.
|
|
612
|
+
ALPHA_LINE_TOOLS = ("color", "graphics", "overlay", "background")
|
|
613
|
+
ALPHA_LINE_OPTIONAL = [{"capability": "encoder:prores_ks", "when": "--keep-alpha / --transparent with --alpha-codec prores4444 (the default)"},
|
|
614
|
+
{"capability": "encoder:qtrle", "when": "--alpha-codec qtrle"}, {"capability": "encoder:png", "when": "--alpha-codec png"},
|
|
615
|
+
{"capability": "encoder:libvpx-vp9", "when": "--alpha-codec vp9"},
|
|
616
|
+
{"capability": "encoder:libopus", "when": "--alpha-codec vp9 on an input with audio (color, graphics, overlay)"},
|
|
617
|
+
{"capability": "decoder:libvpx-vp9", "when": "an alpha source or overlay --video layer stored as VP9 with alpha (refused without it, error.reason decoder_missing)"},
|
|
618
|
+
{"capability": "filter:alphaextract", "when": "an alpha source or --keep-alpha / --transparent (the alpha is read back)"}]
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
def alpha_result_schema(name: str) -> Dict[str, Any]:
|
|
622
|
+
flag = "--transparent" if name == "background" else "--keep-alpha"
|
|
623
|
+
out: Dict[str, Any] = {
|
|
624
|
+
"alpha_codec": {"enum": ["png", "prores4444", "qtrle", "vp9"], "description": f"{flag} only: the alpha line written (--alpha-codec, default prores4444); the source's colour tags are kept and no matrix is converted, as --codec prores does"},
|
|
625
|
+
"alpha_mode": {"enum": ["straight", "premultiplied"], "description": f"{flag} only: how the colour was written beside the alpha (--alpha-mode, default straight)"},
|
|
626
|
+
}
|
|
627
|
+
if name == "background":
|
|
628
|
+
out["alpha_codec"]["description"] += ". The `alpha` verification step reads every written frame back and expects alpha 0 (provenance specification)"
|
|
629
|
+
return out
|
|
630
|
+
out["alpha_codec"]["description"] += " (an RGB source that is neither HDR nor BT.2020, on a prores4444/vp9 line has no matrix to keep: it is converted to BT.709 and tagged so; an HDR or BT.2020 one is not: FFmpeg's own conversion makes its YUV, as before)"
|
|
631
|
+
out["alpha_dropped"] = {"type": "boolean", "description": "true when the source's alpha is used (a frame below opaque, or a stored alpha plane that could not be read) and the output does not keep it (color.py --retag too, when its copy fell back to an H.264 re-encode): without --keep-alpha the `alpha` verification step fails (reason alpha_dropped, attribution artifact, with an alpha_dropped warning); with --drop-alpha there is no such step and a note says the alpha was dropped on purpose. Absent on a source without alpha"}
|
|
632
|
+
if name == "color":
|
|
633
|
+
out["alpha_codec"]["description"] += ". --correct / --lut only: the grade works on the colour (at 4:4:4) and the source's alpha is merged back onto that 8-bit picture (an 8-bit alpha unchanged; a 10- or 12-bit ProRes 4444 alpha keeps 8 bits of precision); the `alpha` step compares the written alpha with the source's frame by frame, tolerance 2 of 255 (comparison {ok, paired, worst_delta, worst_frame}; frames {expected, measured}; written {codec, pix_fmt, alpha_plane})"
|
|
634
|
+
else:
|
|
635
|
+
out["alpha_codec"]["description"] += ". Drawn on the input's alpha at 4:4:4 (layers composited with their alpha, text drawn into it); the `alpha` step (property alpha_at_least_source) passes when the written stream stores an alpha plane, every frame's alpha is at or above the source's (tolerance 2 of 255) and the output did not turn opaque in every frame the source was transparent in (reason: opaque_everywhere, alpha_below_source or no_alpha_plane when it fails)"
|
|
636
|
+
out["alpha_codec"]["description"] += ". A source that stores an alpha plane whose alpha could not be read is never taken as opaque: its step fails with reason source_alpha_unmeasured"
|
|
637
|
+
return out
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
# `font_used` on the tools that draw text: which font the text was drawn with, so a run that
|
|
641
|
+
# drew with a substitute says so (with a font_substituted fallback)
|
|
642
|
+
FONT_USED_SCHEMA = {
|
|
643
|
+
"type": "object",
|
|
644
|
+
"description": "the font face the text was drawn with: {asked, file, family, how, substituted, via?, fonts_dir?}. file and family "
|
|
645
|
+
"name that one face; drawtext (overlay.py, graphics.py, grid.py) draws every glyph from it (a glyph it lacks "
|
|
646
|
+
"is its missing-glyph box), while libass (caption.py) draws a glyph it lacks from another face, which is not "
|
|
647
|
+
"recorded. how: font_file (the "
|
|
648
|
+
"caller's file), script (picked to cover the text's script), resolved (the asked family resolved to a file by "
|
|
649
|
+
"fc-match or the Windows Fonts folder; for libass, the file fontconfig picks for the family), by_name (no file "
|
|
650
|
+
"resolved: ffmpeg/libass look the family up themselves, file null), fonts_dir (caption.py: --fonts-dir is searched for the asked "
|
|
651
|
+
"family, read by fc-scan; only faces with outline true are candidates; file names its face in exactly the asked style (upright, weight 400, or 700 with "
|
|
652
|
+
"--bold), or the face whose full or PostScript name was asked, which libass takes first (an installed copy "
|
|
653
|
+
"that ties is the same family and style); file null, with a note, when the folder holds the family only in "
|
|
654
|
+
"other styles (libass picks among those and the installed faces; not measured) or could not be read; a "
|
|
655
|
+
"literal miss also reports file null, how fonts_dir and the family as asked: libass may select a directory face through a "
|
|
656
|
+
"fontconfig alias, so the face is not established), ass_styles (caption.py --ass: the file's own styles name the fonts). substituted: true when the "
|
|
657
|
+
"file is not the asked family (also a diagnostics.fallbacks entry, font_substituted), false when it is, and null wherever file is null: no face was established, so nothing was measured. overlay.py: with --text; "
|
|
658
|
+
"grid.py: with --label auto",
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
# the tools whose --json carries `dropped_non_av_streams` (a test reads the sources)
|
|
663
|
+
NON_AV_STREAM_TOOLS = frozenset({"audio", "broll", "color", "crop", "cut", "deinterlace", "denoise", "export", "fit", "freeze",
|
|
664
|
+
"graphics", "join", "loudness", "overlay", "pad", "proxy", "redact", "speedramp",
|
|
665
|
+
"sphere", "stabilize", "straighten"})
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
# Top-level keys a tool emits that its own branch in output_schema() does not list (#466 A194: the
|
|
669
|
+
# schemas were written by hand and left these out). tests/test_contract.py's
|
|
670
|
+
# test_every_emitted_top_level_key_is_in_the_output_schema runs each tool and fails on a key that
|
|
671
|
+
# is in neither.
|
|
672
|
+
EMITTED_KEYS: Dict[str, Dict[str, Any]] = {
|
|
673
|
+
"fit": {
|
|
674
|
+
"timing": {"type": "object", "description": "--duration only, in dry-run JSON, saved plans and real results. {method, source_duration, target_duration, speed_factor, retimed}: lengths in seconds, the computed source/target ratio for speed or 1 for trim, and whether the command retimes the source. Ratios within 0.0001 of 1 keep the speed unchanged. A dry run without a usable input length has null source_duration, speed_factor and retimed for speed."},
|
|
675
|
+
"picture": {"type": "object", "description": "after a real run that sized the frame (--aspect, --width or --height): where the picture sits in the frame written, measured, not judged (#519): {measured, x, y, width, height, frame_width, frame_height, frame_share, scale, cropped {left, right, top, bottom}}. ffmpeg runs the frame's own filters (the scale and pad, the blur graph with its background drawn black, or the scale and crop) on one white and one black frame of the source's displayed size and pixel format, ending in the written file's pixel format; the picture is the rectangle where the two differ (no frame of the source is decoded), and frame_width/frame_height are the written file's. frame_share: picture area over frame area (1.0 for --fit crop). scale: the picture's width over the source's displayed width (for --fit crop, the width it was scaled to before the crop); a note says so when it is below 1 and no --width or --height was given. cropped: source pixels --fit crop cut on each side, each axis at its own scale (all 0 otherwise). {measured: false, reason} (and a note) when the measurement gave no frame of the written size. Absent under --dry-run. Whether the subject is in the rectangle is still a look: subject_framing stays in unverified"},
|
|
676
|
+
"crop_check": {"type": "object", "description": "after a real --fit crop with a discarded margin: where the source's luma motion or edge detail sits. {axis: x|y, kept: {start,end} as fractions of that axis, discarded_fraction, motion_outside, detail_outside, centroid, suggested_anchor, samples, basis: luma_motion_proxy, signal: motion|detail|null, verdict: ok|review|unmeasured, review_points: [{source_time, output_time_estimate, signal, motion_outside, detail_outside, centroid, suggested_anchor}]}. Review points are flagged sample seek times; output_time_estimate accounts for trimming and retiming, or is null without a usable time. Review emits crop_content_off_centre. subject_framing stays in unverified."}},
|
|
677
|
+
"cropdetect": {
|
|
678
|
+
"file": {"type": "string", "description": "the input path, as given"},
|
|
679
|
+
"source_width": {"type": "integer", "description": "the displayed frame's width (a 90/270 degree rotation swaps the stored size; a non-square-pixel source is squared at its display aspect): the frame crop and motion_centre are in"},
|
|
680
|
+
"source_height": {"type": "integer", "description": "the displayed frame's height, as source_width"},
|
|
681
|
+
"crop": {"type": ["object", "null"], "description": "{width, height, x, y}: the rectangle cropdetect read most often over the sampled windows, in source pixels (the full frame when there are no bars); null when it produced no reading"},
|
|
682
|
+
"confidence": {"type": "number", "description": "present with a crop: the share of readings (0..1) that gave that rectangle"},
|
|
683
|
+
"motion_centre": {"type": "array", "description": "--motion-centre only: [{time, x, y, x_frac, y_frac, motion}] per second over the same windows; x/y null for a window with no measured motion. Report only"}},
|
|
684
|
+
"graphics": {
|
|
685
|
+
"template": {"type": "string", "description": "the --template drawn"},
|
|
686
|
+
"text_renderer": {"enum": ["ass", "drawtext"], "description": "what drew the text: libass (a generated .ass) or drawtext"},
|
|
687
|
+
"script": {"type": "string", "description": "the writing system detected in the text, which picks the font (latin, han, ...)"},
|
|
688
|
+
"ass": {"type": "string", "description": "text_renderer ass only: the generated .ass path (--write-ass, else <output>_gfx.ass); under --dry-run the path that would be written"},
|
|
689
|
+
"emoji": {"type": "object", "description": "text with emoji only: {mode, count, clusters, assets, missing, overlays}"},
|
|
690
|
+
"broken_inside_word": {"type": "integer", "description": "present when above 0: words hard-sliced because they did not fit a line alone"}},
|
|
691
|
+
"loudness": {
|
|
692
|
+
"loudnorm_mode": {"enum": ["linear", "dynamic"], "description": "--dry-run only (a real run reports it in result): the mode loudnorm's planned pass 2 runs in for the measured input"}},
|
|
693
|
+
"join": {
|
|
694
|
+
"reencoded": {"type": "boolean", "description": "--copy --transition none only: false, the clips were joined by stream copy"},
|
|
695
|
+
"audio_substituted": {"type": "array", "items": {"type": "string"}, "description": "a re-encoded video join: the clips with no audio stream, whose span of the join is generated silence (notes says the same); [] when every clip has sound"},
|
|
696
|
+
"inputs_duration": {"type": ["number", "null"], "description": "the clips' own total length, seconds"},
|
|
697
|
+
"transition_shortening": {"type": ["number", "null"], "description": "how much the transitions took out of inputs_duration, seconds"}},
|
|
698
|
+
"multicam": {
|
|
699
|
+
"inputs": {"type": "array", "items": {"type": "string"}, "description": "the input paths as given, reference first; a camera number in cuts indexes this list"}},
|
|
700
|
+
"broll": {
|
|
701
|
+
"cutaways": {"type": "array", "description": "[{insert, at, end, from}] per cutaway: the B clip, where it starts and ends on A's timeline (seconds), and where in B it starts"},
|
|
702
|
+
"audio": {"enum": ["a", "b", "mix"], "description": "--audio: what plays under a cutaway"}},
|
|
703
|
+
"grid": {
|
|
704
|
+
"cols": {"type": "integer"}, "rows": {"type": "integer"},
|
|
705
|
+
"clips": {"type": "integer", "description": "how many input clips the grid holds"}},
|
|
706
|
+
"scenes": {
|
|
707
|
+
"highlights": {"type": "array", "description": "--highlights only: [{start, end, duration}] the proposed ranges"},
|
|
708
|
+
"highlights_total": {"type": "number", "description": "--highlights only: the ranges' total seconds"},
|
|
709
|
+
"highlights_rank_by": {"enum": ["audio", "duration"], "description": "--highlights only: --rank-by"},
|
|
710
|
+
"sheet": {"type": "string", "description": "--sheet only: the contact sheet path (under --dry-run the path that would be written; nothing is drawn)"}},
|
|
711
|
+
"batch": {
|
|
712
|
+
"jobs": {"type": "integer", "description": "the parallelism actually applied"},
|
|
713
|
+
"jobs_requested": {"type": ["integer", "null"], "description": "the --jobs asked for (auto resolved to a number)"},
|
|
714
|
+
"wall_seconds": {"type": "number", "description": "the batch's wall clock"},
|
|
715
|
+
"item_seconds_total": {"type": "number", "description": "the sum of the per-item times"},
|
|
716
|
+
"timed_out": {"type": "boolean", "description": "whether the shared --timeout budget ran out (a timed-out item's row carries skipped: timeout)"}},
|
|
717
|
+
"render": {
|
|
718
|
+
"picture": {"type": "object", "description": "the last sizing stage's picture report in the output frame (same fields as fit.py); omitted when the last sizing stage has no report or under --dry-run"},
|
|
719
|
+
"stage_pictures": {"type": "object", "description": "recorded picture reports keyed by fit or export; coordinates and source crop are relative to each stage's own output and input respectively (also replayed from cache when recorded)"},
|
|
720
|
+
"template": {"type": "string", "description": "--write-project only: the template the written project was filled from"},
|
|
721
|
+
"pack": {"type": "array", "description": "--template naming several destinations (a social pack) only: one row per destination {platform, file, path, size_bytes, duration, check, guidance, ok}; output is then the <stem>_pack.md table"},
|
|
722
|
+
"outputs": {"type": "array", "items": {"type": "string"}, "description": "a social pack only: each destination's output path"}},
|
|
723
|
+
"report": {
|
|
724
|
+
"pack": {"type": "array", "description": "--pack only: the pack table's rows as {column: cell} objects, as read from the file"}},
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def output_schema(name: str, meta: Dict[str, Any], hw: bool = False) -> Dict[str, Any]:
|
|
729
|
+
"""What the tool prints on stdout with --json (keys observed in the implementation). `hw`: the
|
|
730
|
+
tool takes --hw, so its `notes` can also carry a VideoToolbox encode's quality line."""
|
|
731
|
+
if name == "probe":
|
|
732
|
+
return {"type": "object", "description": "one probe document, or an array of them for several inputs",
|
|
733
|
+
"properties": {"file": {"type": "string"}, "format": {"type": ["string", "null"]},
|
|
734
|
+
"dry_run": {"type": "boolean", "description": "true on an unmeasured input that does not exist yet"},
|
|
735
|
+
"duration": {"type": ["number", "null"]}, "size_bytes": {"type": ["integer", "null"]},
|
|
736
|
+
"video": {"type": ["object", "null"]}, "audio": {"type": ["object", "null"]},
|
|
737
|
+
"timecode": {"type": "object", "description": "3.0.0: the source's start timecode {value, drop_frame, source}: the first HH:MM:SS[:;.]FF timecode tag from the video stream, then a tmcd data stream, then the container; all three null when none carries one"},
|
|
738
|
+
"chapters": {"type": "array", "description": "the container's chapter markers [{index, start, end, title}]"},
|
|
739
|
+
"subtitle_stream_details": {"type": "array", "description": "every subtitle stream in file order [{index (the n of -map 0:s:n), codec, language, title, default (the stream's default disposition)}]"},
|
|
740
|
+
"keyframes": {"type": "array", "description": "--keyframes-near only: one entry per time [{at, window, keyframes (the video keyframes within window seconds of it), before (the nearest of those at or before it, or null when none is within the window), after (at or after it, likewise)}], seconds from the file's start; a failed keyframe read fails the run (kind ffmpeg)"},
|
|
741
|
+
"start_time": {"type": ["number", "null"], "description": "where the container's timeline starts, seconds (an MPEG-TS file often starts above 0)"},
|
|
742
|
+
"bitrate": {"type": ["integer", "null"], "description": "the container's overall bit rate, bits per second, as ffprobe reads it; null when it states none"},
|
|
743
|
+
"subtitle_streams": {"type": ["integer", "null"], "description": "how many subtitle streams the file carries"},
|
|
744
|
+
"data_streams": {"type": ["integer", "null"], "description": "how many data streams (a tmcd timecode track, telemetry) the file carries"},
|
|
745
|
+
"stream_counts": {"type": "object", "description": "{video, audio}: picture streams (a cover picture is not one) and sound streams"},
|
|
746
|
+
"tags": {"type": "object", "description": "the container's title, artist, album, comment, date and genre tags that are set, keys lower-cased"},
|
|
747
|
+
"audio_streams": {"type": "array", "description": "every audio stream in file order [{index (the n of -map 0:a:n), codec, channels, channel_layout, sample_rate, language, title}]"},
|
|
748
|
+
"levels": {"type": "object", "description": "--analyze only, on an input with a video stream: picture levels sampled at 2 fps over the first 20 s, on an 8-bit scale inferred from the values measured (a 10-bit or deeper picture whose luma never passes code 255 is read as 8-bit and left unscaled) {scale, y_min, y_max, y_avg, y_low_p5, y_high_p95, saturation_avg, looks_like_log, note}; {error} when no frame was analysed. Measured under --dry-run too"}},
|
|
749
|
+
"additionalProperties": True}
|
|
750
|
+
base = {"status": {"enum": ["completed"]}, "output": {"type": ["string", "null"], "description": "path written, or null"},
|
|
751
|
+
"wrote": {"type": "string", "description": "one line about the file written, first in the document: its length, `(ASKED N s: M s longer|shorter)` when the length misses expected_duration by more than 40 ms, the frame and rate, and whether it holds picture and sound; absent under --dry-run and for an output that is not media"},
|
|
752
|
+
"dry_run": {"type": "boolean"}, "commands": {"type": "array", "items": {"type": "string"}, "description": "the ffmpeg command lines this run planned or ran to write its output (render.py and waveform.py: their stages' too), shell-quoted; a line that names a file the tool wrote for the run and removed when it exited (such as a concat list, an ffmetadata file, a drawtext text file, a two-pass log or a stage's intermediate) cannot be run again as printed; a measurement pass is listed only where the tool records it (e.g. loudness.py pass 1, check.py, stabilize.py pass 1), and batch.py lists none of its steps' (each results row's step documents carry their own)"},
|
|
753
|
+
"probe": {"type": "object", "description": "probe of the output when a file was written"},
|
|
754
|
+
"output_identity": {"type": "object", "description": "2.24: {size, mtime_ns} of the file this run wrote, absent under --dry-run; pass it to check.py --expect-identity SIZE:MTIME_NS so the check grades this file and not whatever later sits at the path"},
|
|
755
|
+
"encoder": {"type": "string", "description": "the video encoder the last ffmpeg command used (after any GPU->CPU fallback; under --dry-run the planned one; render.py and waveform.py: their stages' commands included), `copy` for a stream copy; absent when no command encoded video"},
|
|
756
|
+
"hw": {"type": "object", "description": "present when VideoToolbox was asked for (--hw, $FFMPEG_SKILL_HW, a render.py stage, a batch.py item), on export.py when $FFMPEG_SKILL_HW=1 is set but its delivery preset does not take it, and when this ffmpeg build has no libx264/libx265 and an encode ran on VideoToolbox instead: {requested: whether this run's encodes were asked onto VideoToolbox (false for that export, and for the build without libx264/libx265), source: flag|env|auto (auto: nobody asked, the build has no libx264/libx265 and this Apple Silicon machine ran VideoToolbox in its place), used: true|false whether the encoder that ran last is VideoToolbox, null under --dry-run (nothing ran) and when this process ran no encode itself (batch.py: its stages are child processes; its top-level hw gathers the items' requested/source/fallback/notes and each results row carries its item's encoder and hw), fallback: a job VideoToolbox refused (encoder open or compression session failure; nothing else is retried) was re-encoded on the CPU, notes: why an encode stayed on or fell back to the CPU, and, when $FFMPEG_SKILL_HW chose the GPU and it ran, what that costs and that --no-hw opts out}. A VideoToolbox encode also adds a top-level notes line: its quality is not CRF-equivalent. A kind: ffmpeg failure under --hw / $FFMPEG_SKILL_HW carries encoder and hw too"},
|
|
757
|
+
"plan": {"type": "string", "description": "with --plan FILE: the plan document written (the run itself is a dry run)"},
|
|
758
|
+
"verified": {"type": "boolean", "description": "true only with a successful artifact probe or equivalent file check and when every self-check (verification) passed; false under --dry-run"},
|
|
759
|
+
"lossless": {"type": "boolean", "description": "true only when the runner can prove the written artifact came from a successful all-stream copy with no re-encode in the run; false under --dry-run or without execution evidence"},
|
|
760
|
+
"verification": {"type": "array", "items": {"type": "object", "properties": {"step": {"type": "string"}, "ok": {"type": "boolean"}, "stage": {"type": "string"}, "property": {"type": "string"}, "expected": {}, "measured": {}, "delta": {}, "tolerance": {}, "provenance": {"enum": ["specification", "user_specified", "independent_measurement", "input_premeasurement"]}, "attribution": {"enum": ["artifact", "reference", "instrument", "provenance", "unresolved"]}}}, "description": "what the tool itself verified: probe, plus loudness (loudness.py, export platform presets; ok false with reason not_measured when it could not be read), check (render), report.py's sections (loudness, compliance, contact_sheet) and batch.py's items (item). render.py also lists every stage's own steps beyond its artifact probe, tagged with `stage` (a cached stage's as recorded), so its `verified` is the conjunction of every stage's. Since 2.18 a step may carry the property it measured with expected, measured, delta, tolerance and the provenance of the expected value; cut, join and export add a `streams` step comparing the output's video/audio streams with the input's; a step with ok false carries `attribution` (unresolved until a tool knows the cause)"},
|
|
761
|
+
"unverified": {"type": "array", "items": {"type": "string"}, "description": "2.18: the properties of the output this tool did not measure (the unverified range), e.g. caption's rendered_placement; `verified` covers the measured properties only"},
|
|
762
|
+
"source_carry": {"type": "object", "description": "what the first input carried besides its picture and sound, compared with the written file: {kept: [...], dropped: [...]} over subtitles, chapters, cover_art, audio_channels (a surround source only), attachments (Matroska attached files, such as a subtitle track's fonts), video_streams (a source with more than one playable picture), creation_time, audio_language, timecode (kept only when the written start timecode is the label of the frame the output starts on: the source's own, or moved there by a tool that moved the picture's start; a join of several ranges writes none). Present only when the source had at least one of them; absent under --dry-run, for a still or GIF output, and when two or more inputs have a picture or sound (render.py: a project whose clips are one file, with no music, replacement, effects track or video layer, is compared with that file). A report, not a check: `verified` does not depend on it. A dropped subtitles/chapters/cover_art/audio_channels/attachments/video_streams also records a source_items_dropped warning"},
|
|
763
|
+
"diagnostics": DIAGNOSTICS_SCHEMA}
|
|
764
|
+
extra: Dict[str, Any] = {}
|
|
765
|
+
if name == "check":
|
|
766
|
+
extra = {"platform": {"type": "string"}, "ok": {"type": "boolean"}, "failed": {"type": "integer"}, "warnings": {"type": "integer"},
|
|
767
|
+
"input_identity": {"type": "object", "description": "2.24: {size, mtime_ns} of the file graded, the same shape as a writing tool's output_identity"},
|
|
768
|
+
"levels": {"type": "object", "description": "--levels only: {standard, reference, bit_depth, legal {y, c}: inclusive legal code ranges at the file's depth, window_seconds, frames, out_of_range_pct {y, u, v, chroma}: share of samples outside them (chroma: Cb and Cr samples together), brng_pct (signalstats BRNG: pixels with any component outside the fixed BT.601/709 nominal range), worst_frame {time, y_pct, chroma_pct}, min {y, u, v}, max {y, u, v}, windows: the same per --levels-window seconds ({start, end, ...})}"},
|
|
769
|
+
"change_scope": {"type": "object", "description": "--expect-changed only, when the two files could be compared: {declared [{start, end, rect}], observed [{start, end, frames, rect [x, y, w, h], peak}]: every span with a tile above the floor, undeclared: the same for the tiles no declaration covers, declared_unchanged: declared spans in which nothing changed, floor, tile [columns, rows], frames, quiet_peak: the largest tile at or under the floor}. Times are this file's presentation times in seconds, rectangles are displayed pixels"},
|
|
770
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "present when no --platform was named (youtube was assumed and judgement rows are WARN), when --compare paired a different number of frames than the reference has, or when --expect-changed compared two files that are not encoded alike"},
|
|
771
|
+
"checks": {"type": "array", "items": {"type": "object", "properties": {"check": {"type": "string", "description": "row name; --content adds black, frozen and silence; --compare adds similarity; --expect-changed adds change_scope; --levels adds legal levels; --expect-identity adds identity; audio FAILs when the track is present but silent (peak <= -50 dBFS). A value that could not be read is \"could not measure\", never a PASS: duration FAILs under a --max-duration the caller stated (WARN under the platform table's limit or without one) when the file states no length, and black, frozen and silence are then WARN rows; loudness is WARN for audio shorter than one 400 ms block; --tp without --lufs (custom) measures the true peak row"}, "status": {"enum": ["PASS", "WARN", "FAIL"]}, "value": {}, "expected": {}, "fix": {"type": "string"}, "kind": {"enum": ["format", "judgement"]}, "basis": {"enum": ["requirement", "guidance"], "description": "where the expected value comes from. guidance: the duration and file size rows when their limit is the platform table's upload limit (scripts/_platforms.py, dated UPLOAD_LIMITS_AS_OF); such a row is PASS or WARN, never FAIL, is not counted in failed, and its reason says the uploader checks the platform's current limit. requirement: every other row, and the same two rows under --max-duration / --max-mb (the caller's own limit), which FAIL"}}}}}
|
|
772
|
+
elif name == "caption":
|
|
773
|
+
extra = {"transcription": {"type": "object", "description": "with --transcribe: {engine, model, language, routing (why auto chose it), detected_language when auto detected it}"},
|
|
774
|
+
"caption": {"type": "object", "description": "cue layout: shifted / wrapped / rebalanced / split / extended / dropped counts, plus wrap ('phrase' or 'measured'), phrase_breaks (1.16), broken_inside_word -- atoms hard-sliced at the column edge because they did not fit alone even at the size floor (1.18.4) -- and overlong -- now residual: a single character alone wider than the column. Burn mode: cues_burned -- non-blank cues that overlap [0, duration] and are drawn -- and cues_outside -- non-blank cues wholly outside it (2.2.6); a burn with no visible cue is refused, kind input. --ass: ass_malformed -- Dialogue lines that could not be read and are not counted -- and with --offset ass_shifted / ass_unshifted -- lines moved, and lines whose timestamps could not be read, copied as they were (each count above 0 is also a diagnostics.warnings entry)"},
|
|
775
|
+
"tracks": {"type": "array", "description": "--mode mux: one entry per subtitle stream in the output ({index, file, language, title, codec, default, cues, kept_from_input}); a stream the input already carried has file null and kept_from_input true (1.16)"},
|
|
776
|
+
"subtitle_tracks": {"type": "integer", "description": "--mode mux: how many subtitle streams the output carries"},
|
|
777
|
+
"emoji": {"type": "object", "description": "how the emoji in the text were drawn (mode, overlays, missing)"},
|
|
778
|
+
"notes": {"type": "array", "items": {"type": "string"}}}
|
|
779
|
+
elif name == "metadata":
|
|
780
|
+
extra = {"chapters": {"type": "array", "description": "the chapter markers read back off the written file"},
|
|
781
|
+
"tags": {"type": "object"}, "streams_copied": {"type": "boolean"},
|
|
782
|
+
"auto_chapters": {"type": "object", "description": "--auto-chapters: {source, min_chapter, max_chapters, proposed, kept, titles, chapters, description_block, files}. titles is always 'placeholder' -- the skill proposes where a chapter starts, never what it is called (1.16)"},
|
|
783
|
+
"notes": {"type": "array", "items": {"type": "string"}}}
|
|
784
|
+
elif name == "waveform":
|
|
785
|
+
extra = {"audiogram": {"type": "object", "description": "{style, background ('image' or 'color'), image, position, vis_height, platform, captions, title, stages, verified} on visualization video runs"},
|
|
786
|
+
"waveforms": {"type": "array", "description": "--at: one row per written PNG {output, time, start, end, window_seconds, marker_x}; seconds are on the input's clock"},
|
|
787
|
+
"planned_waveforms": {"type": "array", "description": "--at under --dry-run: the paths and planned windows, with no PNG written"},
|
|
788
|
+
"outputs": {"type": "array", "items": {"type": "string"}, "description": "--at: PNG paths in request order, planned under --dry-run"},
|
|
789
|
+
"silent": {"type": ["boolean", "null"], "description": "true when the input audio's whole-file peak is at or below --silence-threshold (default -50 dBFS) and --on-silent warn (default) rendered the flat line anyway, with a notes line; false when audible; null under --dry-run (nothing measured). --on-silent fail refuses as kind input instead; verified is unaffected"},
|
|
790
|
+
"notes": {"type": "array", "items": {"type": "string"}}}
|
|
791
|
+
elif name == "scenes":
|
|
792
|
+
extra = {"file": {"type": "string"}, "duration": {"type": "number"}, "scene_count": {"type": "integer"}, "scenes": {"type": "array"}, "audio_peaks": {"type": "array"},
|
|
793
|
+
"shots": {"type": "array", "description": "--shots (1.18): [{start, end, label, flow_magnitude}]"},
|
|
794
|
+
"audio_peaks_db": {"type": "array", "description": "--audio-peaks (1.18): [{time, level}] measured dBFS, distinct from audio_peaks above"},
|
|
795
|
+
"speech": {"type": "array", "description": "--speech (1.18): [{time, speech_music_ratio}]"},
|
|
796
|
+
"audio_only": {"type": "boolean", "description": "After 3.2.0: present (true) when the input has no video stream: no scene detection ran and the file is one scene, 0 to its duration"},
|
|
797
|
+
"beats": {"type": "array", "description": "--beats (1.17): the regular beat grid, seconds"},
|
|
798
|
+
"beat_grid": {"type": "object", "description": "--beats (1.17): {supported_beats, tempo_bpm, interval, confidence, phase, onsets, supported, unsupported, method, step_s (the envelope's real step: 220/22050 s for --beat-step 0.01, after 3.2.0), range_bpm, usable, onset_refinement (after 3.2.0: pcm-window-ratio when each onset was placed on the decoded samples, else null)}"}}
|
|
799
|
+
elif name == "silence":
|
|
800
|
+
extra = {"silences": {"type": "array"}, "keep": {"type": "array"}, "input_duration": {"type": "number"}, "kept_duration": {"type": "number"}, "removed_seconds": {"type": "number"},
|
|
801
|
+
"margins": {"type": "object", "description": "{lead, tail}: the seconds of each silence kept before speech starts (--margin-lead) and after it ends (--margin-tail); both are --margin unless one is named; absent under --filler with neither --speech-aware nor a sentence flag, which removes no silences"},
|
|
802
|
+
"silence_positions": {"type": "array", "description": "--sentence-min-silence / --sentence-margin-tail: per entry of silences, sentence_end when the transcript word before it ends in sentence-final punctuation, else inside"},
|
|
803
|
+
"sentence": {"type": "object", "description": "--sentence-min-silence / --sentence-margin-tail: {min_silence, margin_tail (the floor and tail given to a silence after a sentence end), source, word_timings, sentence_end_words (transcript words that end a sentence; 0 means none did, so every silence used --min-silence and --margin-tail), silences (how many of silences are sentence_end)}"},
|
|
804
|
+
"removed_seconds_total": {"type": "number", "description": "--filler: seconds removed in all, silence plus filler words (removed_seconds stays the silence alone)"},
|
|
805
|
+
"cut_points": {"type": ["array", "null"], "description": "2.22: per cut {source_time, output_time, edge (out|in), rms_dbfs (the loudest channel 50 ms either side on the source; null for digital silence), filler (true on a removed filler word's edge)}; null when the source could not be decoded for it (cut_levels_unmeasured warning)"},
|
|
806
|
+
"cut_warnings": {"type": ["array", "null"], "description": "the cut_points (not filler cuts) within 10 dB of --threshold: where to listen (a cut_near_sound warning); verified is unchanged"},
|
|
807
|
+
"timemap": {"type": "string", "description": "--timemap FILE: the source-to-output time map written (JSON or CSV)"},
|
|
808
|
+
"silence_kinds": {"type": "array", "description": "2.20: per detected silence, digital (at or below -90 dBFS) or below_threshold"},
|
|
809
|
+
"silence_breakdown": {"type": "object", "description": "2.20: {digital, below_threshold}: the count and seconds of each, with the level that defines it"},
|
|
810
|
+
"hint": {"type": "string", "description": "when nothing sat below --threshold: the track's measured level and the --threshold that would find its pauses"},
|
|
811
|
+
"speech_aware": {"type": "object", "description": "--speech-aware (1.18): {min_silence, floor, breaths_kept, breaths_kept_seconds, breaths}"},
|
|
812
|
+
"filler": {"type": "object", "description": "--filler: {lang, source (whisper-json:FILE | whisper:ENGINE | parakeet:ENGINE), engine, transcription (with --transcribe: {engine, model, language, routing}), removed, removed_count, matched_untimed (listed words in the transcript with no usable timing, not removed), matched_too_long (listed words longer than a filler, kept), ...}"}}
|
|
813
|
+
elif name == "sync":
|
|
814
|
+
extra = {"reference": {"type": "string"}, "second": {"type": "string"}, "offset_seconds": {"type": "number"}, "confidence": {"type": "number"}, "meaning": {"type": "string"}, "drift": {"type": "object"},
|
|
815
|
+
"sources": {"type": "array", "description": "1.18: [{path, offset_s, confidence, drift_ppm}], one per SOURCE; the only per-source shape once more than one SOURCE is given; with --fix-drift each also carries drift_skipped_reason"},
|
|
816
|
+
"drift_skipped_reason": {"type": ["string", "null"], "enum": ["too_short", "low_confidence", None], "description": "--fix-drift, one SOURCE: why the drift correction was not applied (too_short: no tail window far enough from the head; low_confidence: the tail did not correlate), null when it was; also a diagnostics.skipped entry, drift_correction_skipped"}}
|
|
817
|
+
elif name == "look":
|
|
818
|
+
extra = {"outputs": {"type": "array", "items": {"type": "string"}},
|
|
819
|
+
"comparisons": {"type": "array", "description": "--compare only: {output, input_seek, compare_seek} per PNG. Seek positions are requested seconds on the two input clocks, also reported in a dry run. They convey no match verdict."},
|
|
820
|
+
"guides": {"type": "array", "description": "--guides only: each outline drawn on the PNG, {guide: action|title, fraction (0.93 / 0.90 of the frame, SMPTE ST 2046-1), of: frame} or {guide: 4:3, window, action: 0.90, title: 0.80}; drawn on the preview only"}}
|
|
821
|
+
elif name == "render":
|
|
822
|
+
extra = {"stages": {"type": "array", "items": {"type": "string"}}, "check": {"type": ["object", "null"], "description": "check.py's document for a \"check\" stage with a platform, \"content\": true, or both; when check.py printed none, a failure document with error.reason check_output_unparsed"},
|
|
823
|
+
"cache": {"type": ["object", "null"], "description": "--cache: {dir, ffmpeg, hits, misses, miss_reasons: [{stage, reason: not_cached|sidecar_missing|artifact_missing|sidecar_corrupt|artifact_truncated|no_output_path|destination_not_owned, ...}], saved_seconds, entries, would_hit (--dry-run)}"},
|
|
824
|
+
"caption_srt": {"type": ["string", "null"], "description": "the captions stage's SRT generated from a captions \"text\" cue file, delivered as <output>.srt beside the output (guarded with the output, before the first stage: an existing file is refused without --overwrite, an input is never replaced); under --dry-run the planned path; null when there is none (captions from \"srt\" or \"ass\", --stop-after before export) or it was not delivered (a caption_srt_not_delivered skip: the stage came from --cache, or the export trimmed the delivery so the cue times are not its own)"},
|
|
825
|
+
"caption": {"type": ["object", "null"], "description": "the caption stage's own block, forwarded verbatim from caption.py (cue-layout counts and fit-size keys); null without a caption stage"},
|
|
826
|
+
"snap": {"type": ["object", "null"], "description": "a project's \"snap\": cut.py's snap block for the first snapped clip, with every clip's in clips; null when nothing was snapped"},
|
|
827
|
+
"intermediate_preset": {"type": ["string", "null"], "description": "2.15: the x264/x265 preset the stages before an encoding export ran at (--intermediate-preset, default superfast since 2.16); null when no stage received it (no encoding export reached, --fast, --stop-after before the export, a copy export, or nothing but the export encoded)"},
|
|
828
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "each stage's own notes, prefixed with its tool (\"export: loudness ... is outside x's ...\")"},
|
|
829
|
+
"plan": {"type": "string", "description": "when the argument was a plan.json (written by <tool> --plan): its path"},
|
|
830
|
+
"plan_sha256": {"type": ["string", "null"], "description": "plan execution: sha256 of the plan file as executed"},
|
|
831
|
+
"unbound_inputs": {"type": "array", "items": {"type": "string"}, "description": "plan execution: inputs that did not exist when the plan was made, so carry no fingerprint and were not checked (also a diagnostics.warnings entry, code plan_unbound_inputs)"},
|
|
832
|
+
"tool": {"type": "string", "description": "plan execution: the tool the plan ran"},
|
|
833
|
+
"tool_result": {"type": "object", "description": "plan execution: the tool's own --json document"},
|
|
834
|
+
"timeline": {"type": "object", "description": "--export-timeline: format, rate, duration, frames, clips, transition, "
|
|
835
|
+
"transition_frames, music, markers, notes, and not_exported (what the project asks for that an "
|
|
836
|
+
"editor timeline cannot carry)"},
|
|
837
|
+
"templates": {"type": "array", "description": "--list-templates --json: one row per shipped template, {template, "
|
|
838
|
+
"destination, frame: {width, height} or null (audio), fit, max_duration, lufs, safe: {top, bottom, "
|
|
839
|
+
"left, right}}; without --json the same rows are a table"}}
|
|
840
|
+
elif name == "verify":
|
|
841
|
+
extra = {"report": {"type": ["string", "null"]},
|
|
842
|
+
"files": {"type": "array", "description": "one entry per file: {file, probe, steps, skipped}. A step is {step, ok, seconds, error (one line, for the table)}, plus the tool's verified when it completed, and on a failure its own kind, reason, message, details and exit_code (reason step_timeout or step_output_unparsed when the tool printed no failure document); skipped lists the steps that do not apply as {step, reason: quick|no_video|no_audio|not_hdr|not_multichannel|input_unreadable, message}"},
|
|
843
|
+
"failed": {"type": "integer"}, "total": {"type": "integer"},
|
|
844
|
+
"out_dir": {"type": ["string", "null"], "description": "the folder the steps' outputs are in when they are kept: --out, or with --keep alone a new folder that outlives the run; null when they were written to a temporary folder and deleted"}}
|
|
845
|
+
elif name == "batch":
|
|
846
|
+
extra = {"results": {"type": "array", "description": "one row per input, every input (an interrupted batch included): ok (every step completed), verified (every step also verified what it wrote; false under --dry-run, except on a row served from the cache, cached: true, which carries what the run that stored it verified, as a real run's served row does) and unverified ([{step, tool, failed}] naming the steps that did not); a failed row's error {step, tool, kind, message, code, reason, details, hint, exit_code} from the failing step's own document; diagnostics from its steps (tagged with step); cache_miss {reason: output_missing|output_changed|entry_unverifiable|entry_predates_output_check, ...} when a cache entry was not served (entry_predates_output_check: the recipe has a step that names no {out} and the entry was stored before batch checked such a step's own output, so it runs once more and is stored again), or {reason: side_input_unresolved, step, argument} for an item never served from the cache because a later step names a side input built from its {in} (an intermediate that does not exist before the item runs; a first step's {in}-derived side input is keyed by its content per item); skipped \"timeout\" or \"interrupted\" for an item that never started, \"recipe_refused\" for one not started because an earlier item's step wrote a file without naming {out} (error.reason step_writes_without_out) and interrupted true for one stopped while running (with kept: the final path, when the stopped last step had written a file there that was not there before it started, as export.py --normalize keeps its encode: on disk, unverified); under --watch, skipped \"settling\" (ok false, not cached) for a source that changed since the previous poll, or, first seen, was modified within one poll interval: it is processed on a later pass. A row whose recipe ran cut.py carries cut_reencoded (each cut.py call's reencoded) and cut_reencode_reasons (each reason those calls named, once per call), and under --dry-run cut_possible_reencode_reason (per cut.py call, that call's possible_reencode_reason: what a real run may still re-encode a planned copy for), except on a row served from the cache (cached: true), whose cut_reencoded and cut_reencode_reasons are what the run that stored it measured"},
|
|
847
|
+
"processed": {"type": "integer"}, "total": {"type": "integer"},
|
|
848
|
+
"cut_stream_copy": {"type": ["object", "null"], "description": "cut.py calls across the folder: {calls, stream_copy, reencoded, stream_copy_rate}; under --dry-run the calls' plans, where a planned stream copy may still re-encode in a real run (cut.py's possible_reencode_reason), and the calls of a row served from the cache (cached: true) as the run that stored it measured them, as a real run counts them; null when no cut.py step ran"},
|
|
849
|
+
"cut_reencode_reasons": {"type": ["object", "null"], "description": "how many cut.py calls named each reencode_reason ({} when none re-encoded); a re-encoded call whose row came from a cache an earlier 2.x batch wrote, which recorded no reasons, counts as unknown; null when no cut.py step ran"}}
|
|
850
|
+
elif name == "report":
|
|
851
|
+
extra = {"report": {"type": "string"}, "check": {"type": ["object", "null"], "description": "check.py's document for --platform; null when it was not asked for or could not run (a failing compliance verification step then says why)"}}
|
|
852
|
+
elif name == "export":
|
|
853
|
+
extra = {"picture": {"type": "object", "description": "after an export with both preset frame dimensions and scaling enabled: measured pad, blur-fill foreground or crop rectangle in the written frame (same fields as fit.py); omitted under --dry-run"},
|
|
854
|
+
"repair": {"type": "object", "description": "--repair (2.24): {before, after}, each {timestamp_warnings, decode_errors} counted over one full decode at -v warning"},
|
|
855
|
+
"loudness": {"type": "object", "description": "platform presets with audio: the written file's lufs/tp against target_lufs/target_tp. ok is true when inside the spec. normalized says whether export ran loudness.py to correct the file. silent true (lufs \"-inf\", ok false, normalized false) when the written audio is silent. measured false (lufs, tp and ok null, reason not_measured) when unreadable; too_short true (lufs and ok null, tp measured) for audio shorter than one 400 ms gating block."},
|
|
856
|
+
"alpha_mode": {"enum": ["straight", "premultiplied"], "description": "alpha presets only (prores4444, prores4444xq, qtrle, vp9-alpha, hap-alpha): how the colour was written, from --alpha-mode (default straight). The `alpha` verification step compares the written file's alpha with the source's frame by frame, tolerance 2 of 255 per frame (comparison: {ok, paired, worst_delta, worst_frame}; with a different frame count the mean and the most transparent frame, paired false; frames: {expected, measured}, each {mean, min, frames}); `codec` compares the written codec and profile with the preset's"},
|
|
857
|
+
"key": {"type": "object", "description": "--preset key-fill only: the key file {output (<out stem>_key.mov), identity, sha256, timecode (the source's start timecode written on both, or null)}. Verification adds key_fill_pair (width, height, frame count, rate and the video streams' lengths equal on both files) and key_level (the key's level against the source's alpha frame by frame, tolerance 2 of 255); the source's subtitle/data streams are not written (non_av_streams.dropped, reason key_fill)"},
|
|
858
|
+
"fill_sha256": {"type": "string", "description": "--preset key-fill only: the fill file's SHA-256 (the key's is key.sha256)"},
|
|
859
|
+
"trimmed": {"type": "object", "description": "present when the source was longer than the preset's platform maximum and the export was cut to it (no --allow-long): {from, to} in seconds; notes says so too"},
|
|
860
|
+
"non_av_streams": {"type": "object", "description": "the source's subtitle and data streams: {kept: [{type: subtitle|data, index (n-th of its type), codec, language (subtitle), output_codec}], dropped: [{type, index, codec, language, reason: write_failed|gif|key_fill|not_in_output}]}, read back from the written file (under --dry-run, as planned). A subtitle track is copied when the container holds it as it is, else converted to the container's text track (mov_text in .mp4/.mov, SubRip in .mkv); a trimmed export cuts it at the same point. Both lists are empty for a source with neither"},
|
|
861
|
+
"dropped_non_av_streams": {"type": "boolean", "description": "true when non_av_streams.dropped is not empty; a notes line says so too"},
|
|
862
|
+
"notes": {"type": "array", "items": {"type": "string"}}}
|
|
863
|
+
elif name == "loudness":
|
|
864
|
+
extra = {"measured": {"type": "object", "description": "the loudnorm measurement of the input (input_i, input_tp, input_lra, input_thresh, target_offset); with --measure-only it is the whole result. silent true (input_i \"-inf\") when the audio has no sound; too_short true (input_i null, input_tp measured) when it is shorter than one 400 ms gating block: not silence, and a normalisation is refused with error.reason audio_too_short"},
|
|
865
|
+
"targets": {"type": "object", "description": "the requested lufs / tp / lra"},
|
|
866
|
+
"result": {"type": "object", "description": "the written file measured again (input_i, input_tp, input_lra, ...), plus tp_ceiling_used, audio_bitrate_used, encodes and loudnorm_mode (linear, or dynamic when loudnorm could not apply one linear gain: the input's true peak plus the gain passes the ceiling, or its range is 0 or above --lra); note says why the loudness missed the target, naming dynamic mode when that is the cause. A loudness step on an output with no integrated loudness is ok false with reason not_measured"},
|
|
867
|
+
"versions": {"type": "array", "description": "--versions only (output is then null): one row per target, {target, output, targets, result}; every row's loudness and duration steps are in verification with a `version` key, and verified is true only when every version met its own target"},
|
|
868
|
+
"outputs": {"type": "array", "items": {"type": "string"}, "description": "--versions only: the files written, in the order asked"}}
|
|
869
|
+
elif name == "color":
|
|
870
|
+
extra = {"dropped_non_av_streams": {"type": "boolean"},
|
|
871
|
+
"sdr_path": {"enum": ["tonemap", "gamut"], "description": "--to-sdr only: tonemap for PQ / HLG / Dolby Vision (and --force on an untagged file); gamut for BT.2020 primaries on an SDR transfer, converted to BT.709 without a tone map"},
|
|
872
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "--to-sdr: which path was taken and why; --retag: why the video was re-encoded (the stream copy failed, or ffprobe still read the old tags on it)"},
|
|
873
|
+
"reencoded": {"type": "boolean", "description": "--retag: true when the stream copy could not carry the tags and the video was re-encoded with them on its frames"},
|
|
874
|
+
"measurements": {"type": "object", "description": "--correct only: signalstats levels of input and output"},
|
|
875
|
+
"legalize": {"type": "object", "description": "--legalize only: {standard, reference, legal {y, c}, output}: output is check.py --levels' levels document for the written file (window 0); its verification step legal_levels fails when one frame keeps more than 1 % of its luma or chroma samples out of range after the encode"}}
|
|
876
|
+
elif name == "loop":
|
|
877
|
+
extra = {"boomerang": {"type": "boolean", "description": "--boomerang: frames 0..N-1 then N-2..1, repeated, so neither turnaround frame is shown twice"},
|
|
878
|
+
"crossfade": {"type": "number", "description": "--crossfade only: the fade used, in seconds, rounded to whole frames; one repeat is the clip minus this"},
|
|
879
|
+
"expected_duration": {"type": "number", "description": "seconds requested: --duration, or --times x one repeat (the clip, the clip minus the crossfade, or a boomerang round trip); the duration verification step compares the file against it within 1.5 frames"},
|
|
880
|
+
"seam": {"type": "object", "description": "not with --boomerang: the first seam of the written file measured (at: between_repeats, or end_to_start for one repeat; time; video_step and video_typical_step, the mean luma change across the seam and the median one between neighbouring frames on a 64x36 grey copy, 0-255; audio_level_step_db, the RMS level 20 ms after the seam minus 20 ms before). A measurement, not a pass/fail: a step far above the typical one is a visible jump"},
|
|
881
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "--boomerang on a source with audio: the audio was dropped"}}
|
|
882
|
+
elif name == "cut":
|
|
883
|
+
extra = {"expected_duration": {"type": "number", "description": "seconds requested"},
|
|
884
|
+
"mode": {"enum": ["copy", "hybrid", "accurate", "smart"], "description": "copy: nothing re-encoded at any stage, the join included; accurate: --accurate was asked for or forced (or --smart fell back, reason in smart.reason); hybrid: asked for lossless but a segment or the join re-encoded anyway (reencode_reason says why); smart: --smart re-encoded only the partial GOPs at the cut points and copied the rest, verified"},
|
|
885
|
+
"possible_reencode_reason": {"type": "array", "items": {"enum": ["copy_failed", "stream_lost", "tolerance", "concat_fallback", "smart_fallback"]},
|
|
886
|
+
"description": "--dry-run only (else []): the reencode_reason values a real run may still add to a plan of mode copy or smart, which it would then report as hybrid or accurate, since the dry run does not write or measure the output cut (a --segments dry run does read the source's packets; see below): copy_failed and stream_lost on every planned copy; tolerance when a copied part is judged by its written length (a single segment, video or audio-only; a --segments part of a source with no B-frames, a Matroska/MPEG-TS part, or an audio-only part; not under --tolerance -1), so a copy that lands --tolerance or more from the requested cut is re-encoded; concat_fallback on a --segments stream-copy join; smart_fallback for mode smart, whose checks run on the written cut. A notes line says the same. [] for a plan that already re-encodes. A --segments dry run reads the source's packets and judges each part against --tolerance from them, as a real run does; tolerance is listed when a part is also judged by its written length"},
|
|
887
|
+
"smart": {"type": "object", "description": "--smart only: {applied: true, parts [{segment, kind: reencode|copy, start, end, frames}], reencoded_frames, copied_frames, matched (the source parameters the re-encoded parts reproduce: codec_name, profile, level, pix_fmt, width, height, sample_aspect_ratio, has_b_frames, colour tags), encoder (the libx264 arguments), checks {frames, grid_worst_seconds, copied_packets_equal, frames_decoded_equal, time_base}, time_base}; or {applied: false, reason, reason_code} when the cut could not be made or did not verify and the whole cut was re-encoded instead (reason_code: no_video, pending_input, vfr, codec, hold, params_unreadable, container, pix_fmt, profile, interlaced, reorder_depth, frame_rate, hdr, packets, no_frames, segments, av_offset, open_gop, seek, encode, copy_count, encode_count, params_mismatch, frames, decode, time_base)"},
|
|
888
|
+
"requested_start": {"type": ["number", "null"], "description": "one segment: the requested start, clamped to the media's duration (null for --segments)"},
|
|
889
|
+
"requested_end": {"type": ["number", "null"], "description": "one segment: the requested end, clamped to the media's duration (null for --segments)"},
|
|
890
|
+
"requested_segments": {"type": ["array", "null"], "description": "--segments: [[start, end], ...] requested, clamped to the media's duration (null for one segment)"},
|
|
891
|
+
"requested_duration": {"type": "number", "description": "the requested length, as expected_duration"},
|
|
892
|
+
"output_duration": {"type": ["number", "null"], "description": "the written file's length, measured (null under --dry-run)"},
|
|
893
|
+
"duration_delta_seconds": {"type": ["number", "null"], "description": "output_duration minus requested_duration (null under --dry-run)"},
|
|
894
|
+
"nearest_keyframes": {"type": ["array", "null"], "description": "the keyframes within 5 s of a start whose stream copy snapped past --tolerance and was re-encoded (null otherwise)"},
|
|
895
|
+
"snap": {"type": ["object", "null"], "description": "--snap beats: {mode, tolerance, confidence, tempo_bpm, grid, grid_points, moved, snapped, unchanged, source}; null otherwise"},
|
|
896
|
+
"dropped_audio_streams": {"type": "integer", "description": "audio tracks of the source this cut did not write (cut writes one, on a stream copy as on a re-encode); 0 for a source with one or none. A notes line and an audio_tracks_dropped warning say so too"},
|
|
897
|
+
"duration_error_ms": {"type": ["number", "null"], "description": "written minus requested, measured by ffprobe (null under --dry-run)"},
|
|
898
|
+
"precision": {"enum": ["packet", "sample", "codec_frame", "frame"],
|
|
899
|
+
"description": "since 3.0.0 the least exact segment's (as least_exact_precision; 2.x: the whole run's, packet only when nothing re-encoded): packet: stream copy on a packet/keyframe boundary; sample: decoded audio trimmed to the sample, lossless output; codec_frame: sample-trimmed then framed by a lossy encoder (priming delay adds to the length); frame: re-encoded video"},
|
|
900
|
+
"least_exact_precision": {"enum": ["packet", "sample", "codec_frame", "frame"],
|
|
901
|
+
"description": "the least exact segment's precision (the order packet, codec_frame, frame, sample); differs from precision only for an audio-only --segments join of copied and re-encoded parts"},
|
|
902
|
+
"keyframe_snapped": {"type": ["boolean", "null"], "description": "since 3.0.0 equal to start_snapped: a copied start really moved (2.x: precision was packet, the run a stream copy end to end)"},
|
|
903
|
+
"start_snapped": {"type": ["boolean", "null"], "description": "measured: true when a copied segment's picture starts more than one frame from its requested start (the keyframe the copy's seek lands on, measured with the seek ffmpeg makes); false when every start is where asked (an MP4 edit list hides the pre-roll, the start is a keyframe, an audio-only copy, or everything re-encoded); null when a copied start was not measured (--dry-run)"},
|
|
904
|
+
"reencoded": {"type": "boolean"},
|
|
905
|
+
"reencode_reason": {"type": "array", "items": {"enum": ["requested", "codec", "vfr", "vfr_inconclusive", "pcm_container", "copy_failed", "stream_lost", "tolerance", "concat_fallback", "smart", "smart_fallback"]},
|
|
906
|
+
"description": "why anything was re-encoded, distinct values in first-seen order ([] when nothing was): smart (--smart re-encoded the partial GOPs at the cut points), smart_fallback (--smart could not be made or verified: the whole cut was re-encoded, smart.reason says why), requested (--accurate), codec (--codec), vfr (a variable-frame-rate source forced --accurate), vfr_inconclusive (its frame timing could not be measured), pcm_container (compressed audio into a .wav), copy_failed (the stream copy errored), stream_lost (the copy wrote no video or no audio, as an MPEG-TS copy with no keyframe in its window does), tolerance (a keyframe snap past --tolerance), concat_fallback (--segments parts could not be joined by stream copy)"},
|
|
907
|
+
"segment_precision": {"type": ["array", "null"], "items": {"enum": ["packet", "sample", "codec_frame", "frame"]},
|
|
908
|
+
"description": "--segments only: each segment's precision in order; least_exact_precision is the least exact of them (null for a single segment)"},
|
|
909
|
+
"edit_list": {"type": "boolean", "description": "a single MP4/MOV stream copy kept the edit list it wrote instead of -avoid_negative_ts make_zero, so the keyframe's pre-roll is stored but hidden and the picture and the sound start at the requested time (the default since 3.0.0; false under --no-edit-list and for every other path)"},
|
|
910
|
+
"stored_preroll_seconds": {"type": ["number", "null"], "description": "with edit_list: seconds decoded from the keyframe the copy's seek lands on up to the requested start and hidden by the edit list (a player that ignores edit lists shows them); null otherwise"},
|
|
911
|
+
"av_start_skew_seconds": {"type": ["number", "null"], "description": "the output's audio start minus its video start (null when either is missing or under --dry-run); reported, never repaired: on a stream copy only, a warning in notes when it is more than max(2 frames, 0.1 s) away from the source's own skew where the copy's picture starts (the keyframe it began from; the requested start with an edit list), naming --accurate (and the edit list for a single MP4/MOV copy whose start snapped under --no-edit-list)"},
|
|
912
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "stored pre-roll behind an edit list, or an edit-list copy judged by its video; an A/V start skew with its remedies; a source --vfr-guard average took for VFR whose sampled timing is constant (naming --vfr-guard sampled), or a sampled measurement that forced or (--vfr-guard off) skipped a re-encode; a --segments segment ended with the video, or held on its last frame for its sound; a --segments join re-cut because the source uses open GOPs, because a later B-frame .mp4/.mov segment starts between keyframes, or because its join check failed; under --dry-run, a plan of mode copy or smart that a real run may still re-encode (possible_reencode_reason)"},
|
|
913
|
+
"vfr_check": {"type": "object", "description": "the sampled frame timing of a video input that could still stream-copy: under --vfr-guard average (2.x's default) only when its nominal and average frame rates differ, which re-encodes it (reason vfr) whatever the sample says; under sampled (the default since 3.0.0) or off on every such input (absent for audio-only input or output, --accurate, --codec, or a --dry-run input a plan has not written yet): {heuristic: true, measured, method: \"sampled\", guard, windows, deltas}. measured is sampled_cfr (every packet interval in up to five 6 s windows within a tick, at least 1 ms and at most half a frame, of its window's median, and the windows agree; the file-start window's first interval is ignored, and a seeked window is read from its first keyframe on, because a seek lands mid-GOP and the frames before it are not a full run), vfr (under sampled, forces a re-encode, reason vfr) or inconclusive (fewer than 20 intervals or ffprobe failed; under sampled, reason vfr_inconclusive). --vfr-guard off keeps the copy either way, with a note. Variable timing between the windows is not seen"},
|
|
914
|
+
"lossless_alternative": {"type": ["string", "null"], "description": "when a lossless cut re-encoded because of the keyframe snap: the --start that would stream-copy instead, and how far it is from the request"},
|
|
915
|
+
"join_check": {"type": ["object", "null"], "description": "--segments video stream-copy join: the written file measured by demuxing, {packets, expected_packets, max_step_seconds, audio_offset_ms, audio_parts_checked, ok}. expected_packets counts the source's video packets from each part's start keyframe to its end (or the end of the video); max_step_seconds is the largest presentation step (null when vfr_check measured anything but sampled_cfr, e.g. a --vfr-guard off join of variable timing, which checks the count only), and each step at a join must be the step its parts predict within 1 ms; audio_offset_ms is, per part, its sound's shift minus its picture's (+ = sound late) from audio packets matched by CRC32 to the source stream shaped like the joined audio (FFmpeg's default selection may copy one other than a:0; an MPEG-TS source's AAC is hashed without its ADTS headers) (null for a part with no unique match, e.g. digital silence; null as a whole when the source has no audio or the video check failed), and audio_parts_checked counts the measured parts; ok is the conjunction (counts, steps, every measured part within 5 ms), and false means the join was re-cut from the source (concat_fallback) and this is the failed measurement. null for a single segment, audio, --dry-run, --accurate/--codec/a forced re-encode, a segment that re-encoded, or a join that fell back before a copy join was attempted (open GOPs, a later B-frame segment starting between keyframes, parts that differ, a concat error)"},
|
|
916
|
+
"declick_ms": {"type": ["number", "null"], "description": "--segments joined by the re-encode (--accurate, a forced re-encode or concat_fallback): the fade in ms asked for on each side of every join, so butted cuts do not click (20 by default, --declick-ms; 0 under --no-declick; the file's own start and end are not faded). Each fade is capped at half its segment, so a segment shorter than twice this is faded for half its length. null when there is no join to fade: a single segment, a source with no audio, or a stream-copy join, whose sound is copied and not faded"},
|
|
917
|
+
"segment_end_snap_seconds": {"type": ["array", "null"], "items": {"type": ["number", "null"]}, "description": "--segments stream-copy join: per segment, the signed seconds its end moved to the keyframe the copied part stops at (the first keyframe at or after the requested end, never an earlier one; null for a part that runs to the end of the video, a part of a source with no B-frames, which is cut to its requested end as in every 2.x release, or a Matroska/MPEG-TS part, which is not snapped). null as a whole unless the output is those copied parts: a single segment, audio, --dry-run, or any re-encode or fallback"}}
|
|
918
|
+
elif name == "multicam":
|
|
919
|
+
extra = {"cuts": {"type": "array", "description": "[[start, end, camera], ...] on the reference timeline: the camera actually rendered. A range whose camera had not started yet plays camera 0, and diagnostics.fallbacks names the camera asked for (code camera_not_started)"},
|
|
920
|
+
"offsets_seconds": {"type": "array"}, "confidence": {"type": "array"},
|
|
921
|
+
"drift_ppm": {"type": "array", "items": {"type": ["number", "null"]}, "description": "--fix-drift: per input, the drift measured against the reference (the reference itself 0, the clock); null for a camera whose drift was not measured, with the reason in drift_skipped_reason (also a diagnostics.skipped entry, drift_correction_skipped)"},
|
|
922
|
+
"drift_skipped_reason": {"type": "array", "items": {"enum": ["too_short", "low_confidence", None]}, "description": "--fix-drift: per input, why its drift was not measured (too_short: no tail window far enough from the head; low_confidence: the tail did not correlate), null when it was and for the reference"}}
|
|
923
|
+
elif name == "join":
|
|
924
|
+
extra = {"mode": {"enum": ["video", "audio", "copy"], "description": "copy: --copy --transition none wrote a stream copy"}, "clips": {"type": "integer"}, "transition": {"type": "string"},
|
|
925
|
+
"expected_duration": {"type": ["number", "null"], "description": "clip lengths minus the transitions; null under --dry-run while an input is pending (its length is unknown)"},
|
|
926
|
+
"frame_rate": {"type": "string", "description": "video mode only: the join's frame rate as an exact fraction (\"30000/1001\"), the rate every clip length and xfade offset is counted in"},
|
|
927
|
+
"clip_frames": {"type": "array", "items": {"type": "integer"}, "description": "video mode only: per clip, the whole frames of frame_rate it holds in the join (its picture's, or the frames that cover a sound running more than a frame past it); its sound is cut to the samples those frames last. A pending --dry-run input counts 0"},
|
|
928
|
+
"transition_frames": {"type": "integer", "description": "video mode only: the frames each xfade/acrossfade overlaps (--duration rounded to whole frames, at least 1; 0 for --transition none)"},
|
|
929
|
+
"sample_rate": {"type": "integer", "description": "audio mode only"}, "channels": {"type": "integer", "description": "audio mode only"},
|
|
930
|
+
"video": {"type": "boolean", "description": "false in audio mode: the output has no video stream"},
|
|
931
|
+
"skipped": {"type": "array", "description": "inputs --on-missing skip left out: [{index, path, reason}] ([] when none were)"},
|
|
932
|
+
"silent": {"type": "array", "description": "inputs whose audio peak is at or below --silence-threshold (default -50 dBFS) and that --on-silent warn (default) joined anyway, plus every --allow-silent input that was silent: [{index, path, peak_db, at, end, intended?}]; at/end are the input's start and end in output seconds (a transition overlaps neighbours), intended: true marks an --allow-silent input (joined whatever --on-silent says, no warning). [] otherwise; fail refuses unallowed ones under problems, skip lists them under skipped; an input with no audio stream is never silent"},
|
|
933
|
+
"short_segments": {"type": "array", "description": "warning, never a refusal: measured inputs shorter than 2 frames at the join's fps (audio-only join: shorter than 0.05 s), [{index, path, duration}] ([] when none), each also in notes; a pending --dry-run input is not measured"},
|
|
934
|
+
"duplicates": {"type": "array", "description": "warning, never a refusal (a repeat can be intended): a path (compared resolved) listed more than once and joined each time, [{path, indices}] with 0-based list positions ([] when none), also in notes"},
|
|
935
|
+
"pending": {"type": "array", "description": "--dry-run: inputs that do not exist yet, planned on as an earlier step's output and never also under skipped: [{index, path}] ([] otherwise)"},
|
|
936
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "--on-silent warn: which silent inputs were joined anyway; short_segments / duplicates: which inputs and why; --dry-run with pending inputs: which ones, what a real run does if one is still missing (including a skip that leaves fewer than two inputs), whether the mode came from the extensions, and which planned numbers are the unmeasured stub's placeholders (a pending first clip's frame and rate, xfade offsets after a pending clip)"}}
|
|
937
|
+
elif name == "audio":
|
|
938
|
+
extra = {"video": {"type": "boolean", "description": "true when the input's video stream was copied; false for an audio output extension (extraction)"},
|
|
939
|
+
"audio_stream": {"type": "integer", "description": "which input audio stream was processed (--audio-stream)"},
|
|
940
|
+
"dynamics": {"type": "array", "items": {"enum": ["agate", "acompressor", "alimiter"]}, "description": "typed dynamics filters applied, in graph order"},
|
|
941
|
+
"tracks": {"type": "array", "description": "--track only (#420): one entry per audio stream of the written file, in order, the input's own sound first: [{index, file (the source), title, language, channels, duration}], the last four as ffprobe and the decoder read the written file (null where it holds none or could not be measured; a dry run lists the names and languages asked, with channels and duration null). A track_tags step checks the names and languages asked against the file; the streams step checks the count; a track_duration step with reason not_measured says a length could not be counted"},
|
|
942
|
+
"silent": {"type": "array", "description": "--on-silent warn (default), only when a track was silent: [{flag, path, peak_db}] for each --music/--replace/--effects file, or under --duck the voice (flag \"input\"), whose whole-file peak is at or below --silence-threshold (default -50 dBFS); it was mixed anyway. --on-silent fail refuses instead, reason \"silent (peak X dBFS)\" in problems"},
|
|
943
|
+
"notes": {"type": "array", "items": {"type": "string"}, "description": "present with `silent`: which tracks were silent and how to refuse them"},
|
|
944
|
+
"timing": {"type": "object", "description": "#486: {tempo, atempo, length_samples, sample_rate}: the --tempo factor (null without it), the atempo stages (each 0.5..2.0, [] at tempo 1) whose product it is, --length-samples (null without it) and the sample rate that count is in (null when not measured yet); with --length-samples a length_samples verification step counts the written track's decoded samples (exact for PCM/FLAC/ALAC, within tolerance_samples, one codec frame, for a lossy codec)"},
|
|
945
|
+
"audio": {"type": "object", "description": "what the mix was built from: voice (null | light | medium | strong), stereo_widen, channel (--channel N, the 0-based channel kept, else null), sample_rate (--sample-rate, else null; both are read back from the output as the channels / sample_rate verification steps), effects/effects_volume, and with --music the music_volume plus duck (null when --duck was not given, else the threshold in dB and linear, the sidechain gate's ratio, attack_ms, release_ms, and amount_db, the depth in dB the bed is lowered under speech)"}}
|
|
946
|
+
if name in ("silence", "verify"):
|
|
947
|
+
extra["cut_plan"] = {"type": "object", "description": "pacing-cut-plan@1, source frame and audio sample spans, times in milliseconds"}
|
|
948
|
+
if name == "silence":
|
|
949
|
+
from _common.pacing import profile_schema
|
|
950
|
+
extra["profile"] = profile_schema()
|
|
951
|
+
if name == "verify":
|
|
952
|
+
extra.update(checks={"type": "object"}, max_frame_pts_error_ms={"type": "number"},
|
|
953
|
+
boundary_sample_deltas={"type": "array"}, output_pauses_ms={"type": "array"})
|
|
954
|
+
for key, prop in EMITTED_KEYS.get(name, {}).items():
|
|
955
|
+
extra.setdefault(key, prop)
|
|
956
|
+
if name in ("overlay", "graphics", "caption", "grid"):
|
|
957
|
+
extra["font_used"] = FONT_USED_SCHEMA
|
|
958
|
+
if name in ALPHA_LINE_TOOLS:
|
|
959
|
+
extra.update(alpha_result_schema(name))
|
|
960
|
+
if name in NON_AV_STREAM_TOOLS and "dropped_non_av_streams" not in extra:
|
|
961
|
+
extra["dropped_non_av_streams"] = {"type": "boolean", "description": "true when the source's subtitle or data streams are not in the output: either the run leaves them out by design (a path whose output they would no longer match, such as speedramp.py's, join.py's or freeze.py's), or the container refused them and the encode ran again without them (a non_av_streams_dropped fallback says which and why; a refused data stream is retried away alone first, so it does not cost the subtitles, and for a source with both a subtitle and a data stream this is then false when the MP4/MOV muxer writes the timecode track itself; a source with a data stream and no subtitle reports true after its retry whatever the muxer wrote); export.py's non_av_streams lists them"}
|
|
962
|
+
if name == "cropdetect":
|
|
963
|
+
extra.update({"windows": {"type": "integer", "description": "sampled windows (--samples)"},
|
|
964
|
+
"windows_failed": {"type": "integer", "description": "windows ffmpeg could not decode and that were skipped (a cropdetect_windows_failed warning when > 0); every window failing is a kind ffmpeg failure"}})
|
|
965
|
+
props = dict(base)
|
|
966
|
+
props.update(extra)
|
|
967
|
+
notes = props.get("notes")
|
|
968
|
+
if hw:
|
|
969
|
+
# emit() adds the VideoToolbox quality line to `notes` on every tool that takes --hw, so every
|
|
970
|
+
# such tool publishes `notes`, and a tool-specific condition (loop's "--boomerang ... the audio
|
|
971
|
+
# was dropped", export's own lines) is not the only one it can carry
|
|
972
|
+
gpu = "a line that its quality is not CRF-equivalent (on a VideoToolbox encode: --hw / $FFMPEG_SKILL_HW; see hw)"
|
|
973
|
+
if isinstance(notes, dict) and notes.get("description"):
|
|
974
|
+
props["notes"] = dict(notes, description=notes["description"] + "; also " + gpu)
|
|
975
|
+
else:
|
|
976
|
+
props["notes"] = dict(notes or {"type": "array", "items": {"type": "string"}}, description=gpu[0].upper() + gpu[1:])
|
|
977
|
+
required = ["status", "output", "dry_run", "commands"]
|
|
978
|
+
return {"type": "object", "properties": props, "required": required, "additionalProperties": True}
|
|
979
|
+
|
|
980
|
+
@functools.lru_cache(maxsize=1)
|
|
981
|
+
def _unverified_table() -> Dict[str, List[str]]:
|
|
982
|
+
"""emit()'s per-tool unverified range, read where the results are made so the two cannot differ."""
|
|
983
|
+
sys.path.insert(0, str(ROOT / "scripts"))
|
|
984
|
+
from _common.emit import UNVERIFIED
|
|
985
|
+
return UNVERIFIED
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
def skill_examples() -> Dict[str, List[Dict[str, Any]]]:
|
|
989
|
+
"""1.20.0: per-tool `examples`, parsed from SKILL.md's "User says" / "Do" table -- the
|
|
990
|
+
same facts that table already states, machine-readable instead of prose-only. A row
|
|
991
|
+
naming more than one tool (e.g. metadata.py's --auto-chapters row also names render.py)
|
|
992
|
+
attaches to each; a row naming none (prose only, no backtick command) attaches to none.
|
|
993
|
+
`prompts` is a list because a row often gives several phrasings ("cut from 1:20 to 2:05",
|
|
994
|
+
"trim the first 10 s") for the one `command`; `command` has the markdown backticks
|
|
995
|
+
stripped but otherwise keeps the row's own text (including "or"/"then" alternatives).
|
|
996
|
+
"""
|
|
997
|
+
examples: Dict[str, List[Dict[str, Any]]] = {}
|
|
998
|
+
try:
|
|
999
|
+
lines = (ROOT / "SKILL.md").read_text(encoding="utf-8").splitlines()
|
|
1000
|
+
except OSError:
|
|
1001
|
+
return examples
|
|
1002
|
+
in_table = False
|
|
1003
|
+
esc_pipe = "\x00" # a markdown-escaped "\|" (a literal pipe inside a cell, e.g. broll's --audio b\|mix) is not a column separator
|
|
1004
|
+
for line in lines:
|
|
1005
|
+
if line.startswith("| User says"):
|
|
1006
|
+
in_table = True
|
|
1007
|
+
continue
|
|
1008
|
+
if not in_table:
|
|
1009
|
+
continue
|
|
1010
|
+
if not line.startswith("|"):
|
|
1011
|
+
break
|
|
1012
|
+
if line.startswith("|---") or line.startswith("|-----"):
|
|
1013
|
+
continue
|
|
1014
|
+
cells = line.strip().strip("|").replace("\\|", esc_pipe).split("|")
|
|
1015
|
+
if len(cells) != 2:
|
|
1016
|
+
continue
|
|
1017
|
+
prompt_cell, do = (c.replace(esc_pipe, "|").strip() for c in cells)
|
|
1018
|
+
prompts = re.findall(r'"([^"]+)"', prompt_cell) or [prompt_cell.strip('"')]
|
|
1019
|
+
command = re.sub(r"`([^`]*)`", r"\1", do)
|
|
1020
|
+
for tool in dict.fromkeys(re.findall(r"`([a-z][a-z0-9_]*)\.py", do)):
|
|
1021
|
+
examples.setdefault(tool, []).append({"prompts": prompts, "command": command})
|
|
1022
|
+
return examples
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
# ----------------------------------------------------------------------------- environment
|
|
1026
|
+
def skill_version() -> str:
|
|
1027
|
+
for candidate in (ROOT / "package.json",):
|
|
1028
|
+
try:
|
|
1029
|
+
return str(json.loads(candidate.read_text(encoding="utf-8"))["version"])
|
|
1030
|
+
except (OSError, ValueError, KeyError):
|
|
1031
|
+
continue
|
|
1032
|
+
return "unknown"
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
def skill_description() -> str:
|
|
1036
|
+
try:
|
|
1037
|
+
text = (ROOT / "SKILL.md").read_text(encoding="utf-8")
|
|
1038
|
+
m = re.search(r"^description:\s*(.+)$", text, re.M)
|
|
1039
|
+
value = m.group(1).strip() if m else ""
|
|
1040
|
+
# The scalar is single-quoted in SKILL.md: unquoted, the ": " inside the text ("...
|
|
1041
|
+
# requests: cut, trim ...") is a new mapping key to a strict YAML parser and the whole
|
|
1042
|
+
# frontmatter fails to load (GitHub's renderer reported it; npx skills add and Claude
|
|
1043
|
+
# Code's loader parse it strictly). '' is the only escape inside a YAML single-quoted scalar.
|
|
1044
|
+
if len(value) >= 2 and value[0] == value[-1] == "'":
|
|
1045
|
+
value = value[1:-1].replace("''", "'")
|
|
1046
|
+
return value
|
|
1047
|
+
except OSError:
|
|
1048
|
+
return ""
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
def public_tools() -> List[str]:
|
|
1052
|
+
return sorted(p.stem for p in HERE.glob("*.py") if not p.name.startswith("_"))
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
# `ffmpeg -filters` rows: FFmpeg <= 7 prints three flag characters (`..C acompressor A->A ...`),
|
|
1056
|
+
# FFmpeg 8 prints two (`T. acompressor A->A ...`). The row is recognised by its io-spec token
|
|
1057
|
+
# (`A->A`, `|->V`, `N->N`, ...) so the flag width does not matter; a legend line never carries `->`.
|
|
1058
|
+
_FILTER_ROW = re.compile(r"^\s*(?:[A-Z.]{1,6}\s+)?([A-Za-z0-9_]+)\s+(\S*->\S*)(?:\s|$)")
|
|
1059
|
+
# `ffmpeg -encoders` rows follow a ` ------` separator: flags (six characters today; any width of
|
|
1060
|
+
# letters and dots is accepted) then the encoder name. A legend line has `=` where the name would be.
|
|
1061
|
+
_ENCODER_ROW = re.compile(r"^\s*[A-Z.]{2,10}\s+([A-Za-z0-9_-]+)(?:\s|$)")
|
|
1062
|
+
_LIST_SEPARATOR = re.compile(r"^\s*-{3,}\s*$")
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
def _parse_ff_list(flag: str, text: str) -> List[str]:
|
|
1066
|
+
"""Names in the stdout of `ffmpeg <flag>`; empty when no row was recognised."""
|
|
1067
|
+
names: List[str] = []
|
|
1068
|
+
if flag == "-filters":
|
|
1069
|
+
for line in text.splitlines():
|
|
1070
|
+
m = _FILTER_ROW.match(line)
|
|
1071
|
+
if m:
|
|
1072
|
+
names.append(m.group(1))
|
|
1073
|
+
elif flag in ("-encoders", "-decoders"):
|
|
1074
|
+
lines = text.splitlines()
|
|
1075
|
+
sep = next((i for i, l in enumerate(lines) if _LIST_SEPARATOR.match(l)), None)
|
|
1076
|
+
rows = lines[sep + 1:] if sep is not None else lines
|
|
1077
|
+
for line in rows:
|
|
1078
|
+
m = _ENCODER_ROW.match(line)
|
|
1079
|
+
if m and m.group(1) != "=":
|
|
1080
|
+
names.append(m.group(1))
|
|
1081
|
+
elif flag == "-bsfs":
|
|
1082
|
+
for line in text.splitlines():
|
|
1083
|
+
parts = line.split()
|
|
1084
|
+
if len(parts) == 1 and not parts[0].endswith(":"):
|
|
1085
|
+
names.append(parts[0])
|
|
1086
|
+
return names
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
def _exe(binary: str) -> str:
|
|
1090
|
+
"""The ffmpeg/ffprobe the tools run (PATH, or Homebrew's keg-only ffmpeg-full over a lean one:
|
|
1091
|
+
_common.runner.ffmpeg_exe), so doctor reports the build the tools will use, not the one PATH names."""
|
|
1092
|
+
from _common.runner import ffmpeg_exe
|
|
1093
|
+
return ffmpeg_exe(binary)[0]
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
def _ff_listing(binary: str, flag: str) -> Dict[str, Any]:
|
|
1097
|
+
"""`{"names": [...], "status": parsed | unparsed | failed | missing, "detail": str}` for `ffmpeg <flag>`.
|
|
1098
|
+
|
|
1099
|
+
`parsed`: rows recognised. `unparsed`: ffmpeg ran but no row matched, so the capabilities it
|
|
1100
|
+
covers are unknown, not absent. `failed`: ffmpeg exited non-zero. `missing`: no binary on PATH.
|
|
1101
|
+
"""
|
|
1102
|
+
exe = _exe(binary)
|
|
1103
|
+
if not exe:
|
|
1104
|
+
return {"names": [], "status": "missing", "detail": f"{binary} not on PATH"}
|
|
1105
|
+
try:
|
|
1106
|
+
proc = subprocess.run([exe, "-hide_banner", flag], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8", errors="replace", timeout=_DETECT_TIMEOUT)
|
|
1107
|
+
except subprocess.TimeoutExpired:
|
|
1108
|
+
return {"names": [], "status": "failed", "detail": f"{binary} {flag} did not exit within {_DETECT_TIMEOUT}s"}
|
|
1109
|
+
except OSError as e:
|
|
1110
|
+
return {"names": [], "status": "failed", "detail": f"{binary} {flag}: {e}"}
|
|
1111
|
+
if proc.returncode != 0:
|
|
1112
|
+
tail = " ".join(proc.stderr.strip().splitlines()[-2:])
|
|
1113
|
+
return {"names": [], "status": "failed", "detail": f"{binary} {flag} exited {proc.returncode}: {tail}"}
|
|
1114
|
+
names = _parse_ff_list(flag, proc.stdout)
|
|
1115
|
+
if not names:
|
|
1116
|
+
return {"names": [], "status": "unparsed", "detail": f"no row recognised in `{binary} {flag}` output ({len(proc.stdout.splitlines())} lines)"}
|
|
1117
|
+
return {"names": names, "status": "parsed", "detail": f"{len(names)} entries"}
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
# GPU-backed encoders are named `<codec>_<backend>` by every ffmpeg build (h264_nvenc,
|
|
1121
|
+
# hevc_videotoolbox, av1_qsv, h264_vaapi, hevc_amf, ...); recognised by the backend suffix so a
|
|
1122
|
+
# new codec in a future ffmpeg build needs no change here.
|
|
1123
|
+
_GPU_ENCODER_SUFFIXES = ("_nvenc", "_videotoolbox", "_qsv", "_vaapi", "_amf")
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
def _gpu_encoders(encoders_listing: Dict[str, Any]) -> Dict[str, Any]:
|
|
1127
|
+
"""GPU-backed encoders this ffmpeg BUILD was compiled with, read from `-encoders` alone.
|
|
1128
|
+
|
|
1129
|
+
This proves the build carries e.g. h264_nvenc; it does NOT prove the GPU/driver on this
|
|
1130
|
+
machine will accept a job -- that would require actually running an encode, which doctor's
|
|
1131
|
+
introspection deliberately never does beyond listing/-version (see doctor()'s own docstring).
|
|
1132
|
+
A caller that needs to know "will a GPU encode actually work here" has to try one; this only
|
|
1133
|
+
answers "did this ffmpeg build even ship the capability."
|
|
1134
|
+
"""
|
|
1135
|
+
status = encoders_listing["status"]
|
|
1136
|
+
if status != "parsed":
|
|
1137
|
+
return {"status": status, "detail": encoders_listing["detail"], "present": []}
|
|
1138
|
+
present = sorted(n for n in encoders_listing["names"] if n.endswith(_GPU_ENCODER_SUFFIXES))
|
|
1139
|
+
return {"status": "parsed", "present": present}
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
# What the tools do about a build without libx264 / libx265 (_common.decision._vt_in_place_of)
|
|
1143
|
+
_VIDEOTOOLBOX_FOR = {"encoder:libx264": "encoder:h264_videotoolbox", "encoder:libx265": "encoder:hevc_videotoolbox"}
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
def _covered_by_videotoolbox(encoders_listing: Dict[str, Any]) -> Dict[str, str]:
|
|
1147
|
+
"""`{"encoder:libx264": "encoder:h264_videotoolbox", ...}` for each CPU encoder the (read) listing
|
|
1148
|
+
lacks while the matching VideoToolbox encoder is listed and this machine can run it: the tools
|
|
1149
|
+
encode with the latter there without --hw, so the former does not block anything. Empty
|
|
1150
|
+
otherwise -- an unread listing proves nothing, and a build that has the CPU encoder needs no cover."""
|
|
1151
|
+
if encoders_listing["status"] != "parsed":
|
|
1152
|
+
return {}
|
|
1153
|
+
from _common.runner import hw_platform_reason
|
|
1154
|
+
if hw_platform_reason() is not None:
|
|
1155
|
+
return {}
|
|
1156
|
+
have = set(encoders_listing["names"])
|
|
1157
|
+
return {cap: alt for cap, alt in _VIDEOTOOLBOX_FOR.items() if cap[8:] not in have and alt[8:] in have}
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
def _version_line(binary: str) -> Optional[str]:
|
|
1161
|
+
exe = _exe(binary)
|
|
1162
|
+
if not exe:
|
|
1163
|
+
return None
|
|
1164
|
+
try:
|
|
1165
|
+
proc = subprocess.run([exe, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8", errors="replace", timeout=_DETECT_TIMEOUT)
|
|
1166
|
+
except subprocess.TimeoutExpired:
|
|
1167
|
+
return None
|
|
1168
|
+
first = (proc.stdout or proc.stderr).splitlines()[:1]
|
|
1169
|
+
m = re.match(rf"{binary} version (\S+)", first[0]) if first else None
|
|
1170
|
+
return m.group(1) if m else (first[0] if first else "unknown")
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
def _ffmpeg_license(exe: Optional[str]) -> Optional[str]:
|
|
1174
|
+
"""Read the selected executable's upstream -L notice without guessing from its version."""
|
|
1175
|
+
if not exe:
|
|
1176
|
+
return None
|
|
1177
|
+
try:
|
|
1178
|
+
proc = subprocess.run([exe, "-hide_banner", "-L"], capture_output=True, encoding="utf-8",
|
|
1179
|
+
errors="replace", timeout=_DETECT_TIMEOUT)
|
|
1180
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
1181
|
+
return None
|
|
1182
|
+
if proc.returncode:
|
|
1183
|
+
return None
|
|
1184
|
+
notice = " ".join((proc.stdout + "\n" + proc.stderr).split())
|
|
1185
|
+
if "has nonfree parts compiled in." in notice:
|
|
1186
|
+
return "nonfree"
|
|
1187
|
+
match = re.search(r"GNU (Lesser )?General Public License as published by the Free Software Foundation; "
|
|
1188
|
+
r"either version (2\.1|2|3) of the License, or \(at your option\) any later version", notice)
|
|
1189
|
+
if not match:
|
|
1190
|
+
return None
|
|
1191
|
+
family = "LGPL" if match[1] else "GPL"
|
|
1192
|
+
version = match[2] if "." in match[2] else match[2] + ".0"
|
|
1193
|
+
return f"{family}-{version}-or-later"
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
# ----------------------------------------------------------------------------- FFmpeg security advisories
|
|
1197
|
+
# doctor's `ffmpeg_security`: a small, dated, hand-maintained table of high-severity FFmpeg CVEs and
|
|
1198
|
+
# the first upstream point release on each branch that carries the fix. ffmpeg-skill does not ship
|
|
1199
|
+
# FFmpeg, so a user stays exposed to a decoder bug until they upgrade; doctor says so. It reads the
|
|
1200
|
+
# table and the local `-version` line only -- no network call, ever (execution.network: false).
|
|
1201
|
+
#
|
|
1202
|
+
# Source: https://ffmpeg.org/security.html (each release section lists the CVEs it fixes), checked
|
|
1203
|
+
# on FFMPEG_ADVISORIES_CHECKED. A branch absent from `fixed_in` had no release listed with the fix
|
|
1204
|
+
# on that date. Only CVEs that page lists go in: AISLE's batch (CVE-2026-64830..64835) was not on it
|
|
1205
|
+
# on 2026-10-22, so it has no row yet -- add one, with its releases, when the page lists them.
|
|
1206
|
+
# When editing: update FFMPEG_ADVISORIES_CHECKED, docs/contract.md and the CHANGELOG together.
|
|
1207
|
+
FFMPEG_ADVISORY_SOURCE = "https://ffmpeg.org/security.html"
|
|
1208
|
+
FFMPEG_ADVISORIES_CHECKED = "2026-10-22"
|
|
1209
|
+
FFMPEG_ADVISORIES: List[Dict[str, Any]] = [
|
|
1210
|
+
{"cve": "CVE-2026-8461", "name": "PixelSmash", "component": "MagicYUV decoder",
|
|
1211
|
+
"kind": "heap out-of-bounds write", "cvss": 8.8,
|
|
1212
|
+
# security.html lists the fix under 9.0, 8.1.2 and 8.0.3; no 7.1.x/7.0.x/6.1.x release carries it
|
|
1213
|
+
"fixed_in": {"8.0": "8.0.3", "8.1": "8.1.2", "9.0": "9.0"}},
|
|
1214
|
+
]
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
def _parse_ffmpeg_version(text: Optional[str]) -> Optional[tuple]:
|
|
1218
|
+
"""(major, minor, patch) from an `ffmpeg -version` token: `6.1.1`, `8.0`, `n7.1.2`, and distro
|
|
1219
|
+
builds that append to the upstream number (`8.0.1-3ubuntu2`, `7.1.2-0+deb13u1`,
|
|
1220
|
+
`8.1.2-full_build-www.gyan.dev`). None for anything else -- a git snapshot (`N-12345-g...`,
|
|
1221
|
+
`2026-10-01-git-...`) has no release number to compare, and a guess would be a false alarm."""
|
|
1222
|
+
if not text:
|
|
1223
|
+
return None
|
|
1224
|
+
m = re.match(r"n?(\d+)\.(\d+)(?:\.(\d+))?(?![\d.])", text.strip())
|
|
1225
|
+
if not m:
|
|
1226
|
+
return None
|
|
1227
|
+
return (int(m.group(1)), int(m.group(2)), int(m.group(3) or 0))
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
def _vstr(v: tuple) -> str:
|
|
1231
|
+
return ".".join(str(x) for x in (v if v[2] else v[:2]))
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
def _advisory_hits(version: Optional[str]) -> Optional[List[Dict[str, Any]]]:
|
|
1235
|
+
"""The table's rows this version is older than (None: the version could not be parsed). A
|
|
1236
|
+
version on a branch the table lists is compared with that branch's fixing release; one on an
|
|
1237
|
+
older branch with no fixing release is compared with the oldest release that has the fix."""
|
|
1238
|
+
v = _parse_ffmpeg_version(version)
|
|
1239
|
+
if v is None:
|
|
1240
|
+
return None
|
|
1241
|
+
hits = []
|
|
1242
|
+
branch = f"{v[0]}.{v[1]}"
|
|
1243
|
+
for adv in FFMPEG_ADVISORIES:
|
|
1244
|
+
fixes = {k: _parse_ffmpeg_version(f) for k, f in adv["fixed_in"].items()}
|
|
1245
|
+
if branch in fixes:
|
|
1246
|
+
first, on_branch = fixes[branch], True
|
|
1247
|
+
else:
|
|
1248
|
+
first, on_branch = min(fixes.values()), False
|
|
1249
|
+
if v < first:
|
|
1250
|
+
hits.append({"cve": adv["cve"], "name": adv["name"], "component": adv["component"], "kind": adv["kind"],
|
|
1251
|
+
"cvss": adv["cvss"], "first_fix": _vstr(first), "fix_on_branch": on_branch, "branch": branch})
|
|
1252
|
+
return hits
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
def _update_hint(version: str, source: Optional[str]) -> str:
|
|
1256
|
+
"""How to update the FFmpeg this version string came from, as one short phrase."""
|
|
1257
|
+
low = version.lower()
|
|
1258
|
+
if "ubuntu" in low or "+deb" in low or "debian" in low:
|
|
1259
|
+
return "sudo apt update && sudo apt install --only-upgrade ffmpeg"
|
|
1260
|
+
system = platform.system()
|
|
1261
|
+
if system == "Darwin":
|
|
1262
|
+
return "brew upgrade ffmpeg-full" if source == "homebrew-ffmpeg-full" else "brew upgrade ffmpeg, or the package manager it came from"
|
|
1263
|
+
if system == "Windows":
|
|
1264
|
+
return "winget upgrade Gyan.FFmpeg, or a newer build from https://ffmpeg.org/download.html"
|
|
1265
|
+
if system == "Linux":
|
|
1266
|
+
return "your distribution's package update, e.g. sudo apt install --only-upgrade ffmpeg or sudo dnf upgrade ffmpeg"
|
|
1267
|
+
return "a newer build from https://ffmpeg.org/download.html"
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
def _advisory_warning(binary: str, version: str, hits: List[Dict[str, Any]], source: Optional[str]) -> str:
|
|
1271
|
+
"""One stderr/`warnings` line. It never says the build IS vulnerable: a distro package
|
|
1272
|
+
(Ubuntu `8.0.1-3ubuntu2`, Debian `+deb13u1`) backports fixes without changing the upstream
|
|
1273
|
+
number, and only the upstream number is visible here."""
|
|
1274
|
+
parts = []
|
|
1275
|
+
for h in hits:
|
|
1276
|
+
where = (f"first fixed on the {h['branch']} branch in {h['first_fix']}" if h["fix_on_branch"]
|
|
1277
|
+
else f"no {h['branch']} release is listed with the fix; the oldest that has it is {h['first_fix']}")
|
|
1278
|
+
parts.append(f"{h['cve']} ({h['component']} {h['kind']}, CVSS {h['cvss']:g}; {where})")
|
|
1279
|
+
return (f"warning: {binary} {version} is older than the first upstream FFmpeg release that fixes "
|
|
1280
|
+
f"{'; '.join(parts)}. A distribution package may have backported the fix without changing the "
|
|
1281
|
+
f"upstream version, so this is not proof the build is vulnerable: update it "
|
|
1282
|
+
f"({_update_hint(version, source)}). Source: {FFMPEG_ADVISORY_SOURCE}, checked {FFMPEG_ADVISORIES_CHECKED}.")
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
def ffmpeg_security(versions: Dict[str, Optional[str]], sources: Optional[Dict[str, Optional[str]]] = None) -> Dict[str, Any]:
|
|
1286
|
+
"""doctor's `ffmpeg_security`: per binary {version, status, advisories}, and `warnings`, one line
|
|
1287
|
+
per distinct version that is older than a fix. `status`: `older_than_fix`, `not_older`, or
|
|
1288
|
+
`unknown` (no binary, or a version this table cannot compare -- which produces no warning).
|
|
1289
|
+
Informational like `fonts`/`gpu_encoders`: it never moves `ok`, a tool's `usable` or the exit code."""
|
|
1290
|
+
sources = sources or {}
|
|
1291
|
+
out: Dict[str, Any] = {"source": FFMPEG_ADVISORY_SOURCE, "checked": FFMPEG_ADVISORIES_CHECKED, "warnings": []}
|
|
1292
|
+
warned = set()
|
|
1293
|
+
for binary in ("ffmpeg", "ffprobe"):
|
|
1294
|
+
version = versions.get(binary)
|
|
1295
|
+
hits = _advisory_hits(version)
|
|
1296
|
+
status = "unknown" if hits is None else ("older_than_fix" if hits else "not_older")
|
|
1297
|
+
out[binary] = {"version": version, "status": status, "advisories": hits or []}
|
|
1298
|
+
if hits and version not in warned:
|
|
1299
|
+
warned.add(version)
|
|
1300
|
+
out["warnings"].append(_advisory_warning(binary, str(version), hits, sources.get(binary)))
|
|
1301
|
+
return out
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
# 3.0.0 removed Python 3.9 (deprecated in 2.10.9) and FFmpeg 5.x (deprecated in 2.14.0): REMOVED
|
|
1305
|
+
# below. doctor reports a floor it is below in `unsupported` and as `ok: false`; bin/install.js
|
|
1306
|
+
# refuses Python below 3.10 and prints the same FFmpeg line (a test keeps the lines equal); every
|
|
1307
|
+
# tool refuses an FFmpeg it can read as older than 6.1 (runner.require_tool).
|
|
1308
|
+
MIN_PYTHON = (3, 10)
|
|
1309
|
+
MIN_FFMPEG = (6, 1)
|
|
1310
|
+
PYTHON_UNSUPPORTED = ("error: Python {v} is not supported since ffmpeg-skill 3.0.0 (3.9 was deprecated in 2.10.9; "
|
|
1311
|
+
"CPython 3.9 is end of life): use Python 3.10+.")
|
|
1312
|
+
FFMPEG_UNSUPPORTED = ("error: FFmpeg {v} is not supported since ffmpeg-skill 3.0.0 (5.x was deprecated in 2.14.0): "
|
|
1313
|
+
"use FFmpeg 6.1+.")
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
def python_unsupported(version_info: Optional[tuple] = None) -> Optional[str]:
|
|
1317
|
+
"""The unsupported-interpreter line for this Python, or None when it is 3.10 or later."""
|
|
1318
|
+
vi = tuple(version_info if version_info is not None else sys.version_info)[:2]
|
|
1319
|
+
return PYTHON_UNSUPPORTED.format(v=f"{vi[0]}.{vi[1]}") if vi < MIN_PYTHON else None
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
def ffmpeg_unsupported(version: Optional[str]) -> Optional[str]:
|
|
1323
|
+
"""The unsupported-FFmpeg line for this version token, or None (6.1 or later, or not a release
|
|
1324
|
+
number: a git snapshot is not refused, as with the security advisory)."""
|
|
1325
|
+
v = _parse_ffmpeg_version(version)
|
|
1326
|
+
return FFMPEG_UNSUPPORTED.format(v=f"{v[0]}.{v[1]}") if v and tuple(v[:2]) < MIN_FFMPEG else None
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
def _exe_report() -> Dict[str, Any]:
|
|
1330
|
+
"""`ffmpeg_path` / `ffmpeg_source` / `ffprobe_path` / `ffprobe_source`: which binary the tools run
|
|
1331
|
+
and why ("path": what PATH resolves; "homebrew-ffmpeg-full": macOS, a lean Homebrew ffmpeg on
|
|
1332
|
+
PATH replaced by the keg-only ffmpeg-full of the same prefix, #317). None when not on PATH."""
|
|
1333
|
+
from _common.runner import ffmpeg_exe
|
|
1334
|
+
out: Dict[str, Any] = {}
|
|
1335
|
+
for name in ("ffmpeg", "ffprobe"):
|
|
1336
|
+
path, source = ffmpeg_exe(name)
|
|
1337
|
+
out[f"{name}_path"] = path or None
|
|
1338
|
+
out[f"{name}_source"] = source or None
|
|
1339
|
+
return out
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
def _speech_startup_error(command: List[str]) -> Optional[str]:
|
|
1343
|
+
from _common.emit import shown
|
|
1344
|
+
|
|
1345
|
+
try:
|
|
1346
|
+
proc = subprocess.run(command, cwd=HERE, capture_output=True, encoding="utf-8",
|
|
1347
|
+
errors="replace", timeout=_DETECT_TIMEOUT)
|
|
1348
|
+
except subprocess.TimeoutExpired:
|
|
1349
|
+
return f"startup check timed out after {_DETECT_TIMEOUT} seconds"
|
|
1350
|
+
except OSError as exc:
|
|
1351
|
+
return f"startup check failed: {shown(exc)}"
|
|
1352
|
+
if proc.returncode == 0:
|
|
1353
|
+
return None
|
|
1354
|
+
lines = (proc.stderr.strip() or proc.stdout.strip()).splitlines()
|
|
1355
|
+
return shown(lines[-1][:300]) if lines else f"startup check exited {proc.returncode}"
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
def _speech_package_version(name: str) -> Optional[str]:
|
|
1359
|
+
try:
|
|
1360
|
+
return importlib.metadata.version(name)
|
|
1361
|
+
except (importlib.metadata.PackageNotFoundError, KeyError, OSError, UnicodeError):
|
|
1362
|
+
return None
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
def _whisper_engines() -> Dict[str, Dict[str, Any]]:
|
|
1366
|
+
"""Check the entry points transcription uses, without opening media or loading models."""
|
|
1367
|
+
from _common.asr import _whisper_cpp_cli
|
|
1368
|
+
from _common.runner import SafeShutil, safe_which
|
|
1369
|
+
|
|
1370
|
+
engines: Dict[str, Dict[str, Any]] = {}
|
|
1371
|
+
cpp = _whisper_cpp_cli(SafeShutil(shutil))
|
|
1372
|
+
if cpp:
|
|
1373
|
+
error = _speech_startup_error([str(Path(cpp).absolute()), "--help"])
|
|
1374
|
+
engines["whisper.cpp"] = {"usable": error is None, "checked": "cli_startup"}
|
|
1375
|
+
if error:
|
|
1376
|
+
engines["whisper.cpp"].update(
|
|
1377
|
+
detail=error, hint="Check the installation and shared libraries of the whisper.cpp command.",
|
|
1378
|
+
)
|
|
1379
|
+
if importlib.util.find_spec("faster_whisper") is not None:
|
|
1380
|
+
error = _speech_startup_error([sys.executable, "-c", "from faster_whisper import WhisperModel"])
|
|
1381
|
+
engines["faster-whisper"] = {"usable": error is None, "checked": "import",
|
|
1382
|
+
"av_version": _speech_package_version("av")}
|
|
1383
|
+
if error:
|
|
1384
|
+
engines["faster-whisper"].update(
|
|
1385
|
+
detail=error,
|
|
1386
|
+
hint="Check that faster-whisper and PyAV are compatible in the Python environment running doctor.",
|
|
1387
|
+
)
|
|
1388
|
+
whisper = safe_which("whisper")
|
|
1389
|
+
if whisper:
|
|
1390
|
+
# The startup check changes cwd. Resolve a relative PATH entry against the caller's cwd.
|
|
1391
|
+
error = _speech_startup_error([str(Path(whisper).absolute()), "--help"])
|
|
1392
|
+
engines["openai-whisper"] = {"usable": error is None, "checked": "cli_startup"}
|
|
1393
|
+
if error:
|
|
1394
|
+
engines["openai-whisper"].update(
|
|
1395
|
+
detail=error, hint="Check the openai-whisper installation in the environment that provides the whisper command.",
|
|
1396
|
+
)
|
|
1397
|
+
elif _speech_package_version("openai-whisper") is not None:
|
|
1398
|
+
engines["openai-whisper"] = {
|
|
1399
|
+
"usable": False, "detail": "whisper command not found on PATH",
|
|
1400
|
+
"hint": "Make the openai-whisper command available on PATH.",
|
|
1401
|
+
}
|
|
1402
|
+
return engines
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
def _parakeet_available() -> bool:
|
|
1406
|
+
"""parakeet-mlx on PATH, or parakeet-cli with a model it can find (PARAKEET_CPP_MODEL or a
|
|
1407
|
+
.gguf in ~/.cache/parakeet.cpp) -- the same test the speech bridge applies before running it."""
|
|
1408
|
+
from _common.asr import _parakeet_available as runtime_check # the bridge's own test, not a copy of it
|
|
1409
|
+
from _common.runner import SafeShutil
|
|
1410
|
+
return any(runtime_check(e, SafeShutil(shutil)) for e in ("parakeet-mlx", "parakeet.cpp"))
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
def _hw_default() -> Dict[str, Any]:
|
|
1414
|
+
"""--hw's machine facts, normalised (never the raw environment value): whether VideoToolbox
|
|
1415
|
+
constant-quality encoding can run here (the tools' own check: Apple Silicon hardware, also
|
|
1416
|
+
under a Rosetta Python), and whether $FFMPEG_SKILL_HW makes it the default."""
|
|
1417
|
+
from _common.runner import env_hw, hw_platform_reason
|
|
1418
|
+
return {"platform_ok": hw_platform_reason() is None, "default_on": env_hw()}
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
def _default_font() -> str:
|
|
1422
|
+
from _common import BRAND_DEFAULTS
|
|
1423
|
+
return str(BRAND_DEFAULTS["font"])
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
def _drawtext_probe() -> Dict[str, Any]:
|
|
1427
|
+
"""Actually render one frame through drawtext, rather than trusting `-filters` alone.
|
|
1428
|
+
|
|
1429
|
+
`-filters` only reports whether this ffmpeg build was compiled with the filter; it never
|
|
1430
|
+
proves drawtext can actually execute. On some real Windows ffmpeg builds (winget's gyan.dev
|
|
1431
|
+
9.x), drawtext crashes with an access violation whenever it has to resolve a font through
|
|
1432
|
+
fontconfig -- with or without a valid fonts.conf -- so `-filters` correctly reports drawtext
|
|
1433
|
+
present and doctor used to report the capability `available` anyway; every tool that actually
|
|
1434
|
+
used it (look, scenes --sheet, overlay --text, graphics) then crashed on first real use (#100).
|
|
1435
|
+
|
|
1436
|
+
This runs the cheapest real drawtext render there is: a one-frame synthetic clip, with the
|
|
1437
|
+
fontfile= the tools themselves pass by default (_common.fonts.default_font_file), or no font
|
|
1438
|
+
at all where none resolves. A clean exit means drawtext genuinely works for the tools here.
|
|
1439
|
+
Anything that could not prove either way (no ffmpeg, timeout, an ordinary nonzero exit with a
|
|
1440
|
+
real ffmpeg error) is `unknown`, same "unknown is not missing" principle as every other
|
|
1441
|
+
capability here. A crash specifically -- killed by signal on POSIX, or an unhandled access
|
|
1442
|
+
violation surfacing as a huge unsigned exit code on Windows -- folds into `missing`. When the
|
|
1443
|
+
fontfile= render works but a bare one crashes, drawtext stays available and the result
|
|
1444
|
+
carries a `note`: only a fontconfig lookup (`--font <family>` with no file) would crash.
|
|
1445
|
+
"""
|
|
1446
|
+
exe = _exe("ffmpeg")
|
|
1447
|
+
if not exe:
|
|
1448
|
+
return {"status": "unknown", "detail": "ffmpeg not on PATH"}
|
|
1449
|
+
# Probe the way the tools call drawtext: with the fontfile= they pick by default (#298). On a
|
|
1450
|
+
# build whose fontconfig lookup crashes (#100) the tools still render, because they never ask
|
|
1451
|
+
# fontconfig; probing only the bare `drawtext=text=x` reported such a machine as missing
|
|
1452
|
+
# drawtext altogether. The bare render still runs, and its crash is reported as a note: it is
|
|
1453
|
+
# the path `--font <family>` without a file would take.
|
|
1454
|
+
from _common.fonts import default_font_file
|
|
1455
|
+
from _common.decision import escape_filter_path
|
|
1456
|
+
font_file = default_font_file(_default_font())
|
|
1457
|
+
result = _drawtext_render(exe, f"drawtext=fontfile={escape_filter_path(font_file)}:text=x" if font_file else "drawtext=text=x")
|
|
1458
|
+
if font_file and result["status"] == "available":
|
|
1459
|
+
bare = _drawtext_render(exe, "drawtext=text=x")
|
|
1460
|
+
if bare["status"] == "missing":
|
|
1461
|
+
result["note"] = ("drawtext renders with fontfile= (what every drawtext tool passes by default) but crashes "
|
|
1462
|
+
"when it has to resolve a font through fontconfig: pass --font-file, not a bare --font "
|
|
1463
|
+
"<family>, on this machine (https://github.com/kajisho5/ffmpeg-skill/issues/100)")
|
|
1464
|
+
return result
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
def _drawtext_render(exe: str, vf: str) -> Dict[str, Any]:
|
|
1468
|
+
try:
|
|
1469
|
+
proc = subprocess.run(
|
|
1470
|
+
[exe, "-hide_banner", "-loglevel", "error", "-f", "lavfi", "-i", "color=c=black:s=64x64:d=1",
|
|
1471
|
+
"-vf", vf, "-frames:v", "1", "-f", "null", "-"],
|
|
1472
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8", errors="replace", timeout=_DETECT_TIMEOUT,
|
|
1473
|
+
)
|
|
1474
|
+
except subprocess.TimeoutExpired:
|
|
1475
|
+
return {"status": "unknown", "detail": f"drawtext probe did not exit within {_DETECT_TIMEOUT}s"}
|
|
1476
|
+
except OSError as e:
|
|
1477
|
+
return {"status": "unknown", "detail": f"drawtext probe: {e}"}
|
|
1478
|
+
if proc.returncode == 0:
|
|
1479
|
+
return {"status": "available", "detail": "one-frame drawtext render succeeded"}
|
|
1480
|
+
if proc.returncode < 0 or proc.returncode >= 0x80000000:
|
|
1481
|
+
return {"status": "missing",
|
|
1482
|
+
"detail": f"drawtext render crashed (exit {proc.returncode}) instead of failing cleanly -- "
|
|
1483
|
+
"the filter is present in this build but cannot render even with the fontfile= the "
|
|
1484
|
+
"tools pass (see https://github.com/kajisho5/ffmpeg-skill/issues/100)"}
|
|
1485
|
+
tail = " ".join(proc.stderr.strip().splitlines()[-2:])
|
|
1486
|
+
return {"status": "unknown", "detail": f"drawtext probe exited {proc.returncode}: {tail}"}
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
def _font_available(font_name: str) -> Dict[str, Any]:
|
|
1490
|
+
"""Whether `font_name` (a fontconfig family name, as passed to drawtext's `font=`) is actually
|
|
1491
|
+
installed, distinct from silently resolving to a substitute.
|
|
1492
|
+
|
|
1493
|
+
This cannot be answered by running drawtext and checking its exit code: fontconfig substitutes
|
|
1494
|
+
the closest match for ANY name, known or not, so `ffmpeg -vf drawtext=font='<garbage>'` still
|
|
1495
|
+
exits 0 (verified against this repo's own sandbox ffmpeg -- a deliberately bogus family name
|
|
1496
|
+
produces the same success exit code as "DejaVu Sans"). That is exactly the "false success" this
|
|
1497
|
+
capability exists to catch (see issue #66): a missing font never fails the encode, it just
|
|
1498
|
+
silently renders with a different typeface. `fc-match` is queried instead, since it reports the
|
|
1499
|
+
family fontconfig actually resolved to; that only equals the request when the font is installed.
|
|
1500
|
+
"""
|
|
1501
|
+
from _common.runner import safe_which
|
|
1502
|
+
exe = safe_which("fc-match")
|
|
1503
|
+
if not exe:
|
|
1504
|
+
return {"status": "unknown", "detail": "fc-match not on PATH; drawtext succeeding proves nothing (fontconfig substitutes silently), so availability cannot be verified"}
|
|
1505
|
+
try:
|
|
1506
|
+
proc = subprocess.run([exe, "--format=%{family}\n", font_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8", errors="replace", timeout=_DETECT_TIMEOUT)
|
|
1507
|
+
except subprocess.TimeoutExpired:
|
|
1508
|
+
return {"status": "unknown", "detail": f"fc-match did not exit within {_DETECT_TIMEOUT}s"}
|
|
1509
|
+
except OSError as e:
|
|
1510
|
+
return {"status": "unknown", "detail": f"fc-match: {e}"}
|
|
1511
|
+
if proc.returncode != 0:
|
|
1512
|
+
tail = " ".join(proc.stderr.strip().splitlines()[-2:])
|
|
1513
|
+
return {"status": "unknown", "detail": f"fc-match exited {proc.returncode}: {tail}"}
|
|
1514
|
+
lines = [l for l in proc.stdout.splitlines() if l.strip()]
|
|
1515
|
+
resolved = lines[0].strip() if lines else ""
|
|
1516
|
+
if not resolved:
|
|
1517
|
+
return {"status": "unknown", "detail": "fc-match produced no output"}
|
|
1518
|
+
if resolved.lower() == font_name.lower():
|
|
1519
|
+
return {"status": "available", "detail": f"fc-match resolves '{font_name}' to itself"}
|
|
1520
|
+
return {"status": "missing", "detail": f"fc-match substitutes '{resolved}' for '{font_name}' -- '{font_name}' is not installed"}
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
def required_capabilities() -> Dict[str, List[str]]:
|
|
1524
|
+
req: set = set()
|
|
1525
|
+
opt: set = set()
|
|
1526
|
+
for meta in TOOL_META.values():
|
|
1527
|
+
req.update(meta["required"])
|
|
1528
|
+
opt.update(o["capability"] for o in meta["optional"] if o["capability"] != "delegated")
|
|
1529
|
+
opt.update(o["capability"] for o in CODEC_CAPS)
|
|
1530
|
+
opt.update(o["capability"] for o in ALPHA_LINE_OPTIONAL)
|
|
1531
|
+
opt -= req
|
|
1532
|
+
return {"required": sorted(req), "optional": sorted(opt)}
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
def doctor() -> Dict[str, Any]:
|
|
1536
|
+
"""Detect which declared capabilities this machine has. No secrets, no environment variables.
|
|
1537
|
+
|
|
1538
|
+
`version` is this INSTALLED COPY's own version (read from its local package.json, same value
|
|
1539
|
+
`contract --json`'s `skill.version` reports) -- never fetched from the network or compared
|
|
1540
|
+
against the latest published release. A copy installed with `npx ffmpeg-skill` is not updated
|
|
1541
|
+
automatically; re-run the installer to refresh it, then `doctor` again to confirm the version
|
|
1542
|
+
changed. This exists so a stale installed copy is visible locally, not to check for updates.
|
|
1543
|
+
|
|
1544
|
+
Three states per capability: available, missing, unknown. `unknown` means the ffmpeg listing
|
|
1545
|
+
that would prove it could not be read (unparsed output, ffmpeg failure); it is never folded into
|
|
1546
|
+
`missing` (a filter that exists is not reported absent) nor into `available` (a failed detection
|
|
1547
|
+
is not a pass). `ok` is true only when nothing required is missing or unknown.
|
|
1548
|
+
|
|
1549
|
+
One exception to "missing blocks": `encoder:libx264` / `encoder:libx265` absent from the build
|
|
1550
|
+
while the matching VideoToolbox encoder is present and this machine can run it (Apple Silicon).
|
|
1551
|
+
The tools use VideoToolbox there without --hw (#314), so the capability is neither `available`
|
|
1552
|
+
(it is not in the build) nor `missing` (nothing is blocked): it is left out of both lists, named
|
|
1553
|
+
in `covered_by`, and a tool that needs it stays usable. A build that has libx264 reports exactly
|
|
1554
|
+
what it did before.
|
|
1555
|
+
|
|
1556
|
+
`gpu_encoders` is a separate, honest answer to a question none of the required/optional
|
|
1557
|
+
capabilities above ask: which GPU-backed encoders (nvenc, videotoolbox, qsv, vaapi, amf) this
|
|
1558
|
+
ffmpeg BUILD carries, from `-encoders` alone. No tool requires one -- every tool runs on CPU
|
|
1559
|
+
x264/x265 unless `--hw` / FFMPEG_SKILL_HW=1 puts it on VideoToolbox (Apple Silicon only) -- so
|
|
1560
|
+
`gpu_encoders` never affects `ok` or any tool's `usable` (`covered_by` is the one place a
|
|
1561
|
+
VideoToolbox encoder counts: for a libx264/libx265 the build lacks, see above). It
|
|
1562
|
+
only proves the build shipped the capability, never that the GPU/driver on this machine will
|
|
1563
|
+
actually accept a job (that needs a real encode, which this introspection never runs).
|
|
1564
|
+
|
|
1565
|
+
`fonts` is the same kind of informational answer for the default drawtext font (caption.py's
|
|
1566
|
+
--animate/--karaoke, graphics.py's templates -- see issue #66): available/missing/unknown for
|
|
1567
|
+
whether BRAND_DEFAULTS["font"] ("DejaVu Sans") is actually installed, not silently substituted
|
|
1568
|
+
by fontconfig. It never affects `ok` or a tool's `usable` -- a missing font is not a broken
|
|
1569
|
+
tool, drawtext still runs and still writes an artifact, it may just render with a different
|
|
1570
|
+
typeface than requested (which is why this exists: that substitution is otherwise invisible).
|
|
1571
|
+
"""
|
|
1572
|
+
listings = {
|
|
1573
|
+
"encoders": _ff_listing("ffmpeg", "-encoders"),
|
|
1574
|
+
"filters": _ff_listing("ffmpeg", "-filters"),
|
|
1575
|
+
"bsfs": _ff_listing("ffmpeg", "-bsfs"),
|
|
1576
|
+
"decoders": _ff_listing("ffmpeg", "-decoders"),
|
|
1577
|
+
}
|
|
1578
|
+
sets = {k: set(v["names"]) for k, v in listings.items()}
|
|
1579
|
+
state: Dict[str, str] = {} # capability -> available | missing | unknown
|
|
1580
|
+
wanted = required_capabilities()
|
|
1581
|
+
covered = _covered_by_videotoolbox(listings["encoders"])
|
|
1582
|
+
drawtext_probe: Optional[Dict[str, Any]] = None
|
|
1583
|
+
drawtext_crashed = False # listed but crashed (#100), as opposed to absent from the build
|
|
1584
|
+
speech_engines = _whisper_engines()
|
|
1585
|
+
|
|
1586
|
+
def _from(kind: str, name: str) -> str:
|
|
1587
|
+
lst = listings[kind]
|
|
1588
|
+
if lst["status"] == "parsed":
|
|
1589
|
+
return "available" if name in sets[kind] else "missing"
|
|
1590
|
+
if lst["status"] == "missing":
|
|
1591
|
+
return "missing" # no ffmpeg at all: nothing it provides is available
|
|
1592
|
+
return "unknown"
|
|
1593
|
+
|
|
1594
|
+
for cap in wanted["required"] + wanted["optional"]:
|
|
1595
|
+
if cap == "ffmpeg":
|
|
1596
|
+
state[cap] = "available" if _exe("ffmpeg") else "missing"
|
|
1597
|
+
elif cap == "ffprobe":
|
|
1598
|
+
state[cap] = "available" if _exe("ffprobe") else "missing"
|
|
1599
|
+
elif cap.startswith("encoder:"):
|
|
1600
|
+
state[cap] = _from("encoders", cap[8:])
|
|
1601
|
+
elif cap.startswith("decoder:"):
|
|
1602
|
+
state[cap] = _from("decoders", cap[8:])
|
|
1603
|
+
elif cap == "filter:drawtext":
|
|
1604
|
+
listing_state = _from("filters", "drawtext")
|
|
1605
|
+
if listing_state == "available":
|
|
1606
|
+
# Only escalate an "available" listing to "missing" on an unambiguous crash --
|
|
1607
|
+
# an ordinary nonzero exit (a real ffmpeg's own -h/-filters-only build variance, or
|
|
1608
|
+
# in tests a fake ffmpeg shim that only implements -filters/-encoders/-bsfs/-version)
|
|
1609
|
+
# proves nothing either way, so it leaves the listing-based result standing rather
|
|
1610
|
+
# than downgrading it; see _drawtext_probe()'s own docstring for why a crash alone
|
|
1611
|
+
# is the one case this exists to catch.
|
|
1612
|
+
probe = _drawtext_probe()
|
|
1613
|
+
if probe.get("note"):
|
|
1614
|
+
drawtext_probe = probe
|
|
1615
|
+
if probe["status"] == "missing":
|
|
1616
|
+
drawtext_probe = probe
|
|
1617
|
+
drawtext_crashed = True
|
|
1618
|
+
state[cap] = "missing"
|
|
1619
|
+
else:
|
|
1620
|
+
state[cap] = "available"
|
|
1621
|
+
else:
|
|
1622
|
+
state[cap] = listing_state
|
|
1623
|
+
elif cap.startswith("filter:"):
|
|
1624
|
+
state[cap] = _from("filters", cap[7:])
|
|
1625
|
+
elif cap.startswith("bsf:"):
|
|
1626
|
+
state[cap] = _from("bsfs", cap[4:])
|
|
1627
|
+
elif cap == "external:whisper":
|
|
1628
|
+
state[cap] = "available" if any(engine["usable"] for engine in speech_engines.values()) else "missing"
|
|
1629
|
+
elif cap == "external:parakeet":
|
|
1630
|
+
state[cap] = "available" if _parakeet_available() else "missing"
|
|
1631
|
+
else:
|
|
1632
|
+
state[cap] = "missing"
|
|
1633
|
+
available = sorted(c for c, st in state.items() if st == "available")
|
|
1634
|
+
missing_required = sorted(c for c in wanted["required"] if state[c] == "missing" and c not in covered)
|
|
1635
|
+
missing_optional = sorted(c for c in wanted["optional"] if state[c] == "missing" and c not in covered)
|
|
1636
|
+
unknown = sorted(c for c, st in state.items() if st == "unknown")
|
|
1637
|
+
unknown_required = [c for c in unknown if c in wanted["required"]]
|
|
1638
|
+
errors = [f"{k}: {v['detail']}" for k, v in listings.items() if v["status"] in ("unparsed", "failed")]
|
|
1639
|
+
if drawtext_probe is not None and drawtext_probe["status"] != "available":
|
|
1640
|
+
errors.append(f"filter:drawtext: {drawtext_probe['detail']}")
|
|
1641
|
+
notes = [f"filter:drawtext: {drawtext_probe['note']}"] if drawtext_probe and drawtext_probe.get("note") else []
|
|
1642
|
+
notes += [f"{cap}: not in this ffmpeg build; the tools that need it encode with {alt[8:]} (VideoToolbox) instead, so their output is "
|
|
1643
|
+
"not CRF-equivalent (the result's `encoder`/`hw` say so)" for cap, alt in sorted(covered.items())]
|
|
1644
|
+
versions = {"ffmpeg": _version_line("ffmpeg"), "ffprobe": _version_line("ffprobe")}
|
|
1645
|
+
exes = _exe_report()
|
|
1646
|
+
# 3.0.0: below the requirements floor is a broken install, not an advisory
|
|
1647
|
+
unsupported = [line for line in (python_unsupported(), ffmpeg_unsupported(versions["ffmpeg"])) if line]
|
|
1648
|
+
probe_line = ffmpeg_unsupported(versions["ffprobe"])
|
|
1649
|
+
if probe_line:
|
|
1650
|
+
probe_line = probe_line.replace("error: FFmpeg ", "error: ffprobe ", 1)
|
|
1651
|
+
if probe_line not in unsupported:
|
|
1652
|
+
unsupported.append(probe_line)
|
|
1653
|
+
return {
|
|
1654
|
+
"version": skill_version(),
|
|
1655
|
+
"python": ".".join(str(x) for x in sys.version_info[:3]),
|
|
1656
|
+
"ffmpeg": versions["ffmpeg"],
|
|
1657
|
+
"ffprobe": versions["ffprobe"],
|
|
1658
|
+
**exes,
|
|
1659
|
+
"ffmpeg_license": _ffmpeg_license(exes.get("ffmpeg_path")),
|
|
1660
|
+
# non-fatal: never part of `ok`, `usable` or the exit code
|
|
1661
|
+
"ffmpeg_security": ffmpeg_security(versions, {b: exes.get(f"{b}_source") for b in versions}),
|
|
1662
|
+
"available": available,
|
|
1663
|
+
"missing": missing_required,
|
|
1664
|
+
"missing_optional": missing_optional,
|
|
1665
|
+
"unknown": unknown,
|
|
1666
|
+
"detection": {k: {"status": v["status"], "count": len(v["names"]), "detail": v["detail"]} for k, v in listings.items()},
|
|
1667
|
+
"errors": errors,
|
|
1668
|
+
**({"notes": notes} if notes else {}),
|
|
1669
|
+
"unsupported": unsupported,
|
|
1670
|
+
"ok": not missing_required and not unknown_required and not unsupported,
|
|
1671
|
+
"tools": _tool_usability(state, drawtext_crashed, covered, unsupported),
|
|
1672
|
+
"covered_by": covered,
|
|
1673
|
+
"gpu_encoders": _gpu_encoders(listings["encoders"]),
|
|
1674
|
+
"hw": _hw_default(),
|
|
1675
|
+
"fonts": _fonts_capability(probe=True),
|
|
1676
|
+
"speech_engines": speech_engines,
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
def _fonts_capability(probe: bool = True) -> Dict[str, Any]:
|
|
1681
|
+
"""The default drawtext family (issue #66) plus, since 1.12, one entry per script the tools
|
|
1682
|
+
can detect: which languages this machine can actually RENDER, not just which filters exist.
|
|
1683
|
+
|
|
1684
|
+
Per script: available (a font file covers it, path in `file`), missing (fontconfig knows none),
|
|
1685
|
+
unknown (no fontconfig to ask -- the same "unknown is not missing" rule every other capability
|
|
1686
|
+
here follows). Informational like the default font and gpu_encoders: a machine with no Thai
|
|
1687
|
+
font is not a broken install, it is a machine that must not be asked to burn Thai captions.
|
|
1688
|
+
"""
|
|
1689
|
+
from _common import SCRIPTS, font_for_script, script_font_status, emoji_support
|
|
1690
|
+
|
|
1691
|
+
font = _default_font()
|
|
1692
|
+
result = _font_available(font)
|
|
1693
|
+
scripts: Dict[str, Any] = {}
|
|
1694
|
+
for script in SCRIPTS:
|
|
1695
|
+
if script == "latin":
|
|
1696
|
+
continue
|
|
1697
|
+
# script_font_status() is the one place that tells "fontconfig answered, nothing covers
|
|
1698
|
+
# this" (missing) apart from "there is no working fontconfig to ask" (unknown) -- the same
|
|
1699
|
+
# distinction the tools refuse or continue on.
|
|
1700
|
+
status = script_font_status(script)
|
|
1701
|
+
scripts[script] = {"status": status, "file": font_for_script(script) if status == "available" else None}
|
|
1702
|
+
# 1.15: emoji are a separate question from the writing system, and the only honest answer is a
|
|
1703
|
+
# render (an installed colour emoji font proves nothing -- libass on this build may still draw
|
|
1704
|
+
# it monochrome). `probe=False` -- `contract --json --static`, and every static/JSON-only path -- skips
|
|
1705
|
+
# that render, exactly as it skips the rest of the environment detection.
|
|
1706
|
+
return {"default_font": font, "status": result["status"], "detail": result["detail"],
|
|
1707
|
+
"scripts": scripts, "emoji": emoji_support(probe=probe)}
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
def _fonts_summary_line(fonts: Dict[str, Any]) -> str:
|
|
1711
|
+
"""One line for the plain-text doctor: which scripts render here, which do not."""
|
|
1712
|
+
scripts = fonts.get("scripts") or {}
|
|
1713
|
+
by_state: Dict[str, List[str]] = {"available": [], "missing": [], "unknown": []}
|
|
1714
|
+
for name, entry in scripts.items():
|
|
1715
|
+
by_state.setdefault(entry["status"], []).append(name)
|
|
1716
|
+
# the default font's `detail` (which family fontconfig substituted, or why it is unknown) is
|
|
1717
|
+
# the actionable half of a non-available status, and the line has room for it
|
|
1718
|
+
head = f"fonts: '{fonts['default_font']}' {fonts['status']}"
|
|
1719
|
+
detail = fonts.get("detail") or ""
|
|
1720
|
+
# The substituted family is the actionable half of a non-available status, so it goes on the
|
|
1721
|
+
# plain line -- but only while it stays short enough to keep doctor's one-line-per-capability
|
|
1722
|
+
# shape (the longest other line is ~85 chars). A long explanation is --json only.
|
|
1723
|
+
if detail and fonts["status"] != "available" and len(detail) <= 60:
|
|
1724
|
+
head += f" ({detail})"
|
|
1725
|
+
parts = [head]
|
|
1726
|
+
if by_state["available"]:
|
|
1727
|
+
parts.append("renders " + " ".join(by_state["available"]))
|
|
1728
|
+
if by_state["missing"]:
|
|
1729
|
+
parts.append("no font for " + " ".join(by_state["missing"]))
|
|
1730
|
+
if by_state["unknown"]:
|
|
1731
|
+
parts.append("unknown (no fontconfig) " + " ".join(by_state["unknown"]))
|
|
1732
|
+
emoji = fonts.get("emoji") or {}
|
|
1733
|
+
mode = emoji.get("mode")
|
|
1734
|
+
if mode == "color":
|
|
1735
|
+
parts.append("emoji colour")
|
|
1736
|
+
elif mode == "png":
|
|
1737
|
+
parts.append("emoji colour (assets)")
|
|
1738
|
+
elif mode == "mono":
|
|
1739
|
+
parts.append("emoji monochrome -- --emoji-assets DIR for colour")
|
|
1740
|
+
elif mode:
|
|
1741
|
+
parts.append("emoji none")
|
|
1742
|
+
return "; ".join(parts)
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
def _capability_fix_hint(cap: str, drawtext_crashed: bool = False) -> str:
|
|
1746
|
+
"""One-line, plain-language remedy for a single missing/unknown capability."""
|
|
1747
|
+
if cap in ("ffmpeg", "ffprobe"):
|
|
1748
|
+
from _common import INSTALL_HINTS
|
|
1749
|
+
hint = INSTALL_HINTS.get(platform.system(), "see https://ffmpeg.org/download.html").strip().splitlines()[0].strip()
|
|
1750
|
+
# a hint's "# why" is a shell comment so the printed line pastes; joined into a fix string
|
|
1751
|
+
# with "; " it would swallow what follows, so show it in parentheses here instead
|
|
1752
|
+
cmd, _, why = hint.partition("#")
|
|
1753
|
+
return f"install ffmpeg: {cmd.strip()} ({why.strip()})" if why else f"install ffmpeg: {hint}"
|
|
1754
|
+
system = platform.system()
|
|
1755
|
+
if system == "Darwin":
|
|
1756
|
+
full_hint = ("on macOS, brew install ffmpeg-full; export PATH=\"$(brew --prefix ffmpeg-full)/bin:$PATH\" "
|
|
1757
|
+
"(ffmpeg-full is keg-only, so installing it does not replace the ffmpeg already found: keep the "
|
|
1758
|
+
"export in your shell profile; the plain formula lacks subtitles/drawtext/zscale)")
|
|
1759
|
+
elif system == "Windows":
|
|
1760
|
+
full_hint = "on Windows, winget install Gyan.FFmpeg (the gyan.dev full build carries subtitles/drawtext/zscale; a plain choco ffmpeg package can lack them)"
|
|
1761
|
+
else:
|
|
1762
|
+
full_hint = "install/build ffmpeg with it enabled"
|
|
1763
|
+
if cap.startswith("encoder:"):
|
|
1764
|
+
return f"this ffmpeg build has no {cap[8:]} encoder; {full_hint}"
|
|
1765
|
+
if cap.startswith("decoder:"):
|
|
1766
|
+
return f"this ffmpeg build has no {cap[8:]} decoder; {full_hint}"
|
|
1767
|
+
if cap == "filter:drawtext" and not drawtext_crashed:
|
|
1768
|
+
return f"this ffmpeg build has no drawtext filter (no freetype); {full_hint}"
|
|
1769
|
+
if cap == "filter:drawtext":
|
|
1770
|
+
return ("drawtext crashed instead of rendering a frame (see errors[] for the exit detail) -- "
|
|
1771
|
+
"every drawtext tool already resolves a concrete font file automatically when one can "
|
|
1772
|
+
"be found (#100); if it still crashes, use --no-timecode with look.py or scenes.py "
|
|
1773
|
+
"--sheet to skip drawtext entirely, or pass --font-file explicitly to overlay.py/"
|
|
1774
|
+
"graphics.py (the two that accept it) rather than relying on font= resolution")
|
|
1775
|
+
if cap.startswith("filter:"):
|
|
1776
|
+
return f"this ffmpeg build has no {cap[7:]} filter; {full_hint}"
|
|
1777
|
+
if cap.startswith("bsf:"):
|
|
1778
|
+
return f"this ffmpeg build has no {cap[4:]} bitstream filter; {full_hint}"
|
|
1779
|
+
if cap.startswith("font:"):
|
|
1780
|
+
from _common import LANGUAGE_NAMES, FONT_INSTALL_HINT
|
|
1781
|
+
script = cap[5:]
|
|
1782
|
+
return (f"no installed font covers {LANGUAGE_NAMES.get(script, script)} text on this machine; "
|
|
1783
|
+
f"{FONT_INSTALL_HINT} (doctor --json .fonts.scripts lists every script)")
|
|
1784
|
+
if cap == "external:whisper":
|
|
1785
|
+
return ("install a local whisper (whisper-cli, whisper-cpp, faster-whisper or openai-whisper) for --transcribe; "
|
|
1786
|
+
"faster-whisper and openai-whisper download their model on first use, and every engine transcribes "
|
|
1787
|
+
"on this machine (the audio is never uploaded)")
|
|
1788
|
+
if cap == "external:parakeet":
|
|
1789
|
+
from _common.asr import PARAKEET_MLX_DEFAULT_MODEL
|
|
1790
|
+
return ("for English --transcribe, install parakeet-mlx (uv tool install parakeet-mlx; its first run downloads "
|
|
1791
|
+
f"{PARAKEET_MLX_DEFAULT_MODEL} from Hugging Face, then it transcribes on this machine and the audio is "
|
|
1792
|
+
"never uploaded) or parakeet-cli with a tdt-0.6b-v2 .gguf in ~/.cache/parakeet.cpp; a local whisper "
|
|
1793
|
+
"covers every language")
|
|
1794
|
+
return f"'{cap}' is not available; see docs/contract.md"
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
def _tool_usability(state: Dict[str, str], drawtext_crashed: bool = False, covered: Optional[Dict[str, str]] = None,
|
|
1798
|
+
unsupported: Optional[List[str]] = None) -> Dict[str, Dict[str, Any]]:
|
|
1799
|
+
"""Per-tool usable/missing/unknown, folded from the same capability `state` doctor already
|
|
1800
|
+
computed. Answers "can I run this tool on this machine today", not just "what capabilities
|
|
1801
|
+
exist" -- a caller reading only `available`/`missing` still has to cross-reference each tool's
|
|
1802
|
+
own required-capability list by hand to answer that. A required capability in `covered`
|
|
1803
|
+
(libx264 replaced by VideoToolbox on this machine) blocks nothing; the tool lists it in `covered_by`.
|
|
1804
|
+
A Python or FFmpeg below the 3.0.0 floor (`unsupported`) makes every tool unusable: each one
|
|
1805
|
+
refuses to start on it."""
|
|
1806
|
+
covered = covered or {}
|
|
1807
|
+
tools: Dict[str, Dict[str, Any]] = {}
|
|
1808
|
+
for name, meta in TOOL_META.items():
|
|
1809
|
+
required = list(meta["required"])
|
|
1810
|
+
missing = [c for c in required if state.get(c) == "missing" and c not in covered]
|
|
1811
|
+
unknown = [c for c in required if state.get(c) == "unknown"]
|
|
1812
|
+
entry: Dict[str, Any] = {"usable": "no" if missing or unsupported else ("unknown" if unknown else "yes")}
|
|
1813
|
+
fixes = []
|
|
1814
|
+
if missing:
|
|
1815
|
+
entry["missing"] = missing
|
|
1816
|
+
fixes += [_capability_fix_hint(c, drawtext_crashed) for c in missing]
|
|
1817
|
+
if unsupported:
|
|
1818
|
+
entry["unsupported"] = list(unsupported)
|
|
1819
|
+
fixes.append("install Python 3.10+ and FFmpeg 6.1+ (ffmpeg and ffprobe from one build)")
|
|
1820
|
+
if fixes:
|
|
1821
|
+
entry["fix"] = "; ".join(dict.fromkeys(fixes))
|
|
1822
|
+
if unknown:
|
|
1823
|
+
entry["unknown"] = unknown
|
|
1824
|
+
via = {c: covered[c] for c in required if c in covered}
|
|
1825
|
+
if via:
|
|
1826
|
+
entry["covered_by"] = via
|
|
1827
|
+
tools[name] = entry
|
|
1828
|
+
return tools
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
# Cross-repository Capability ids (kajisho5/AI-video-production-OS docs/SPEC.md
|
|
1832
|
+
# `CapabilityContract.provides`), matching the ids already assigned to these 21 tools in
|
|
1833
|
+
# that project's own docs/CAPABILITY_MATRIX.md section 9: "ffmpeg-skill's 21 raw tools ...
|
|
1834
|
+
# are Capabilities in their own right, independent of the higher-level Skills that
|
|
1835
|
+
# delegate to them". Each tool's own id is `ffmpeg-skill/<tool>` (a slash, matching every
|
|
1836
|
+
# ToolSpec.id here); the Capability id uses a dot - `ffmpeg-skill.<tool>` - the same
|
|
1837
|
+
# `<domain>.<verb>`-shaped convention every other Skill's Capability ids use elsewhere in
|
|
1838
|
+
# that project (`video.trim`, `audio.gain`, ...), with "ffmpeg-skill" as the domain.
|
|
1839
|
+
def capability_provides() -> List[Dict[str, str]]:
|
|
1840
|
+
return [{"id": f"{SKILL_ID}.{name}", "lifecycle": "EXPERIMENTAL", "tool_id": f"{SKILL_ID}/{name}"} for name in public_tools()]
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
# Abstract, domain-shaped capability ids (`<domain>.<verb>`, matching the convention `provides`
|
|
1844
|
+
# already documents for cross-repo Capability ids) that a planning agent can resolve without
|
|
1845
|
+
# already knowing this skill's tool names. Unlike `provides` (one entry per tool, id derived
|
|
1846
|
+
# from the tool name), this is a hand-authored, many-to-one table: several of these ids name a
|
|
1847
|
+
# tool PLUS the fixed parameters that pin it to that specific behaviour (`video.reframe` is
|
|
1848
|
+
# `fit.py` with `fit=crop` fixed, not bare `fit.py`, which also speed-ramps and pads). This is
|
|
1849
|
+
# still purely descriptive -- a caller still builds and runs the named tool's own CLI/MCP call
|
|
1850
|
+
# from its `input_schema`; nothing here executes or chooses on the caller's behalf. Deliberately
|
|
1851
|
+
# excludes any capability that would require judgment to resolve (e.g. no `video.highlight`:
|
|
1852
|
+
# `scenes.py --highlights` ranks by a measured proxy, never by understood content -- see
|
|
1853
|
+
# SKILL.md "What this skill does and does not decide" -- so it is not offered as a capability
|
|
1854
|
+
# a planner can blindly delegate to). `media.proxy` (a low-bitrate, fast-decode proxy, distinct
|
|
1855
|
+
# from `export.py`'s delivery presets, which target visual quality over size/speed) resolves to
|
|
1856
|
+
# `proxy.py` -- itself a purely mechanical resize+re-encode with no opinion on which asset should
|
|
1857
|
+
# be proxied or what for.
|
|
1858
|
+
CAPABILITY_MAP: List[Dict[str, Any]] = [
|
|
1859
|
+
{"capability": "video.trim", "tool_id": f"{SKILL_ID}/cut", "params": {}},
|
|
1860
|
+
{"capability": "video.reframe", "tool_id": f"{SKILL_ID}/fit", "params": {"fit": "crop"}},
|
|
1861
|
+
{"capability": "audio.loudness", "tool_id": f"{SKILL_ID}/loudness", "params": {}},
|
|
1862
|
+
{"capability": "subtitle.burn", "tool_id": f"{SKILL_ID}/caption", "params": {}},
|
|
1863
|
+
{"capability": "media.stream.inspect", "tool_id": f"{SKILL_ID}/probe", "params": {}},
|
|
1864
|
+
{"capability": "media.frames.extract", "tool_id": f"{SKILL_ID}/look", "params": {}},
|
|
1865
|
+
{"capability": "media.proxy", "tool_id": f"{SKILL_ID}/proxy", "params": {}},
|
|
1866
|
+
]
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
def capability_map(tools: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
1870
|
+
"""Validate CAPABILITY_MAP against the live tool specs before returning it. A fixed param
|
|
1871
|
+
that isn't a real input_schema property is drift, not a typo to ship silently (same "fail
|
|
1872
|
+
loudly" posture as tool_spec()'s missing-TOOL_META check). A tool_id that no longer exists
|
|
1873
|
+
is not drift in that sense -- a tool can legitimately be removed -- so that capability is
|
|
1874
|
+
dropped from the map rather than crashing the whole contract build."""
|
|
1875
|
+
by_id = {t["id"]: t for t in tools}
|
|
1876
|
+
result = []
|
|
1877
|
+
for entry in CAPABILITY_MAP:
|
|
1878
|
+
spec = by_id.get(entry["tool_id"])
|
|
1879
|
+
if spec is None:
|
|
1880
|
+
continue
|
|
1881
|
+
props = spec["input_schema"]["properties"]
|
|
1882
|
+
for key in entry["params"]:
|
|
1883
|
+
if key not in props:
|
|
1884
|
+
raise RuntimeError(f"capability {entry['capability']!r} sets param {key!r} which is not in {entry['tool_id']}'s input_schema")
|
|
1885
|
+
result.append(dict(entry))
|
|
1886
|
+
return result
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
# ----------------------------------------------------------------------------- contract
|
|
1890
|
+
def _merge_optional(base: List[Dict[str, Any]], extra: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
1891
|
+
"""Optional capabilities de-duplicated by name: a tool that already lists encoder:libx265 for
|
|
1892
|
+
HDR sources gets its `when` extended by the --codec condition instead of a second entry."""
|
|
1893
|
+
out: List[Dict[str, Any]] = [dict(o) for o in base]
|
|
1894
|
+
for o in extra:
|
|
1895
|
+
hit = next((b for b in out if b["capability"] == o["capability"]), None)
|
|
1896
|
+
if hit is None:
|
|
1897
|
+
out.append(dict(o))
|
|
1898
|
+
elif o["when"] not in hit["when"]:
|
|
1899
|
+
hit["when"] = f"{hit['when']}; {o['when']}"
|
|
1900
|
+
return out
|
|
1901
|
+
|
|
1902
|
+
|
|
1903
|
+
_SENTENCE_END = re.compile(r"(?<!\be\.g)(?<!\bi\.e)(?<!\betc)[.!?](?=\s|$)")
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
def summary_sentence(docstring: str) -> str:
|
|
1907
|
+
"""The docstring's first sentence, its wrapped lines joined (#466 A195: the first physical line
|
|
1908
|
+
cut 16 descriptions mid-phrase). A first paragraph with no full stop is taken whole."""
|
|
1909
|
+
para = re.split(r"\n\s*\n", docstring.strip(), maxsplit=1)[0]
|
|
1910
|
+
joined = " ".join(line.strip() for line in para.splitlines())
|
|
1911
|
+
end = _SENTENCE_END.search(joined)
|
|
1912
|
+
return joined[:end.end()] if end else joined
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
def tool_spec(name: str, version: str) -> Dict[str, Any]:
|
|
1916
|
+
if name not in TOOL_META:
|
|
1917
|
+
# a public script without metadata is drift: fail loudly instead of guessing its role or capabilities
|
|
1918
|
+
raise RuntimeError(f"scripts/{name}.py is public but has no TOOL_META entry in scripts/_contract.py; add one (or prefix the file with '_')")
|
|
1919
|
+
meta = TOOL_META[name]
|
|
1920
|
+
parser = _capture_parser(HERE / f"{name}.py")
|
|
1921
|
+
schema = input_schema(parser)
|
|
1922
|
+
# structured key -> CLI flag where key.replace("_", "-") is not the long option (MCP uses the same table)
|
|
1923
|
+
exceptions: Dict[str, str] = {}
|
|
1924
|
+
for dest, prop in schema["properties"].items():
|
|
1925
|
+
if prop["cli"] == "positional":
|
|
1926
|
+
continue
|
|
1927
|
+
longs = [f for f in prop["cli"] if f.startswith("--")]
|
|
1928
|
+
if dest == "output":
|
|
1929
|
+
exceptions[dest] = "-o"
|
|
1930
|
+
elif name == "loudness" and dest == "lufs":
|
|
1931
|
+
exceptions[dest] = "-I"
|
|
1932
|
+
elif "--" + dest.replace("_", "-") not in longs:
|
|
1933
|
+
exceptions[dest] = longs[0] if longs else prop["cli"][0]
|
|
1934
|
+
supports_dry_run = "dry_run" in schema["properties"] and name != "verify"
|
|
1935
|
+
return {
|
|
1936
|
+
"id": f"{SKILL_ID}/{name}",
|
|
1937
|
+
"name": name,
|
|
1938
|
+
"version": version,
|
|
1939
|
+
"description": summary_sentence(parser.description or ""),
|
|
1940
|
+
"executable": f"scripts/{name}.py",
|
|
1941
|
+
# 1.20.0: SKILL.md's own request-table rows for this tool, machine-readable
|
|
1942
|
+
"examples": skill_examples().get(name, []),
|
|
1943
|
+
"role": meta["role"],
|
|
1944
|
+
# 4.0.0: what the 4.x promise covers for this tool (docs/contract.md, Stability guarantee (4.x))
|
|
1945
|
+
"stability": "stable" if name in STABLE_TOOLS else "beta",
|
|
1946
|
+
"capabilities": {"required": list(meta["required"]), "optional": _merge_optional(meta["optional"], (CODEC_CAPS if "codec" in schema["properties"] else [])
|
|
1947
|
+
+ (ALPHA_LINE_OPTIONAL if name in ALPHA_LINE_TOOLS else []))},
|
|
1948
|
+
"inputs": list(meta["inputs"]),
|
|
1949
|
+
"outputs": list(meta["outputs"]),
|
|
1950
|
+
"input_schema": schema,
|
|
1951
|
+
"output_schema": output_schema(name, meta, hw="hw" in schema["properties"]),
|
|
1952
|
+
"supports_dry_run": supports_dry_run,
|
|
1953
|
+
"dry_run": {"supported": supports_dry_run,
|
|
1954
|
+
"ffmpeg_execution": "full" if not supports_dry_run else "analysis_only" if name in DRY_RUN_ANALYSIS else "none",
|
|
1955
|
+
"semantics": "prints the ffmpeg command lines that would run; no output file is written",
|
|
1956
|
+
**({"note": DRY_RUN_ANALYSIS.get(name) or DRY_RUN_NOTES[name]} if name in DRY_RUN_ANALYSIS or name in DRY_RUN_NOTES else {})},
|
|
1957
|
+
"supports_json": "json" in schema["properties"],
|
|
1958
|
+
# additive mirror of supports_json (1.11.0): --json-brief is the same document trimmed
|
|
1959
|
+
"supports_json_brief": "json_brief" in schema["properties"],
|
|
1960
|
+
"mutates_input": False,
|
|
1961
|
+
"produces_artifact": meta["produces_artifact"],
|
|
1962
|
+
"verification": {"required": bool(meta["verify"]), "tools": [f"{SKILL_ID}/{t}" for t in meta["verify"]]},
|
|
1963
|
+
# a tool with no declared entry reports "conditional" rather than guessing "always" or
|
|
1964
|
+
# "never" -- same "unknown is not missing" principle as doctor's capability detection
|
|
1965
|
+
"reencodes_video": REENCODE_META.get(name, {}).get("video", "conditional"),
|
|
1966
|
+
"reencodes_audio": REENCODE_META.get(name, {}).get("audio", "conditional"),
|
|
1967
|
+
**({"reencode_note": REENCODE_META[name]["note"]} if REENCODE_META.get(name, {}).get("note") else {}),
|
|
1968
|
+
"requires_visual_verification": meta["visual"],
|
|
1969
|
+
# 2.18: what `verified` does not cover for this tool (the result's `unverified`)
|
|
1970
|
+
"unverified_properties": list(_unverified_table().get(name, [])),
|
|
1971
|
+
"audio_only": meta["audio_only"],
|
|
1972
|
+
"video_required": meta["video_required"],
|
|
1973
|
+
"deterministic_inputs": meta["deterministic"],
|
|
1974
|
+
"idempotency_hint": meta["idempotency"],
|
|
1975
|
+
"mcp": {"tool": name, "positional": schema["positional"], "argument_exceptions": exceptions},
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
# ----------------------------------------------------------------------------- MCP derivation
|
|
1980
|
+
# tools that print JSON without --json (probe) or whose primary output is a file path (look): the transport
|
|
1981
|
+
# does not append --json for them (stated in invocation.structured.argument_mapping.json)
|
|
1982
|
+
# ----------------------------------------------------------------------------- deprecations
|
|
1983
|
+
# What the next major removes, announced here per docs/contract.md's three-step deprecation policy:
|
|
1984
|
+
# step 1 (this list, --help text and the CHANGELOG) in a minor, step 2 keeps it working, step 3
|
|
1985
|
+
# removes it in the major. `where` says which surface a caller sees it on. Empty at 2.0.0 and at
|
|
1986
|
+
# 3.0.0: every deprecation announced in 1.x and 2.x was settled by its major (REMOVED below).
|
|
1987
|
+
DEPRECATED: List[Dict[str, str]] = []
|
|
1988
|
+
|
|
1989
|
+
# What each major removed or changed, with the version that deprecated each: the "Removed" half of
|
|
1990
|
+
# the policy's step 3, kept in the contract so a caller migrating can diff it instead of reading a
|
|
1991
|
+
# CHANGELOG. docs/contract.md's "What 2.0 changed" and "What 3.0 changed" tables are written from it.
|
|
1992
|
+
REMOVED: List[Dict[str, str]] = [
|
|
1993
|
+
{"what": "--crf as an alias of --quality on every re-encoding tool that takes --quality (export.py keeps --crf: its preset chooses the encoder)",
|
|
1994
|
+
"since": "1.10.0", "removed_in": "2.0.0", "where": "cli",
|
|
1995
|
+
"replacement": "--quality N (the same CRF scale, codec-neutral; each tool's old --crf default is its --quality default)"},
|
|
1996
|
+
{"what": "json and progress in the MCP inputSchema (they are CLI transport flags, not tool arguments)",
|
|
1997
|
+
"since": "1.10.0", "removed_in": "2.0.0", "where": "mcp",
|
|
1998
|
+
"replacement": "nothing: the MCP transport sets them itself; a client that still sends them is not refused"},
|
|
1999
|
+
{"what": "probe's hdr meaning BT.2020 primaries or a PQ/HLG transfer",
|
|
2000
|
+
"since": "1.10.0", "removed_in": "2.0.0", "where": "json",
|
|
2001
|
+
"replacement": "hdr is now true only for PQ / HLG / Dolby Vision (as hdr_signal, which stays); bt2020_or_hdr carries the 1.x meaning"},
|
|
2002
|
+
{"what": "overwriting an existing output without --overwrite (1.x warned)",
|
|
2003
|
+
"since": "1.10.0", "removed_in": "2.0.0", "where": "behaviour",
|
|
2004
|
+
"replacement": "--overwrite as explicit consent; without it an existing output is refused (kind: input) before anything runs"},
|
|
2005
|
+
{"what": "the result_v2 preview key and FFMPEG_SKILL_RESULT_V2 (the v1 top-level keys it was to replace were un-deprecated: they are the 2.0 shape)",
|
|
2006
|
+
"since": "1.10.0", "removed_in": "2.0.0", "where": "json",
|
|
2007
|
+
"replacement": "the top-level keys, unchanged from 1.x; --json-brief for a short document"},
|
|
2008
|
+
{"what": "running on Python 3.9 (the requirements.python floor)",
|
|
2009
|
+
"since": "2.10.9", "removed_in": "3.0.0", "where": "behaviour",
|
|
2010
|
+
"replacement": "Python 3.10 or later; the npx installer skips an older interpreter and doctor reports it as unsupported (ok: false)"},
|
|
2011
|
+
{"what": "running on FFmpeg 5.x (the requirements.ffmpeg floor)",
|
|
2012
|
+
"since": "2.14.0", "removed_in": "3.0.0", "where": "behaviour",
|
|
2013
|
+
"replacement": "FFmpeg 6.1 or later; every tool refuses an older one it can read (kind: missing_tool), and doctor reports it as unsupported"},
|
|
2014
|
+
]
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
MCP_JSON_EXEMPT = ("look", "probe")
|
|
2018
|
+
# json/progress are CLI transport flags the MCP server sets itself, not tool arguments: 2.0 leaves
|
|
2019
|
+
# them out of every inputSchema (1.10.0-1.x kept them unless FFMPEG_SKILL_MCP_LEAN=1). A client
|
|
2020
|
+
# that still sends them is not refused -- build_argv() maps them like any other key.
|
|
2021
|
+
MCP_TRANSPORT_FLAGS = ("json", "progress")
|
|
2022
|
+
# what a read-only tool's (mcp_read_only: probe, check, cropdetect) MCP inputSchema says of the two
|
|
2023
|
+
# keys that would write a file: `plan` is refused over MCP and `overwrite` only governed that plan.
|
|
2024
|
+
# The names stay (3.x never removes an inputSchema property); the CLI keeps both working (every
|
|
2025
|
+
# tool gets --plan, docs/design-decisions.md).
|
|
2026
|
+
MCP_READ_ONLY_REFUSED = {
|
|
2027
|
+
"plan": "refused over MCP (read-only tool; error.reason read_only_plan_refused): this tool writes no file here; run it from the CLI to write a plan",
|
|
2028
|
+
"overwrite": "no effect over MCP: this read-only tool writes no file (it governed --plan, which is refused here)",
|
|
2029
|
+
}
|
|
2030
|
+
# set by mcp/server.py in the environment of a read-only tool's process: --plan is refused
|
|
2031
|
+
# (kind input, error.reason read_only_plan_refused), however the raw argv spells it
|
|
2032
|
+
READ_ONLY_ENV = "FFMPEG_SKILL_READ_ONLY"
|
|
2033
|
+
# default MCP tools/list surface (roadmap P1-7, shipped 1.18.3): the 42-tool schema dump costs
|
|
2034
|
+
# every MCP session context whether it needs it or not. These 12 are the tools eval iterations
|
|
2035
|
+
# 17-20's ground-truth `expect` lists actually name most often across the 118 agent prompts in
|
|
2036
|
+
# evals/agent_prompts*.json (render/look/caption/export/check each >=10 hits; fit/cut/audio/
|
|
2037
|
+
# loudness/graphics/silence/probe each >=6) -- not a hand-picked "starter" set. `tools/list`
|
|
2038
|
+
# returns only these unless FFMPEG_SKILL_MCP_FULL=1 (anything but "" or "0") asks for all 42; the
|
|
2039
|
+
# other 30 stay reachable by name through tools/call either way, and `contract --json` always
|
|
2040
|
+
# describes all 42.
|
|
2041
|
+
MCP_CORE_TOOLS = ("render", "look", "caption", "export", "check", "fit", "cut", "audio", "loudness", "graphics", "silence", "probe")
|
|
2042
|
+
# 4.0.0: the tools whose surface 4.x promises not to break; the other 30 are "beta" (docs/contract.md).
|
|
2043
|
+
STABLE_TOOLS = MCP_CORE_TOOLS
|
|
2044
|
+
MCP_STRUCTURED_NOTE = ("Structured arguments: keys are the input_schema property names (argparse dests), positionals "
|
|
2045
|
+
"are passed by name, output -> -o. Or argv: the raw CLI list (non-canonical; all other keys are then ignored). "
|
|
2046
|
+
"Media paths must be absolute.")
|
|
2047
|
+
|
|
2048
|
+
# roadmap 1.20.0 "agent ergonomics": a `prompts` capability with the five workflows an agent asks
|
|
2049
|
+
# for most often (per the SKILL.md request table these are built from -- see skill_examples()'s
|
|
2050
|
+
# own source, not a separate hand-picked list). Each `template` is filled with `{name}` -> the
|
|
2051
|
+
# matching argument's value; a missing optional argument's `{name}` is dropped along with the
|
|
2052
|
+
# surrounding text named in `optional` (so "no chapters file" doesn't leave a dangling clause).
|
|
2053
|
+
# The five are recipes, not new tool calls -- every command line named is one this skill already
|
|
2054
|
+
# runs; `prompts/get` hands back the same facts SKILL.md's own table states, just addressed by
|
|
2055
|
+
# workflow instead of by request phrasing.
|
|
2056
|
+
MCP_PROMPTS: List[Dict[str, Any]] = [
|
|
2057
|
+
{
|
|
2058
|
+
"name": "reel", "description": "Turn a clip into a captioned vertical delivery (TikTok/Reels/Shorts) and verify it.",
|
|
2059
|
+
"arguments": [{"name": "input", "description": "path to the source video", "required": True},
|
|
2060
|
+
{"name": "platform", "description": "tiktok | reels | shorts | youtube-shorts (default reels)", "required": False, "default": "reels"},
|
|
2061
|
+
{"name": "cues", "description": "path to a captions cue file, if the clip needs captions", "required": False}],
|
|
2062
|
+
"optional": {"cues": " with cues from {cues}"},
|
|
2063
|
+
"template": ("Turn {input} into a {platform} deliverable: run `render.py --template {platform} {input}`{cues}, "
|
|
2064
|
+
"which handles frame, captions, loudness and export in one command. Then verify with "
|
|
2065
|
+
"`check.py <output> --platform {platform}` before calling it done -- format rows (codec, pixel "
|
|
2066
|
+
"format, size, true peak, colour tags, VFR) are safe to fix; judgement rows (duration, aspect, "
|
|
2067
|
+
"fps, loudness) change content, so fix them only when the request implies the answer, otherwise "
|
|
2068
|
+
"state the choice and its cost. Mention WARNs; do not chase them. A duration or file size WARN with "
|
|
2069
|
+
"basis guidance is the table's upload limit, which platforms change: report it, the uploader "
|
|
2070
|
+
"checks the current one."),
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
"name": "podcast", "description": "Turn an audio recording into a loudness-normalised podcast episode with chapters.",
|
|
2074
|
+
"arguments": [{"name": "input", "description": "path to the source audio", "required": True},
|
|
2075
|
+
{"name": "chapters", "description": "path to a chapters timing file", "required": False}],
|
|
2076
|
+
"optional": {"chapters": " with chapters from `metadata.py <output> --chapters {chapters}`"},
|
|
2077
|
+
"template": ("Turn {input} into a podcast episode: normalise loudness with `loudness.py {input} -I -16 --tp -1.5`"
|
|
2078
|
+
"{chapters}, then verify with `check.py <output> --platform podcast` (its chapters and channels rows)."),
|
|
2079
|
+
},
|
|
2080
|
+
{
|
|
2081
|
+
"name": "multicam", "description": "Cut between several camera angles of the same scene.",
|
|
2082
|
+
"arguments": [{"name": "inputs", "description": "the camera files, space-separated", "required": True}],
|
|
2083
|
+
"optional": {},
|
|
2084
|
+
"template": ("Cut between the cameras in {inputs}: `multicam.py {inputs} --switch energy` auto-cuts to the "
|
|
2085
|
+
"loudest camera at each moment (`--min-shot` sets the shortest allowed shot); a manual spec "
|
|
2086
|
+
"looks like `--switch \"0-20:0,20-40:1,40-60:2\"`. Check the reported sync confidence per camera "
|
|
2087
|
+
"-- under 0.3 (or a large offset) is suspect and needs a manual look; these align audio, never lip sync."),
|
|
2088
|
+
},
|
|
2089
|
+
{
|
|
2090
|
+
"name": "delivery_check", "description": "Verify a finished file is ready to upload to a platform.",
|
|
2091
|
+
"arguments": [{"name": "input", "description": "path to the file to check", "required": True},
|
|
2092
|
+
{"name": "platform", "description": "youtube | reels | tiktok | shorts | x | linkedin | facebook | podcast", "required": True}],
|
|
2093
|
+
"optional": {},
|
|
2094
|
+
"template": ("Verify {input} is ready for {platform}: run `check.py {input} --platform {platform}`. Format "
|
|
2095
|
+
"rows (codec, pixel format, size, true peak, colour tags, VFR) are safe to fix automatically. "
|
|
2096
|
+
"Judgement rows (duration, aspect, fps, loudness) change content -- fix only when the request "
|
|
2097
|
+
"implies the answer, otherwise state the choice and its cost. Mention WARNs; do not chase them."),
|
|
2098
|
+
},
|
|
2099
|
+
{
|
|
2100
|
+
"name": "hdr", "description": "Bring an HDR or Dolby Vision clip down to SDR (or strip only the DV layer).",
|
|
2101
|
+
"arguments": [{"name": "input", "description": "path to the HDR/Dolby Vision source", "required": True},
|
|
2102
|
+
{"name": "strip_dovi", "description": "true to keep HDR and drop only the Dolby Vision layer, instead of converting to SDR", "required": False}],
|
|
2103
|
+
"optional": {},
|
|
2104
|
+
"template": ("Bring {input} from HDR/Dolby Vision down to SDR: `color.py {input} --to-sdr` (or `--strip-dovi` "
|
|
2105
|
+
"to keep HDR and only drop the Dolby Vision layer, when strip_dovi is asked for). A flat, washed-out "
|
|
2106
|
+
"look after a re-encode usually means HDR metadata was lost upstream; `probe` shows `hdr: true` "
|
|
2107
|
+
"only for a real PQ/HLG/Dolby Vision signal, and `bt2020_or_hdr: true` also for BT.2020 SDR."),
|
|
2108
|
+
# A23 (#465): strip_dovi was taken and changed nothing; true now asks for the other recipe
|
|
2109
|
+
"flags": {"strip_dovi": (
|
|
2110
|
+
"Keep {input} HDR and drop only its Dolby Vision layer: `color.py {input} --strip-dovi`, a stream copy "
|
|
2111
|
+
"(HEVC only) that removes the Dolby Vision RPU so players use the HLG/HDR10 base layer. A source with no "
|
|
2112
|
+
"Dolby Vision metadata gets a `dovi_not_detected` warning.")},
|
|
2113
|
+
},
|
|
2114
|
+
]
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
def mcp_prompt_list() -> List[Dict[str, Any]]:
|
|
2118
|
+
"""`prompts/list`: name, description and arguments for each of MCP_PROMPTS -- everything but
|
|
2119
|
+
the template, which `prompts/get` fills."""
|
|
2120
|
+
return [{"name": p["name"], "description": p["description"], "arguments": p["arguments"]} for p in MCP_PROMPTS]
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
def mcp_prompt_get(name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
2124
|
+
"""`prompts/get`: the filled template as a single user-role text message. Raises KeyError for
|
|
2125
|
+
an unknown prompt name (mirrors call_tool's own unknown-tool handling) and ValueError naming
|
|
2126
|
+
the missing argument when a required one is absent -- both are caller mistakes, not server
|
|
2127
|
+
failures, so the transport turns them into a JSON-RPC error rather than a crash."""
|
|
2128
|
+
by_name = {p["name"]: p for p in MCP_PROMPTS}
|
|
2129
|
+
if name not in by_name:
|
|
2130
|
+
raise KeyError(name)
|
|
2131
|
+
prompt = by_name[name]
|
|
2132
|
+
missing = [a["name"] for a in prompt["arguments"] if a["required"] and not (arguments or {}).get(a["name"])]
|
|
2133
|
+
if missing:
|
|
2134
|
+
raise ValueError(f"prompt {name!r} needs {', '.join(missing)}")
|
|
2135
|
+
fields: Dict[str, str] = {a["name"]: str((arguments or {}).get(a["name"]) or a.get("default", "")) for a in prompt["arguments"]}
|
|
2136
|
+
for opt_name, clause in prompt["optional"].items():
|
|
2137
|
+
fields[opt_name] = clause.format(**fields) if fields.get(opt_name) else ""
|
|
2138
|
+
template = prompt["template"]
|
|
2139
|
+
for flag, flag_template in (prompt.get("flags") or {}).items():
|
|
2140
|
+
# a yes/no argument picks the recipe; every prompt argument arrives as a string, so
|
|
2141
|
+
# "false" is no, and a value that is neither is a caller mistake (ValueError, as above)
|
|
2142
|
+
value = (arguments or {}).get(flag)
|
|
2143
|
+
word = str(value).strip().lower() if value is not None else ""
|
|
2144
|
+
if word in ("true", "1", "yes"):
|
|
2145
|
+
template = flag_template
|
|
2146
|
+
elif word not in ("", "false", "0", "no"):
|
|
2147
|
+
raise ValueError(f"prompt {name!r}: {flag} must be true or false, got {value!r}")
|
|
2148
|
+
text = template.format(**fields)
|
|
2149
|
+
return {"description": prompt["description"], "messages": [{"role": "user", "content": {"type": "text", "text": text}}]}
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
def mcp_input_schema(spec: Dict[str, Any]) -> Dict[str, Any]:
|
|
2153
|
+
"""Translate a ToolSpec.input_schema into the JSON Schema an MCP tools/list entry carries.
|
|
2154
|
+
|
|
2155
|
+
Deterministic and lossless where JSON Schema can express argparse semantics:
|
|
2156
|
+
- properties keep type / enum / default / description / items; the ffmpeg-skill-only keys
|
|
2157
|
+
(`cli`, `common`) are dropped, positionals get a "(positional N)" prefix in the description;
|
|
2158
|
+
- required fields, mutually exclusive groups (`not required [a, b]` per pair) and required
|
|
2159
|
+
groups (`anyOf required`) apply to the structured branch;
|
|
2160
|
+
- the raw-argv compatibility branch (`argv` present) lifts those constraints, which JSON Schema
|
|
2161
|
+
expresses as a top-level anyOf of the two branches.
|
|
2162
|
+
Not expressible and therefore documented rather than encoded: which keys the tool ignores when
|
|
2163
|
+
`argv` is given (all of them), and argparse's `%(default)s` help interpolation (already applied).
|
|
2164
|
+
"""
|
|
2165
|
+
src = spec["input_schema"]
|
|
2166
|
+
props: Dict[str, Any] = {}
|
|
2167
|
+
positional = list(src.get("positional", []))
|
|
2168
|
+
for dest in sorted(src["properties"]):
|
|
2169
|
+
p = src["properties"][dest]
|
|
2170
|
+
out: Dict[str, Any] = {"type": p["type"]}
|
|
2171
|
+
if p["type"] == "array":
|
|
2172
|
+
out["items"] = dict(p.get("items", {"type": "string"}))
|
|
2173
|
+
desc = p.get("description", "")
|
|
2174
|
+
if dest in positional:
|
|
2175
|
+
desc = f"(positional {positional.index(dest) + 1}) {desc}".strip()
|
|
2176
|
+
if desc:
|
|
2177
|
+
out["description"] = desc
|
|
2178
|
+
for key in ("enum", "default"):
|
|
2179
|
+
if key in p:
|
|
2180
|
+
out[key] = p[key]
|
|
2181
|
+
props[dest] = out
|
|
2182
|
+
props["argv"] = {"type": "array", "items": {"type": "string"}, "description": "raw CLI arguments; when present every other key is ignored"}
|
|
2183
|
+
structured: Dict[str, Any] = {}
|
|
2184
|
+
if src.get("required"):
|
|
2185
|
+
structured["required"] = list(src["required"])
|
|
2186
|
+
all_of: List[Dict[str, Any]] = []
|
|
2187
|
+
for group in src.get("mutually_exclusive", []):
|
|
2188
|
+
for i, a in enumerate(group):
|
|
2189
|
+
for b in group[i + 1:]:
|
|
2190
|
+
all_of.append({"not": {"required": [a, b]}})
|
|
2191
|
+
if all_of:
|
|
2192
|
+
structured["allOf"] = all_of
|
|
2193
|
+
one_of = [[{"required": [d]} for d in group] for group in src.get("one_of_required", [])]
|
|
2194
|
+
if one_of:
|
|
2195
|
+
structured["anyOf"] = one_of[0] if len(one_of) == 1 else [{"allOf": [{"anyOf": g} for g in one_of]}]
|
|
2196
|
+
for dest in MCP_TRANSPORT_FLAGS:
|
|
2197
|
+
props.pop(dest, None)
|
|
2198
|
+
if mcp_read_only(spec):
|
|
2199
|
+
# a tool that writes no artifact is annotated readOnlyHint; --plan is the one file it could
|
|
2200
|
+
# still write (and --overwrite only governs that file). mcp/server.py runs the tool with
|
|
2201
|
+
# FFMPEG_SKILL_READ_ONLY=1, which refuses --plan however it is spelled; the descriptions say so
|
|
2202
|
+
for dest, text in MCP_READ_ONLY_REFUSED.items():
|
|
2203
|
+
if dest in props:
|
|
2204
|
+
props[dest]["description"] = text
|
|
2205
|
+
if structured.get("required"):
|
|
2206
|
+
structured["required"] = [d for d in structured["required"] if d not in MCP_TRANSPORT_FLAGS]
|
|
2207
|
+
if not structured["required"]:
|
|
2208
|
+
del structured["required"]
|
|
2209
|
+
schema: Dict[str, Any] = {"type": "object", "properties": props, "additionalProperties": False}
|
|
2210
|
+
if structured:
|
|
2211
|
+
schema["anyOf"] = [{"required": ["argv"]}, structured]
|
|
2212
|
+
return schema
|
|
2213
|
+
|
|
2214
|
+
|
|
2215
|
+
def mcp_tool(spec: Dict[str, Any]) -> Dict[str, Any]:
|
|
2216
|
+
"""The MCP tools/list entry for a ToolSpec: name, one-line description and the derived
|
|
2217
|
+
inputSchema. 1.20.0: MCP_STRUCTURED_NOTE used to be appended to every one of the 42
|
|
2218
|
+
descriptions verbatim (the same ~250 characters repeated 42 times in every tools/list dump);
|
|
2219
|
+
it now goes once into the server's `initialize` response (`instructions`) instead, so a tool's
|
|
2220
|
+
own description stays its own one-line sentence."""
|
|
2221
|
+
return {"name": spec["name"], "description": spec["description"], "inputSchema": mcp_input_schema(spec),
|
|
2222
|
+
"annotations": mcp_annotations(spec)}
|
|
2223
|
+
|
|
2224
|
+
|
|
2225
|
+
def mcp_read_only(spec: Dict[str, Any]) -> bool:
|
|
2226
|
+
"""A tool that writes no artifact and does not touch its input: over MCP it writes nothing at
|
|
2227
|
+
all (mcp/server.py refuses its `plan`, see mcp_input_schema), so it is annotated readOnlyHint."""
|
|
2228
|
+
return not (bool(spec.get("produces_artifact")) or bool(spec.get("mutates_input")))
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
def mcp_annotations(spec: Dict[str, Any]) -> Dict[str, Any]:
|
|
2232
|
+
"""MCP ToolAnnotations (spec 2025-06-18) derived from the ToolSpec flags. Hints only: clients
|
|
2233
|
+
must not treat them as a security boundary. Every tool runs locally (no open world). A tool
|
|
2234
|
+
that writes nothing is read-only (mcp_read_only: the server runs it with
|
|
2235
|
+
FFMPEG_SKILL_READ_ONLY=1, which refuses `--plan` however it is spelled). Every other tool is
|
|
2236
|
+
destructive: none edits its input in place, but with `overwrite` it replaces an existing file at its output or plan path, which is not an
|
|
2237
|
+
additive update."""
|
|
2238
|
+
writes = not mcp_read_only(spec)
|
|
2239
|
+
return {"title": spec["name"],
|
|
2240
|
+
"readOnlyHint": not writes,
|
|
2241
|
+
"destructiveHint": writes,
|
|
2242
|
+
"idempotentHint": spec.get("idempotency_hint") in ("bit_exact", "content_equivalent", "cached"),
|
|
2243
|
+
"openWorldHint": False}
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
def mcp_tools(detect: bool = False) -> List[Dict[str, Any]]:
|
|
2247
|
+
return [mcp_tool(spec) for spec in build(detect=detect)["tools"]]
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
def build(detect: bool = True) -> Dict[str, Any]:
|
|
2251
|
+
version = skill_version()
|
|
2252
|
+
tools = [tool_spec(n, version) for n in public_tools()]
|
|
2253
|
+
wanted = required_capabilities()
|
|
2254
|
+
caps: Dict[str, Any] = {"required": wanted["required"], "optional": wanted["optional"], "naming": "ffmpeg | ffprobe | encoder:<name> | decoder:<name> | filter:<name> | bsf:<name> | external:whisper | external:parakeet"}
|
|
2255
|
+
if detect:
|
|
2256
|
+
d = doctor()
|
|
2257
|
+
caps.update({"available": d["available"], "missing": d["missing"], "missing_optional": d["missing_optional"],
|
|
2258
|
+
"unknown": d["unknown"], "detection": d["detection"], "detected_by": "doctor"})
|
|
2259
|
+
return {
|
|
2260
|
+
"contract_version": CONTRACT_VERSION,
|
|
2261
|
+
"deprecated": [dict(d) for d in DEPRECATED],
|
|
2262
|
+
"removed": [dict(d) for d in REMOVED],
|
|
2263
|
+
"skill": {
|
|
2264
|
+
"id": SKILL_ID,
|
|
2265
|
+
"version": version,
|
|
2266
|
+
"description": skill_description(),
|
|
2267
|
+
"execution_mode": "local",
|
|
2268
|
+
"kind": "execution",
|
|
2269
|
+
"entrypoints": {
|
|
2270
|
+
"cli": "python3 scripts/<tool>.py [args] [--json] [--dry-run]",
|
|
2271
|
+
"mcp": "python3 mcp/server.py (stdio JSON-RPC; tools/list == this tool list)",
|
|
2272
|
+
"contract": "python3 scripts/_contract.py --json | ffmpeg-skill contract --json",
|
|
2273
|
+
"doctor": "python3 scripts/_contract.py doctor --json | ffmpeg-skill doctor --json",
|
|
2274
|
+
},
|
|
2275
|
+
"not_provided": ["AI reasoning", "decisions", "production plans", "project IR", "approvals", "network access", "transcription engine"],
|
|
2276
|
+
},
|
|
2277
|
+
"requirements": {"python": ">=3.10 (standard library only)", "ffmpeg": ">=6.1", "ffprobe": ">=6.1", "node": ">=16 (npx installer only)"},
|
|
2278
|
+
"execution": {
|
|
2279
|
+
"shell": False,
|
|
2280
|
+
"arbitrary_executables": False,
|
|
2281
|
+
"subprocess": "argv list only: [python3, scripts/<tool>.py, ...] and [ffmpeg|ffprobe, ...] resolved from PATH; "
|
|
2282
|
+
"with --transcribe, a local speech engine's CLI (whisper.cpp's whisper-cli / whisper-cpp / main, "
|
|
2283
|
+
"openai-whisper's whisper, parakeet-mlx, parakeet-cli) resolved from PATH",
|
|
2284
|
+
"network": False,
|
|
2285
|
+
# `network` is about the skill's own code. A speech engine may fetch its model weights the
|
|
2286
|
+
# first time it runs; faster-whisper is a library, so its fetch is made from the skill's own
|
|
2287
|
+
# process. A caller that sandboxes the network must know that before a first --transcribe.
|
|
2288
|
+
"model_downloads": {
|
|
2289
|
+
"when": "first use of a speech engine (--transcribe; silence.py --transcribe, with --filler or a sentence flag, runs it under --dry-run too, caption.py --transcribe does not) whose model is not cached yet; media is never uploaded",
|
|
2290
|
+
"in_process": {"faster-whisper": "Hugging Face (Systran/faster-whisper-<model>)"},
|
|
2291
|
+
"child_process": {"parakeet-mlx": "Hugging Face (mlx-community/parakeet-*)",
|
|
2292
|
+
"openai-whisper": "OpenAI (its model checkpoint)"},
|
|
2293
|
+
"none": ["whisper.cpp", "parakeet.cpp"],
|
|
2294
|
+
"offline": "HF_HUB_OFFLINE=1 keeps faster-whisper and parakeet-mlx on the cached copy",
|
|
2295
|
+
},
|
|
2296
|
+
"input_mutation": False,
|
|
2297
|
+
},
|
|
2298
|
+
"invocation": {
|
|
2299
|
+
"structured": {
|
|
2300
|
+
"canonical": True,
|
|
2301
|
+
"transports": ["cli", "mcp"],
|
|
2302
|
+
"argument_mapping": {
|
|
2303
|
+
"positional": "listed in input_schema.positional, in order; array values expand to several arguments; when any of them starts with '-', all of them follow '--' after every option, so none is read as an option",
|
|
2304
|
+
"options": "key -> --key with '_' replaced by '-'; booleans are flags; arrays repeat the flag; input_schema.properties[key].cli lists the accepted spellings; a value starting with '-' is one token, --long-flag=value (\"-50%\" is text, not an option)",
|
|
2305
|
+
"exceptions": "per tool in mcp.argument_exceptions (key -> flag), e.g. output -> -o, loudness.lufs -> -I, graphics.count_from -> --from",
|
|
2306
|
+
"json": "--json is appended for every tool except look and probe (probe prints JSON by default)",
|
|
2307
|
+
},
|
|
2308
|
+
},
|
|
2309
|
+
"raw_argv": {"canonical": False, "transports": ["mcp"], "note": "MCP tools also accept {\"argv\": [...]} for CLI compatibility; it is still bound to the named script, never a shell"},
|
|
2310
|
+
},
|
|
2311
|
+
"roles": ROLES,
|
|
2312
|
+
"idempotency_hints": IDEMPOTENCY,
|
|
2313
|
+
"verification_policy": {
|
|
2314
|
+
"probe_first": "run ffmpeg-skill/probe on every input before planning",
|
|
2315
|
+
"verify_last": "run the tools named in each ToolSpec.verification after it wrote an artifact",
|
|
2316
|
+
"visual": "when requires_visual_verification is true, run ffmpeg-skill/look on the output and inspect the PNG",
|
|
2317
|
+
"audio_only": "audio-only inputs and audio-only tools never need ffmpeg-skill/look",
|
|
2318
|
+
"check_rows": "ffmpeg-skill/check rows carry kind=format (fix) or kind=judgement (decide with the user), and basis=requirement (can FAIL) or basis=guidance (the platform table's upload length/size limit: WARN at most, the uploader checks the current limit)",
|
|
2319
|
+
},
|
|
2320
|
+
"json_output": {
|
|
2321
|
+
"success": {"status": "completed", "exit_code": 0, "stdout": "one JSON document (output_schema)"},
|
|
2322
|
+
"failure": {"status": "failed", "exit_code": "non-zero (127 when ffmpeg/ffprobe is missing)", "stdout": "{\"status\": \"failed\", \"exit_code\": N, \"error\": {\"kind\": ..., \"message\": ..., \"code\": ..., \"retryable\": false}, \"commands\": [...]} when --json was given; a refusal adds error.reason (error_reasons) and error.details (the facts the message is written from), and a run that recorded warnings, fallbacks or skipped steps before failing carries diagnostics", "stderr": "human-readable message",
|
|
2323
|
+
"error": {"kind": "error_kinds", "message": "the reason in prose", "code": "a static relabelling of kind", "retryable": "always false",
|
|
2324
|
+
"hint": "optional: the flag change that would make a retry meaningful",
|
|
2325
|
+
"reason": "optional, on refusals: a stable code from error_reasons",
|
|
2326
|
+
"details": "optional, with reason: an object of the facts behind the refusal (paths, expected and actual values)"},
|
|
2327
|
+
"diagnostics": DIAGNOSTICS_SCHEMA["description"]},
|
|
2328
|
+
"error_reasons": ERROR_REASONS,
|
|
2329
|
+
"diagnostic_codes": {code: {"bucket": bucket, "meaning": meaning} for code, (bucket, meaning) in DIAGNOSTIC_CODES.items()},
|
|
2330
|
+
"audit_log": {"format": "JSON lines, appended: {ts, tool, event, pid, plan_sha256 (plan events), details}",
|
|
2331
|
+
"events": {"plan_rejected": "render.py refused a plan (details: the refusal's error.details plus reason)",
|
|
2332
|
+
"lock_takeover": "a stale output lock was taken over (details: lock, output, pid, pid_alive, deadline, why)",
|
|
2333
|
+
"output_unlocked": "no output lock could be created and the run went on without one",
|
|
2334
|
+
"output_is_input_refused": "the output-is-input refusal (only when an audit log was named)",
|
|
2335
|
+
"cache_entry_damaged": "render.py --cache: a damaged entry (details: stage, reason, key, sidecar or artifact, sizes)",
|
|
2336
|
+
"batch_cache_reset": "batch.py: .ffskill_cache.json did not parse and was started empty (details: path, size, error)"},
|
|
2337
|
+
"location": "render.py --audit-log FILE when given; otherwise a refused plan's <plan>.audit.jsonl, a lock event's "
|
|
2338
|
+
"hidden .<output>.ffskill-audit.jsonl beside the output, and a cache event's .ffskill-audit.jsonl in the "
|
|
2339
|
+
"cache directory (render.py --cache DIR) or the batch's output_dir. Never written under --dry-run; a write that "
|
|
2340
|
+
"fails is a diagnostics.warnings entry (audit_log_unwritable), never a failure"},
|
|
2341
|
+
"error_kinds": {"input": "missing or unsuitable input, bad arguments", "ffmpeg": "ffmpeg/ffprobe returned an error (message carries the last stderr lines)", "output": "ffmpeg exited 0 but the artifact is missing, empty or unreadable (an empty file is removed)", "missing_tool": "something the run needs is not installed: ffmpeg or ffprobe not on PATH, or older than the supported 6.1 (error.reason ffmpeg_unsupported) (both exit 127); an encoder this build lacks for --codec, an export.py preset or an alpha line (encoder_missing); the libvpx-vp9 decoder for a VP9 source with an alpha layer (decoder_missing); no local speech-to-text engine for --transcribe (asr_engine_missing), or a named --engine that is not installed (these exit 1)","timeout": "one ffmpeg/ffprobe run exceeded --timeout (default 1800 s, FFMPEG_SKILL_TIMEOUT; verify.py's --timeout is per step, default 600 s) and was killed; partial output removed; exit 124", "verification": "the tool ran but its result failed the requested check: check.py platform rows (checks attached), render.py's check stage (output written, check attached), a render.py --template social pack with a destination that failed (pack rows attached; a destination that timed out or was interrupted gives that kind instead), batch.py items (results attached), verify.py steps (files attached), color.py --retag (output written, but ffprobe does not read the requested colour tags on it), loudness.py (output written, its true peak still above --tp after the re-encodes; result attached), join.py --copy (the stream-copied join does not hold the clips it was given; it is not moved to the output path, verification attached), export.py since 4.0.0 (a single-file video delivery other than GIF missed a required property: steps streams, codec (for an editing master also its profile and pixel format), frame_size, frame_rate, duration or file_size; output kept, verification attached); exit 1", "interrupted": "the tool received SIGINT or SIGTERM: the running ffmpeg (or sibling script) was stopped and its partial output removed; exit 130 or 143"},
|
|
2342
|
+
"success_criterion": "exit 0 AND the output exists AND is non-empty AND ffprobe reads a stream from it; only then is status completed printed and the output probe attached",
|
|
2343
|
+
},
|
|
2344
|
+
"capabilities": caps,
|
|
2345
|
+
"tools": tools,
|
|
2346
|
+
"provides": capability_provides(),
|
|
2347
|
+
"capability_map": capability_map(tools),
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
|
|
2351
|
+
def main() -> int:
|
|
2352
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
2353
|
+
ap.add_argument("command", nargs="?", choices=["contract", "doctor"], default="contract")
|
|
2354
|
+
ap.add_argument("--json", action="store_true", help="JSON on stdout (the contract is always JSON)")
|
|
2355
|
+
ap.add_argument("--static", action="store_true", help="omit environment detection (available / missing capabilities)")
|
|
2356
|
+
ap.add_argument("--tool", action="append", metavar="NAME",
|
|
2357
|
+
help="only this tool's entry under `tools` (repeatable; `cut` or `cut.py`); every other key is "
|
|
2358
|
+
"unchanged. The whole contract is about 950 KB; with one tool, 55-85 KB")
|
|
2359
|
+
args = ap.parse_args()
|
|
2360
|
+
wanted: List[str] = []
|
|
2361
|
+
for name in args.tool or []:
|
|
2362
|
+
name = name[:-3] if name.endswith(".py") else name
|
|
2363
|
+
if name not in public_tools():
|
|
2364
|
+
ap.error(f"--tool {name}: no such tool (one of: {', '.join(public_tools())})")
|
|
2365
|
+
if name not in wanted:
|
|
2366
|
+
wanted.append(name)
|
|
2367
|
+
if wanted and args.command == "doctor":
|
|
2368
|
+
ap.error("--tool selects from the contract; doctor --json lists every tool under `tools`")
|
|
2369
|
+
if args.command == "doctor":
|
|
2370
|
+
d = doctor()
|
|
2371
|
+
# On stderr in both modes, so `doctor --json`'s stdout stays one JSON document: an
|
|
2372
|
+
# unsupported Python or FFmpeg (also in the document as `unsupported`, and part of `ok`)
|
|
2373
|
+
# and the FFmpeg security advisories (`ffmpeg_security.warnings`, never part of `ok`).
|
|
2374
|
+
for line in d["unsupported"] + d["ffmpeg_security"]["warnings"]:
|
|
2375
|
+
if line:
|
|
2376
|
+
print(line, file=sys.stderr)
|
|
2377
|
+
if args.json:
|
|
2378
|
+
print(json.dumps(d, indent=2, sort_keys=True))
|
|
2379
|
+
else:
|
|
2380
|
+
print(f"ffmpeg-skill {d['version']} (this installed copy; re-run `npx ffmpeg-skill` to refresh it -- copies are not updated automatically)")
|
|
2381
|
+
print(f"python {d['python']}; ffmpeg {d['ffmpeg'] or 'MISSING'}; ffprobe {d['ffprobe'] or 'MISSING'}")
|
|
2382
|
+
print(f"FFmpeg build license {d['ffmpeg_license'] or 'unknown'}")
|
|
2383
|
+
for name in ("ffmpeg", "ffprobe"):
|
|
2384
|
+
if d[f"{name}_source"] == "homebrew-ffmpeg-full":
|
|
2385
|
+
print(f"{name} runs from {d[f'{name}_path']}: Homebrew's keg-only ffmpeg-full, used because the {name} on PATH is the lean formula (no drawtext/subtitles)")
|
|
2386
|
+
# counts, not the full capability list: the names of the ~60 available capabilities
|
|
2387
|
+
# answer no question a caller has (they are in `doctor --json .available` when one
|
|
2388
|
+
# does), while what is MISSING is the whole reason to run doctor (1.11.0 token diet).
|
|
2389
|
+
head = (f"{'ok' if d['ok'] else 'NOT ok'}: {len(d['available'])} capabilities available, "
|
|
2390
|
+
f"{len(d['missing'])} required missing, {len(d['missing_optional'])} optional missing")
|
|
2391
|
+
if d["unknown"]:
|
|
2392
|
+
head += f", {len(d['unknown'])} unknown"
|
|
2393
|
+
print(head)
|
|
2394
|
+
print(f"missing required: {', '.join(d['missing']) or 'none'}")
|
|
2395
|
+
print(f"missing optional: {', '.join(d['missing_optional']) or 'none'}")
|
|
2396
|
+
for name, engine in d["speech_engines"].items():
|
|
2397
|
+
if not engine["usable"]:
|
|
2398
|
+
av = f" (PyAV {engine['av_version']})" if engine.get("av_version") else ""
|
|
2399
|
+
print(f"{name}{av}: {engine['detail']}. {engine['hint']}", file=sys.stderr)
|
|
2400
|
+
if d["unknown"]:
|
|
2401
|
+
print(f"unknown (detection failed, not proven missing): {', '.join(d['unknown'])}")
|
|
2402
|
+
for cap, alt in sorted(d["covered_by"].items()):
|
|
2403
|
+
print(f"{cap} is not in this build; VideoToolbox ({alt[8:]}) encodes in its place (not CRF-equivalent)")
|
|
2404
|
+
not_usable = sorted(name for name, t in d["tools"].items() if t["usable"] != "yes")
|
|
2405
|
+
if not_usable and d["ok"]:
|
|
2406
|
+
print(f"note: overall 'ok' means nothing REQUIRED BY EVERY TOOL is missing -- {len(not_usable)} tool(s) still can't run today: {', '.join(not_usable)} (see doctor --json .tools for why)")
|
|
2407
|
+
gpu = d["gpu_encoders"]
|
|
2408
|
+
if gpu["status"] == "parsed":
|
|
2409
|
+
print(f"GPU-backed encoders in this build: {len(gpu['present'])} (only --hw / FFMPEG_SKILL_HW=1 use one, VideoToolbox on Apple Silicon; names in doctor --json)")
|
|
2410
|
+
print(_fonts_summary_line(d["fonts"]))
|
|
2411
|
+
print("full detail: doctor --json (capability lists, per-tool `usable`, fix hints)")
|
|
2412
|
+
for err in d["errors"]:
|
|
2413
|
+
print(f"detection error: {err}", file=sys.stderr)
|
|
2414
|
+
if d["ok"]:
|
|
2415
|
+
return 0
|
|
2416
|
+
# 1: something required is missing; 2: nothing proven missing but a required capability is unknown
|
|
2417
|
+
# an unsupported Python/FFmpeg is a known failure, like a missing capability (not "unknown")
|
|
2418
|
+
return 1 if d["missing"] or d.get("unsupported") else 2
|
|
2419
|
+
doc = build(detect=not args.static)
|
|
2420
|
+
if wanted:
|
|
2421
|
+
# in the order asked; `provides` and `capability_map` stay whole (a few KB): they map ids
|
|
2422
|
+
# to tools across the skill, which one tool's entry does not change (#467 A220)
|
|
2423
|
+
doc["tools"] = sorted((t for t in doc["tools"] if t["name"] in wanted), key=lambda t: wanted.index(t["name"]))
|
|
2424
|
+
print(json.dumps(doc, indent=2, sort_keys=True, ensure_ascii=False))
|
|
2425
|
+
return 0
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
def _main_to_a_pipe() -> int:
|
|
2429
|
+
"""main(), ending quietly when the reader of stdout has gone (#558): `contract --json | head -40`,
|
|
2430
|
+
README's quick start, closes the pipe after 40 of the document's lines, and print() of the
|
|
2431
|
+
rest raised BrokenPipeError: a traceback and exit 1 for a command that had done its job.
|
|
2432
|
+
stdout is pointed at the null device so the interpreter's own flush at exit finds nothing to
|
|
2433
|
+
report; a reader that left has what it asked for, so the exit code is 0. `doctor` is a check
|
|
2434
|
+
whose exit code is its verdict: a reader that left early does not turn a failed check into a
|
|
2435
|
+
pass, so it is run again with its output discarded and keeps that exit code (review of #636)."""
|
|
2436
|
+
try:
|
|
2437
|
+
code = main()
|
|
2438
|
+
sys.stdout.flush()
|
|
2439
|
+
return code
|
|
2440
|
+
except BrokenPipeError:
|
|
2441
|
+
try:
|
|
2442
|
+
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno())
|
|
2443
|
+
except (OSError, ValueError):
|
|
2444
|
+
pass
|
|
2445
|
+
if "doctor" in sys.argv[1:]:
|
|
2446
|
+
try:
|
|
2447
|
+
return main()
|
|
2448
|
+
except BrokenPipeError:
|
|
2449
|
+
return 1
|
|
2450
|
+
return 0
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
if __name__ == "__main__":
|
|
2454
|
+
sys.exit(_main_to_a_pipe())
|