@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,290 @@
|
|
|
1
|
+
"""drawtext: the option builders (textfile= route, boxborderw form per ffmpeg version), the
|
|
2
|
+
font-name escape and the shaping-library probe that decides drawtext vs libass per script.
|
|
3
|
+
Split out of _common.text in the refactor after 1.17.3; every body is byte-identical.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
from typing import Dict, List, Optional
|
|
12
|
+
from _common.decision import escape_filter_path
|
|
13
|
+
from _common.runner import STATE, _DRAWTEXT_PENDING, _drawtext_tmpdir, ffmpeg_exe, ffmpeg_release, require_tool
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _on_windows() -> bool:
|
|
17
|
+
return os.name == "nt"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _windows_short_path(path: str) -> "Optional[str]":
|
|
21
|
+
"""The 8.3 short form of an existing Windows path, or None (not Windows, the call failed, or
|
|
22
|
+
the volume keeps no short names)."""
|
|
23
|
+
if not _on_windows():
|
|
24
|
+
return None
|
|
25
|
+
try:
|
|
26
|
+
import ctypes
|
|
27
|
+
buf = ctypes.create_unicode_buffer(32768)
|
|
28
|
+
n = ctypes.windll.kernel32.GetShortPathNameW(str(path), buf, len(buf))
|
|
29
|
+
except (OSError, AttributeError, ValueError):
|
|
30
|
+
return None
|
|
31
|
+
return buf.value if 0 < n < len(buf) else None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def drawtext_fontfile(path: str) -> str:
|
|
35
|
+
"""`fontfile=<path>` for drawtext, with a path FreeType can open.
|
|
36
|
+
|
|
37
|
+
drawtext hands the path to FreeType, which opens it with the C runtime's ANSI fopen on
|
|
38
|
+
Windows: measured on the gyan.dev 9.0.2 build, a font under `compat dir ünïcode` fails to
|
|
39
|
+
load (drawtext falls back to fontconfig and the job dies with "could not parse fontconfig
|
|
40
|
+
pattern") while the same file under an ASCII directory loads, spaces and all. A non-ASCII
|
|
41
|
+
path on Windows is therefore given in its 8.3 short form, or, where the volume keeps no
|
|
42
|
+
short names, copied into this run's private drawtext directory under an ASCII name (recorded,
|
|
43
|
+
`font_path_copied`). Elsewhere the path is passed as it is. The original file is what a plan
|
|
44
|
+
binds, never the copy.
|
|
45
|
+
"""
|
|
46
|
+
path = str(path)
|
|
47
|
+
if not _on_windows() or path.isascii() or not os.path.isfile(path):
|
|
48
|
+
# a missing file is left to ffmpeg's own error, as before: there is nothing to copy
|
|
49
|
+
return f"fontfile={escape_filter_path(path)}"
|
|
50
|
+
if os.path.isfile(path) and path not in STATE.plan_inputs:
|
|
51
|
+
STATE.plan_inputs.append(path)
|
|
52
|
+
short = _windows_short_path(path)
|
|
53
|
+
if short and short.isascii():
|
|
54
|
+
return f"fontfile={escape_filter_path(short, bind=False)}"
|
|
55
|
+
import hashlib
|
|
56
|
+
from _common.emit import record_fallback, warn
|
|
57
|
+
tmpdir = _drawtext_tmpdir(create=not STATE.dry_run)
|
|
58
|
+
if not tmpdir.isascii():
|
|
59
|
+
tmpdir = _windows_short_path(tmpdir) or tmpdir
|
|
60
|
+
st = os.stat(path)
|
|
61
|
+
# the path plus size and mtime: a font replaced in place during the run gets a new copy
|
|
62
|
+
key = f"{path}|{st.st_size}|{st.st_mtime_ns}".encode("utf-8")
|
|
63
|
+
name = "font_" + hashlib.sha1(key, usedforsecurity=False).hexdigest()[:16] + os.path.splitext(path)[1].lower()
|
|
64
|
+
copy = os.path.join(tmpdir, name)
|
|
65
|
+
if not copy.isascii():
|
|
66
|
+
warn(f"font: {path} is not an ASCII path and no ASCII copy could be placed; drawtext may "
|
|
67
|
+
"not open it on Windows (move the font to a folder named in ASCII)", "font_path_not_ascii", font=path)
|
|
68
|
+
return f"fontfile={escape_filter_path(path, bind=False)}"
|
|
69
|
+
if not STATE.dry_run and not os.path.exists(copy):
|
|
70
|
+
try:
|
|
71
|
+
shutil.copyfile(path, copy)
|
|
72
|
+
except OSError as e:
|
|
73
|
+
warn(f"font: could not copy {path} to an ASCII path ({e}); drawtext may not open it on "
|
|
74
|
+
"Windows (move the font to a folder named in ASCII)", "font_path_not_ascii", font=path)
|
|
75
|
+
return f"fontfile={escape_filter_path(path, bind=False)}"
|
|
76
|
+
record_fallback(f"font: {path} is not an ASCII path, which drawtext cannot open on Windows; "
|
|
77
|
+
f"drawing with a copy at {copy}", "font_path_copied", font=path, file=copy)
|
|
78
|
+
return f"fontfile={escape_filter_path(copy, bind=False)}"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def drawtext_boxborderw(vertical: int, horizontal: int) -> str:
|
|
82
|
+
"""drawtext's per-side `boxborderw` in its two-value `v|h` form (FFmpeg 6.1+, the floor since
|
|
83
|
+
3.0.0; 2.x gave 5.x and 6.0 the larger single value, which they needed)."""
|
|
84
|
+
return f"{vertical}|{horizontal}"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# --------------------------------------------------------------------------- shaping (1.15)
|
|
88
|
+
# Scripts whose correct rendering needs harfbuzz-class reordering and re-clustering (Indic matras,
|
|
89
|
+
# Thai/Lao mark stacking). drawtext does NOT use harfbuzz even in an --enable-libharfbuzz build, so
|
|
90
|
+
# these come out wrong through drawtext on every build and must go through libass. Arabic and
|
|
91
|
+
# Hebrew are NOT here: drawtext's text_shaping uses fribidi, which does bidi and Arabic joining
|
|
92
|
+
# correctly -- they only join this set on a build compiled without fribidi.
|
|
93
|
+
SHAPING_SCRIPTS = frozenset({"hi", "bn", "ta", "te", "kn", "ml", "gu", "pa", "si", "th", "lo", "km", "my"})
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
BIDI_SCRIPTS = frozenset({"ar", "he"})
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
_SHAPING_BUILD_CACHE: "Dict[str, bool]" = {}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def drawtext_shaping() -> "Dict[str, bool]":
|
|
103
|
+
"""Which shaping libraries THIS ffmpeg was built with, from -buildconf (falling back to the
|
|
104
|
+
`configuration:` line of -version). Cached per process."""
|
|
105
|
+
if _SHAPING_BUILD_CACHE:
|
|
106
|
+
return dict(_SHAPING_BUILD_CACHE)
|
|
107
|
+
text = ""
|
|
108
|
+
exe = ffmpeg_exe("ffmpeg")[0]
|
|
109
|
+
if exe:
|
|
110
|
+
for flag in ("-buildconf", "-version"):
|
|
111
|
+
try:
|
|
112
|
+
proc = subprocess.run([exe, "-hide_banner", flag], stdout=subprocess.PIPE,
|
|
113
|
+
stderr=subprocess.STDOUT, text=True, encoding="utf-8", errors="replace", timeout=10)
|
|
114
|
+
except (subprocess.TimeoutExpired, OSError):
|
|
115
|
+
break
|
|
116
|
+
if proc.returncode == 0 and proc.stdout.strip():
|
|
117
|
+
text = proc.stdout
|
|
118
|
+
break
|
|
119
|
+
_SHAPING_BUILD_CACHE.update({"fribidi": "--enable-libfribidi" in text,
|
|
120
|
+
"harfbuzz": "--enable-libharfbuzz" in text})
|
|
121
|
+
return dict(_SHAPING_BUILD_CACHE)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def shaping_refusal(script: str) -> str:
|
|
125
|
+
"""Why drawtext cannot draw `script` here, as the clause after "<Language> text": on any build
|
|
126
|
+
for the scripts harfbuzz reorders, on this build for Arabic and Hebrew, which a build with
|
|
127
|
+
fribidi draws (#402: both were refused as "on any ffmpeg build")."""
|
|
128
|
+
if script in BIDI_SCRIPTS:
|
|
129
|
+
return ("cannot be shaped by drawtext on this ffmpeg build (it was built without libfribidi, which "
|
|
130
|
+
"drawtext needs for right-to-left order and Arabic joining; a build with it draws this text)")
|
|
131
|
+
return ("cannot be shaped by drawtext on any ffmpeg build (the marks are reordered by harfbuzz, which "
|
|
132
|
+
"drawtext does not use)")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def needs_shaping(script: str) -> bool:
|
|
136
|
+
"""Whether drawtext would render `script` wrongly on this build."""
|
|
137
|
+
if script in SHAPING_SCRIPTS:
|
|
138
|
+
return True
|
|
139
|
+
return script in BIDI_SCRIPTS and not drawtext_shaping()["fribidi"]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def escape_drawtext(text: str) -> str:
|
|
143
|
+
"""Escape a FONT NAME for a single-quoted drawtext option value (`font='<this>'`).
|
|
144
|
+
|
|
145
|
+
Since 1.15 this is no longer the route for drawn TEXT -- use drawtext_text_opts(), which puts
|
|
146
|
+
the text in a file and keeps `\'` and `%` verbatim. It remains the escape for the font-name
|
|
147
|
+
fallback, where the value is a family name that never legitimately contains a quote or a
|
|
148
|
+
percent sign.
|
|
149
|
+
|
|
150
|
+
Every ffmpeg filter-graph special character (`\\ : % , [ ] ;`) needs a backslash escape
|
|
151
|
+
regardless of the surrounding quotes -- the graph parser still splits on an unescaped `,`/`;`
|
|
152
|
+
or ends an option list on an unescaped `:`/`[`/`]` even while "inside" a quoted value. The
|
|
153
|
+
quote character itself has no reliable backslash escape at all: `\\'` and the POSIX shell
|
|
154
|
+
close-insert-reopen trick both parse fine in a simple `-vf` chain but silently corrupt a
|
|
155
|
+
`-filter_complex` chain that uses explicit `[label]` pads (confirmed by rendering the result:
|
|
156
|
+
trailing option names leak into the picture as literal text). `%` has the same problem as far
|
|
157
|
+
as drawtext's own expansion scanner is concerned. Both are therefore dropped here rather than
|
|
158
|
+
escaped -- which is exactly why drawn text no longer comes through this function.
|
|
159
|
+
"""
|
|
160
|
+
text = re.sub(r"[\x00-\x1f\x7f]", "", text)
|
|
161
|
+
return (
|
|
162
|
+
text.replace("'", "")
|
|
163
|
+
.replace("%", "")
|
|
164
|
+
.replace("\\", "\\\\")
|
|
165
|
+
.replace(":", "\\:")
|
|
166
|
+
.replace(",", "\\,")
|
|
167
|
+
.replace("[", "\\[")
|
|
168
|
+
.replace("]", "\\]")
|
|
169
|
+
.replace(";", "\\;")
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# FFmpeg 8.0 rewrote drawtext's line splitter to hand harfbuzz `p - start` bytes after GET_UTF8 had
|
|
174
|
+
# already stepped past the line break, so every line but the last is shaped WITH its newline and
|
|
175
|
+
# the font's .notdef box is drawn at its end (and counted in text_w). 8.0.2 and 8.1.1 measure the
|
|
176
|
+
# length before the step; 8.0, 8.0.1 (Ubuntu 26.04) and 8.1 ship the bug.
|
|
177
|
+
NEWLINE_GLYPH_RELEASES = frozenset({(8, 0, 0), (8, 0, 1), (8, 1, 0)})
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def drawtext_draws_newline_glyph() -> bool:
|
|
181
|
+
"""Whether this build's drawtext draws a box at each line break of a multi-line text (see
|
|
182
|
+
NEWLINE_GLYPH_RELEASES). A git or vendor build without a release number is taken to be fixed:
|
|
183
|
+
the fix is on master, and a guess the other way would reroute every multi-line title."""
|
|
184
|
+
return ffmpeg_release() in NEWLINE_GLYPH_RELEASES
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def is_multiline(text: "Optional[str]") -> bool:
|
|
188
|
+
"""`text` draws as more than one line (the normalisation drawtext_text_opts() applies)."""
|
|
189
|
+
cleaned = (text or "").replace("\r\n", "\n").replace("\r", "\n").rstrip("\n")
|
|
190
|
+
return "\n" in cleaned
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def drawtext_center_align() -> str:
|
|
194
|
+
"""`:text_align=C` for a centred drawtext, so each line of a multi-line label is centred on
|
|
195
|
+
its own (FFmpeg 6.1+, the floor since 3.0.0)."""
|
|
196
|
+
return ":text_align=C"
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def drawtext_clean(text: "Optional[str]") -> str:
|
|
200
|
+
"""The text drawtext_text_opts() writes to its file: `\r\n` and `\r` become `\n`, a tab,
|
|
201
|
+
vertical tab or form feed becomes a space, other control characters are stripped, and trailing
|
|
202
|
+
newlines are dropped (drawtext ignores one trailing newline and draws a second as a blank
|
|
203
|
+
line, which would centre the block half a line too high; a label that is only newlines stays
|
|
204
|
+
as it is)."""
|
|
205
|
+
cleaned = (text or "").replace("\r\n", "\n").replace("\r", "\n")
|
|
206
|
+
cleaned = re.sub(r"[\x00-\x08\x0e-\x1f\x7f]", "", re.sub(r"[\t\x0b\x0c]", " ", cleaned))
|
|
207
|
+
return cleaned.rstrip("\n") or cleaned
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def drawtext_text_opts(text: str, tmpdir: "Optional[str]" = None) -> str:
|
|
211
|
+
r"""`textfile=<path>:expansion=none` for drawtext -- the one route that is provably safe for
|
|
212
|
+
every character on every build shape this repo uses.
|
|
213
|
+
|
|
214
|
+
The filter-graph parser never sees the text at all: only the PATH is parsed, and
|
|
215
|
+
escape_filter_path() already handles that. `expansion=none` switches off drawtext's own
|
|
216
|
+
`%{...}` scanner, which is the reason `%` was unsafe (a bare `\%` logs "Stray %" on one build
|
|
217
|
+
and fails the whole filter chain on another). With the scanner off, `'`, `%`, `:`, `,`, `[`,
|
|
218
|
+
`]`, `;` and `\` all reach the picture verbatim -- 1.15 fixes `overlay.py --text "it's 100%
|
|
219
|
+
done"` losing both characters. A newline is kept (`\r\n` and `\r` become `\n`): drawtext
|
|
220
|
+
draws it as a line break, and graphics.py's wrap puts them there on purpose (stripping them
|
|
221
|
+
ran a wrapped title off both edges of the frame); trailing newlines are dropped. A tab, vertical tab or form
|
|
222
|
+
feed becomes a space, as the wrap measures it; other control characters are stripped (that
|
|
223
|
+
dates from the inline-escape route, where they broke the graph parser).
|
|
224
|
+
|
|
225
|
+
The file is UTF-8, mode 0600, in a private per-run directory (see _drawtext_tmpdir) that is
|
|
226
|
+
removed when the process ends. It is *registered* here and written by run() only if the
|
|
227
|
+
command about to run actually names it, so --dry-run and the ASS route write nothing; a
|
|
228
|
+
printed plan therefore names a path that no longer exists once the run is over, which is the
|
|
229
|
+
same promise every other temp file in this skill makes.
|
|
230
|
+
"""
|
|
231
|
+
cleaned = drawtext_clean(text)
|
|
232
|
+
import hashlib
|
|
233
|
+
name = "t_" + hashlib.sha256(cleaned.encode("utf-8")).hexdigest()[:16] + ".txt"
|
|
234
|
+
if tmpdir is None:
|
|
235
|
+
tmpdir = _drawtext_tmpdir(create=not STATE.dry_run)
|
|
236
|
+
path = os.path.join(tmpdir, name)
|
|
237
|
+
_DRAWTEXT_PENDING[path] = cleaned
|
|
238
|
+
return f"textfile={escape_filter_path(path)}:expansion=none"
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def drawtext_line_metrics(lines: "List[str]", font_opt: str, fontsize: int) -> "List[Optional[Dict[str, float]]]":
|
|
242
|
+
"""Each line's drawtext metrics as this ffmpeg measures it ALONE, on one line, where the
|
|
243
|
+
8.0/8.0.1/8.1.0 newline bug cannot reach it: {w: text_w, top: top_a, bottom: bottom_d, lh},
|
|
244
|
+
None for an empty line (drawtext measures it as no glyphs).
|
|
245
|
+
|
|
246
|
+
The numbers come out of drawtext itself: its y expression print()s them (libavutil's eval
|
|
247
|
+
function, logged at error level), one drawtext per line on a generated one-frame picture --
|
|
248
|
+
no input is read and nothing is written but the line files, in a temporary directory that is
|
|
249
|
+
removed afterwards. It runs under --dry-run too (run_analysis), so a plan places the lines
|
|
250
|
+
where a run does. The y expression is evaluated at configuration and again per frame; the
|
|
251
|
+
last value of each line wins."""
|
|
252
|
+
import tempfile
|
|
253
|
+
from _common.emit import die
|
|
254
|
+
from _common.runner import flush_drawtext_textfiles, run_analysis
|
|
255
|
+
out: "List[Optional[Dict[str, float]]]" = [None] * len(lines)
|
|
256
|
+
with tempfile.TemporaryDirectory(prefix="ffmpeg-skill-measure-") as td:
|
|
257
|
+
chain = []
|
|
258
|
+
for i, line in enumerate(lines):
|
|
259
|
+
if line:
|
|
260
|
+
chain.append(f"drawtext={drawtext_text_opts(line, tmpdir=td)}:{font_opt}:fontsize={fontsize}:x=0:"
|
|
261
|
+
f"y='print({-(1000 + i)},16)+print(text_w,16)+print(top_a,16)+print(bottom_d,16)+print(lh,16)'")
|
|
262
|
+
if not chain:
|
|
263
|
+
return out
|
|
264
|
+
cmd = [require_tool("ffmpeg"), "-hide_banner", "-nostdin", "-v", "error", "-f", "lavfi",
|
|
265
|
+
"-i", "color=c=black:s=16x16:r=1", "-frames:v", "1", "-vf", ",".join(chain), "-f", "null", "-"]
|
|
266
|
+
try:
|
|
267
|
+
flush_drawtext_textfiles(cmd)
|
|
268
|
+
proc = run_analysis(cmd, record=True)
|
|
269
|
+
finally:
|
|
270
|
+
for path in [p for p in _DRAWTEXT_PENDING if p.startswith(td)]:
|
|
271
|
+
del _DRAWTEXT_PENDING[path]
|
|
272
|
+
current, values = None, {} # type: Optional[int], Dict[int, List[float]]
|
|
273
|
+
# 8.x prefixes each value with "[Eval @ 0x...] ", 6.1 prints it bare
|
|
274
|
+
for m in re.finditer(r"^(?:\[Eval @ [^\]]*\] )?(-?[0-9]+(?:\.[0-9]+)?|-?nan|-?inf)\s*$", proc.stderr, re.M):
|
|
275
|
+
try:
|
|
276
|
+
v = float(m.group(1))
|
|
277
|
+
except ValueError:
|
|
278
|
+
continue
|
|
279
|
+
if v <= -1000 and v == int(v):
|
|
280
|
+
current = int(-v) - 1000
|
|
281
|
+
values[current] = []
|
|
282
|
+
elif current is not None:
|
|
283
|
+
values[current].append(v)
|
|
284
|
+
for i, line in enumerate(lines):
|
|
285
|
+
got = values.get(i) if line else None
|
|
286
|
+
if line and (not got or len(got) != 4):
|
|
287
|
+
die("could not measure a line of --text with drawtext (no print() output from ffmpeg)", kind="ffmpeg")
|
|
288
|
+
if got:
|
|
289
|
+
out[i] = {"w": got[0], "top": got[1], "bottom": got[2], "lh": got[3]}
|
|
290
|
+
return out
|