@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,11 @@
|
|
|
1
|
+
# Audio cleanup and narration
|
|
2
|
+
|
|
3
|
+
Use FFmpeg to apply a high-pass filter, suppress steady noise, and normalize dialogue. Listen to a short before-and-after sample and measure loudness on the final export.
|
|
4
|
+
|
|
5
|
+
\`\`\`sh
|
|
6
|
+
cleoedits run ffmpeg -- -i pipeline/work/dialogue.wav -af 'highpass=f=80,afftdn=nf=-25,loudnorm=I=-16:TP=-1.5:LRA=11' pipeline/work/clean.wav
|
|
7
|
+
\`\`\`
|
|
8
|
+
|
|
9
|
+
For model-based speech enhancement, select \`clearervoice\` and run a Python script with \`cleoedits run python -- --profile clearervoice path/to/script.py\`. Instantiate \`ClearVoice(task="speech_enhancement", model_names=["MossFormer2_SE_48K"])\`. Let ClearerVoice download its weights on first use.
|
|
10
|
+
|
|
11
|
+
Select \`kokoro\` for local narration. Run a Python script in that profile using \`KPipeline(lang_code="a")\` and write each generated audio segment at 24 kHz. For Edge TTS, choose \`edge-tts\` and use \`cleoedits run edge-tts -- --help\`. For ElevenLabs, choose \`elevenlabs\` and set your own \`ELEVENLABS_API_KEY\` in the environment. Use cloud services with the user's approval and confirm rights for voice cloning.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# FFmpeg edits, rough cuts, and reel effects
|
|
2
|
+
|
|
3
|
+
Probe inputs and decide on the output aspect ratio and delivery format before cutting. Use \`cleoedits run skill-script -- ffmpeg/probe.py --help\` and the same form for the other bundled FFmpeg helpers. For cut, fit, color, captions, loudness, and contact sheets see \`cut.py\`, \`fit.py\`, \`color.py\`, \`caption.py\`, \`loudness.py\`, and \`look.py\`. JSON format presets are in \`../assets/ffmpeg_templates/\`.
|
|
4
|
+
|
|
5
|
+
| Workflow | Profile and runner |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Fast silence cuts | \`quick-cuts\`, then \`cleoedits run auto-editor -- --help\` |
|
|
8
|
+
| Transcript | \`transcription\`, then \`cleoedits run skill-script -- reel_effects/words.py pipeline/raw_footage/take.mp4\` |
|
|
9
|
+
| Aligned word timestamps and retake cuts | \`word-captions\`, then \`cleoedits run whisperx -- --help\` and \`cleoedits run whisper-cut -- --help\` |
|
|
10
|
+
| Talking-head effects | \`reel-effects\`, then \`cleoedits run skill-script -- reel_effects/fx.py --list\` |
|
|
11
|
+
| Face tracking effect | Install \`reel-effects\` and \`reel-tracking\` |
|
|
12
|
+
|
|
13
|
+
For speech-timed effects, select \`transcription\` and correct the generated words JSON before the effect pass. Preview representative frames with the effects runner's \`--still\` option.
|
|
14
|
+
|
|
15
|
+
Use \`ffmpeg -encoders\` to check the available output codecs. If \`libx264\` is missing, check for \`libopenh264\` or install an FFmpeg build with the required encoder. For stabilization, measure drift on a downscaled sample and use the \`vidstabdetect\` then \`vidstabtransform\` passes when available. Match colors by comparing equivalent regions between the reference and source.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# HyperFrames workflows
|
|
2
|
+
|
|
3
|
+
Install the \`hyperframes\` profile and use the starter in \`generators/hyperframes/index.html\`. Use the engine CLI argument help for available formats and render options.
|
|
4
|
+
|
|
5
|
+
\`\`\`sh
|
|
6
|
+
cleoedits run hyperframes -- check --json
|
|
7
|
+
cleoedits run hyperframes -- preview
|
|
8
|
+
cleoedits run hyperframes -- render . --format mov -o ../../pipeline/work/overlay.mov
|
|
9
|
+
\`\`\`
|
|
10
|
+
|
|
11
|
+
The runner executes from \`generators/hyperframes/\`. Put additional compositions in subfolders and give the engine a relative path to that composition. MOV output supports transparent ProRes overlays. Inspect the rendered alpha channel before compositing.
|
|
12
|
+
|
|
13
|
+
Declare a root composition ID, canvas dimensions, and duration. Give timed items the \`clip\` class and start and duration attributes. Register a paused GSAP timeline under the matching ID in \`window.__timelines\`. Animate inner elements using transforms or opacity, use deterministic frame timing, and keep media paths relative to the composition. Use \`snapshot --review\` for a quick visual check.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Editable Kdenlive timelines
|
|
2
|
+
|
|
3
|
+
Install the \`kdenlive\` profile and place the graded video, alpha overlays, and music in stable locations. Build a timeline from the workspace and open it in Kdenlive.
|
|
4
|
+
|
|
5
|
+
\`\`\`sh
|
|
6
|
+
cleoedits run skill-script -- kdenlive_builder.py --aroll pipeline/work/cut.mp4 --out pipeline/work/edit.kdenlive
|
|
7
|
+
cleoedits run kdenlive -- pipeline/work/edit.kdenlive
|
|
8
|
+
\`\`\`
|
|
9
|
+
|
|
10
|
+
Add \`--overlay\`, \`--music\`, and vertical dimensions such as \`--width 1080 --height 1920\` as needed. Repeat \`--aroll\` to assemble multiple clips. Projects retain absolute paths to the input media. Save a separate project file for any agent-generated revision to preserve manual edits.
|
|
11
|
+
|
|
12
|
+
On Linux, \`cleoedits doctor kdenlive-appimage\` checks the optional AppImage renderer. Set \`KDENLIVE_APPIMAGE\` if needed and run \`cleoedits run melt -- --check\` before rendering. Specify the exact inclusive output frame range and verify the first and last frames with FFmpeg. Elsewhere, use Kdenlive's Render dialog.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Motion graphics and visual review
|
|
2
|
+
|
|
3
|
+
Choose a composition engine based on the scene. HyperFrames suits HTML overlays, while Remotion is useful for React-based UI and chart scenes. Browse the bundled motion reference styles under \`../assets/video_styles/\`. Some are style guides for recreating motion with your own content.
|
|
4
|
+
|
|
5
|
+
Use deterministic, frame-driven timing. Make the primary movement easy to follow, give text time to read, and line up sound effects with visible impact frames. Render to an intermediate with alpha if the graphic layers over footage.
|
|
6
|
+
|
|
7
|
+
Make a contact sheet with \`cleoedits run skill-script -- ffmpeg/look.py pipeline/work/draft.mp4 --tiles 6x5\`. Check the opening image, title-safe placement, cropping, and the first frame after each transition. For rapid movement or a compositing problem, inspect a strip of nearby frames at full size.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Motion timing
|
|
2
|
+
|
|
3
|
+
Use a fast ease-out for entrances and a shorter reverse move for exits. Give the lead element the largest move and follow it with subtler supporting elements. Keep compatible movements on one timeline so visual motion and audio cues stay synchronized.
|
|
4
|
+
|
|
5
|
+
Begin scaled entrances near their final size and pair them with opacity. In UI scenes, set the transform origin at the element's trigger or focal point. Avoid animating layout when a transform produces the same motion. Hold the last pose long enough to read and check it at phone size.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Playwright product demo capture
|
|
2
|
+
|
|
3
|
+
Install the \`capture\` profile and record a walkthrough of a page you have permission to capture.
|
|
4
|
+
|
|
5
|
+
\`\`\`sh
|
|
6
|
+
cleoedits run record-demo -- http://localhost:3000 --out-dir pipeline/work/demo
|
|
7
|
+
\`\`\`
|
|
8
|
+
|
|
9
|
+
The recorder saves a browser video and timing cues in the chosen directory. Adapt the action sequence in \`pipeline/scripts/record_demo.py\` for the real walkthrough. Leave natural pauses between actions and capture at the delivery canvas size when possible. Inspect the recording before sharing and crop out any sensitive interface regions. For zoomed walkthroughs use the timestamps and bounding boxes in the output cue file.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Remotion workflows
|
|
2
|
+
|
|
3
|
+
Install the \`remotion\` profile. The runner executes from \`generators/remotion/\`.
|
|
4
|
+
|
|
5
|
+
\`\`\`sh
|
|
6
|
+
cleoedits run remotion -- compositions src/index.ts
|
|
7
|
+
cleoedits run remotion -- studio src/index.ts
|
|
8
|
+
cleoedits run remotion -- render src/index.ts CleoEditsStarter ../../pipeline/exports/starter.mp4
|
|
9
|
+
\`\`\`
|
|
10
|
+
|
|
11
|
+
Create compositions under \`src/\` and register them with unique IDs. Drive animation with \`useCurrentFrame()\`, \`interpolate()\`, and \`spring()\` using the composition FPS. Wait for any media and font assets to load before rendering. Use the \`Caption\` type from \`@remotion/captions\` for aligned words, with times in milliseconds.
|
|
12
|
+
|
|
13
|
+
For UI walkthroughs, pass the capture's \`zoom_cues.json\` as props and interpolate crop, scale, and focus toward the captured bounding boxes. Use a short preview to confirm timing before rendering the full sequence.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kajisho5
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Render a set of positioned text elements as an ASS file, so libass draws them instead of
|
|
3
|
+
drawtext.
|
|
4
|
+
|
|
5
|
+
Private helper (leading underscore): not a tool, no TOOL_META entry, no contract or MCP surface.
|
|
6
|
+
|
|
7
|
+
Why it exists (1.15): drawtext cannot SHAPE. On a build with fribidi it gets bidi and Arabic
|
|
8
|
+
joining right, but it never reorders or re-clusters -- Devanagari matras come out in logical
|
|
9
|
+
order and Thai/Lao marks stack wrongly -- because drawtext does not use harfbuzz even in an
|
|
10
|
+
--enable-libharfbuzz build. libass does. `graphics.py` keeps computing exactly the geometry it
|
|
11
|
+
computed before; only the renderer changes, and only for text that needs it.
|
|
12
|
+
|
|
13
|
+
Each element is a dict:
|
|
14
|
+
|
|
15
|
+
{"text", "x", "y", "size", "color", "font", "bold", "outline", "outline_color",
|
|
16
|
+
"shadow", "align", "start", "end", "fade", "move", "scale_t", "box", "box_color"}
|
|
17
|
+
|
|
18
|
+
`align` is the ASS numpad alignment of (x, y) -- 7 is top-left, 5 centre, 2 bottom-centre -- so
|
|
19
|
+
a centred title needs no text-width measurement at all. `move` is (x1, y1, x2, y2, t1, t2) in
|
|
20
|
+
milliseconds relative to the line's own start; `fade` is (in_ms, out_ms); `scale_t` is
|
|
21
|
+
(t1_ms, t2_ms, percent) for a pop.
|
|
22
|
+
"""
|
|
23
|
+
import re
|
|
24
|
+
from unicodedata import bidirectional
|
|
25
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# One sentinel character stands in drawn text where an emoji was, so the placeholder is inserted
|
|
29
|
+
# AFTER the brace-stripping that keeps caller-supplied text from injecting override commands.
|
|
30
|
+
EMOJI_SENTINEL = "\ue000"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def ass_base_encoding(texts: Iterable[str]) -> int:
|
|
34
|
+
"""Use libass's whole-event bidi layout when the generated style has RTL text."""
|
|
35
|
+
return -1 if any(bidirectional(ch) in ("R", "AL") for text in texts for ch in text) else 1
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def emoji_placeholder(box_px: float, back_alpha: int = 0) -> str:
|
|
39
|
+
r"""The ASS override that reserves exactly `box_px` of advance and draws nothing.
|
|
40
|
+
|
|
41
|
+
Measured, not assumed (1.15 spec, open question 2). U+2588 FULL BLOCK is NOT 1.0 em: its
|
|
42
|
+
advance measured 0.83 em in FreeSans, 0.79 in WenQuanYi Zen Hei and 0.66 in DejaVu Sans,
|
|
43
|
+
IPAPGothic and Loma, so a block reserves the wrong gap in every face this repo resolves.
|
|
44
|
+
The spec's fallback, alpha-hidden figure spaces (U+2007), measured 0.46-0.55 em and only
|
|
45
|
+
quantises the gap to half an em. What IS exact in all five faces is that same alpha-hidden
|
|
46
|
+
whitespace carried by `\fsp` (letter spacing, in script pixels) on a zero-width space: the
|
|
47
|
+
next glyph starts exactly `box_px` later, with no font dependence at all (verified by render,
|
|
48
|
+
including inside a karaoke run, where the placeholder is its own zero-duration \kf segment).
|
|
49
|
+
The text after it gets back exactly what this override changed -- the four alphas (the box
|
|
50
|
+
colour's is `back_alpha`, the Style's own) and a letter spacing of 0, which every Style here
|
|
51
|
+
has. A `\r` did the same and also reset everything before it on the line: the pop's
|
|
52
|
+
\fscx/\t, a per-cue \fs, a cue's <i>/<b> and colour (A69, #457).
|
|
53
|
+
"""
|
|
54
|
+
return "{\\alpha&HFF&\\fsp%.1f}\u200b{\\alpha&H00&\\4a&H%02X&\\fsp0}" % (box_px, int(back_alpha) & 0xFF)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def ass_time(sec: float) -> str:
|
|
58
|
+
cs = int(round(max(0.0, sec) * 100))
|
|
59
|
+
h, rem = divmod(cs, 360000)
|
|
60
|
+
m, rem = divmod(rem, 6000)
|
|
61
|
+
s, cs = divmod(rem, 100)
|
|
62
|
+
return f"{h}:{m:02d}:{s:02d}.{cs:02d}"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def ass_color(hex_rgb: str, alpha: int = 0) -> str:
|
|
66
|
+
h = str(hex_rgb).lstrip("#")
|
|
67
|
+
if len(h) != 6 or any(c not in "0123456789abcdefABCDEF" for c in h):
|
|
68
|
+
raise ValueError(f"colour must be RRGGBB hex, got '{hex_rgb}'")
|
|
69
|
+
return f"&H{alpha:02X}{h[4:6]}{h[2:4]}{h[0:2]}".upper()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def ass_field(name: str) -> str:
|
|
73
|
+
"""A font name or style name for a comma-delimited ASS field: no escape mechanism exists, so
|
|
74
|
+
the delimiters are dropped (the same call caption.py's ass_font_name() makes)."""
|
|
75
|
+
out = "".join(ch for ch in str(name or "") if ord(ch) >= 0x20 and ch not in ",:\\'")
|
|
76
|
+
return out or "Sans"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# After a literal backslash, these characters would start an ASS sequence libass acts on
|
|
80
|
+
# (\N, \n, \h) or an override block (\{ is an escape, so \\{ is ambiguous). A zero-width space
|
|
81
|
+
# between the two breaks the sequence without changing what the reader sees.
|
|
82
|
+
_ASS_AFTER_BACKSLASH = frozenset("Nnh{}")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def ass_escape(text: str) -> str:
|
|
86
|
+
"""Element text for a Dialogue, with every character the user typed still in it.
|
|
87
|
+
|
|
88
|
+
`{` and `}` would open and close an override block -- real style and animation commands
|
|
89
|
+
(\\pos, \\t, \\fscx), so caller-supplied text containing them could reposition, rescale or
|
|
90
|
+
recolour itself and everything after it. libass has escapes for exactly this (`\\{`, `\\}`),
|
|
91
|
+
so 1.15.0 escapes them instead of deleting them: `A {b} c \\ d` now reaches the picture
|
|
92
|
+
verbatim through the ASS route, the way it already did through drawtext. A literal backslash
|
|
93
|
+
needs no escape of its own in libass (`\\\\` renders as TWO backslashes, it is not an escape);
|
|
94
|
+
only a backslash immediately before one of _ASS_AFTER_BACKSLASH is ambiguous, and a
|
|
95
|
+
zero-width space parts them.
|
|
96
|
+
"""
|
|
97
|
+
s = str(text or "")
|
|
98
|
+
out = []
|
|
99
|
+
for i, ch in enumerate(s):
|
|
100
|
+
if ch == "{":
|
|
101
|
+
out.append("\\{")
|
|
102
|
+
elif ch == "}":
|
|
103
|
+
out.append("\\}")
|
|
104
|
+
elif ch == "\n":
|
|
105
|
+
out.append("\\N")
|
|
106
|
+
elif ch == "\\":
|
|
107
|
+
out.append("\\\u200b" if (i + 1 < len(s) and s[i + 1] in _ASS_AFTER_BACKSLASH) else "\\")
|
|
108
|
+
else:
|
|
109
|
+
out.append(ch)
|
|
110
|
+
return "".join(out)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def ass_text(text: str) -> str:
|
|
114
|
+
"""Back-compatible name for ass_escape()."""
|
|
115
|
+
return ass_escape(text)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# --- SRT markup -------------------------------------------------------------------------------
|
|
119
|
+
# The tags ffmpeg's own SRT reader turns into styling (libavcodec/htmlsubtitles.c): <i> <b> <u>
|
|
120
|
+
# <s>, <font color=...>, and a `{\anN}` position block. caption.py's plain --srt route hands the
|
|
121
|
+
# file to ffmpeg, which draws `<i>Hello</i>` in italics; the routes where caption.py writes its own
|
|
122
|
+
# ASS (--animate, --karaoke, an emoji-forced ASS, the tiktok/reels/shorts templates) escaped the
|
|
123
|
+
# same cue and drew the tags as text, and the wrapper measured them as width. Only these tags are
|
|
124
|
+
# markup here: an unknown `<tag>` and every other `{\...}` block stay text, escaped as before
|
|
125
|
+
# (a caption still cannot open \pos or \t from its cue text).
|
|
126
|
+
_SRT_TAG_RE = re.compile(
|
|
127
|
+
r"<\s*(/?)\s*(i|b|u|s)\s*>" # 1, 2: simple style tags
|
|
128
|
+
r"|<\s*font\b([^<>]*)>" # 3: <font ...attributes>
|
|
129
|
+
r"|<\s*/\s*font\s*>" # closing font
|
|
130
|
+
r"|\{\\an([1-9])\}", # 4: position block
|
|
131
|
+
re.IGNORECASE)
|
|
132
|
+
_FONT_COLOR_RE = re.compile(r"""\bcolor\s*=\s*["']?\s*([#\w]+)""", re.IGNORECASE)
|
|
133
|
+
_NAMED_COLORS = {
|
|
134
|
+
"white": "ffffff", "black": "000000", "red": "ff0000", "lime": "00ff00", "green": "008000",
|
|
135
|
+
"blue": "0000ff", "yellow": "ffff00", "cyan": "00ffff", "aqua": "00ffff",
|
|
136
|
+
"magenta": "ff00ff", "fuchsia": "ff00ff", "silver": "c0c0c0", "gray": "808080",
|
|
137
|
+
"grey": "808080", "maroon": "800000", "olive": "808000", "navy": "000080",
|
|
138
|
+
"purple": "800080", "teal": "008080", "orange": "ffa500"}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def srt_markup_tokens(text: str) -> "List[Tuple[bool, str]]":
|
|
142
|
+
"""`text` cut into (is_markup, piece) runs, in order; the pieces concatenate back to `text`."""
|
|
143
|
+
out: "List[Tuple[bool, str]]" = []
|
|
144
|
+
pos = 0
|
|
145
|
+
for m in _SRT_TAG_RE.finditer(text or ""):
|
|
146
|
+
if m.start() > pos:
|
|
147
|
+
out.append((False, text[pos:m.start()]))
|
|
148
|
+
out.append((True, m.group(0)))
|
|
149
|
+
pos = m.end()
|
|
150
|
+
if pos < len(text or ""):
|
|
151
|
+
out.append((False, text[pos:]))
|
|
152
|
+
return out
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def strip_srt_markup(text: str) -> str:
|
|
156
|
+
"""The words a viewer reads: `text` with the SRT markup tags removed."""
|
|
157
|
+
return "".join(piece for markup, piece in srt_markup_tokens(text) if not markup)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def srt_alignment(text: str) -> "Optional[int]":
|
|
161
|
+
"""The `{\\anN}` a cue asks for, or None."""
|
|
162
|
+
for markup, piece in srt_markup_tokens(text):
|
|
163
|
+
m = _SRT_TAG_RE.fullmatch(piece) if markup else None
|
|
164
|
+
if m and m.group(4):
|
|
165
|
+
return int(m.group(4))
|
|
166
|
+
return None
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _font_colour(attrs: str) -> "Optional[str]":
|
|
170
|
+
m = _FONT_COLOR_RE.search(attrs or "")
|
|
171
|
+
if not m:
|
|
172
|
+
return None
|
|
173
|
+
value = m.group(1).lower()
|
|
174
|
+
value = _NAMED_COLORS.get(value, value)
|
|
175
|
+
if value.startswith("0x"):
|
|
176
|
+
value = value[2:]
|
|
177
|
+
value = value.lstrip("#")
|
|
178
|
+
if re.fullmatch(r"[0-9a-f]{6}", value):
|
|
179
|
+
return "&H%s%s%s&" % (value[4:6].upper(), value[2:4].upper(), value[0:2].upper())
|
|
180
|
+
return None # ffmpeg ignores a colour it cannot read (#f00 included); so does this
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _markup_to_ass(tag: str, colours: "List[str]", colour: bool = True) -> str:
|
|
184
|
+
m = _SRT_TAG_RE.fullmatch(tag)
|
|
185
|
+
if not m:
|
|
186
|
+
return ""
|
|
187
|
+
if not colour and not m.group(2) and not m.group(4):
|
|
188
|
+
return "" # a <font> tag where the caller owns the colours (karaoke): dropped
|
|
189
|
+
if m.group(2):
|
|
190
|
+
return "{\\%s%d}" % (m.group(2).lower(), 0 if m.group(1) else 1)
|
|
191
|
+
if m.group(4):
|
|
192
|
+
return "{\\an%s}" % m.group(4)
|
|
193
|
+
if m.group(0).lstrip("< \t").lower().startswith("/"):
|
|
194
|
+
if colours:
|
|
195
|
+
colours.pop()
|
|
196
|
+
return "{\\c%s}" % colours[-1] if colours else "{\\c}"
|
|
197
|
+
colour = _font_colour(m.group(3))
|
|
198
|
+
colours.append(colour or (colours[-1] if colours else ""))
|
|
199
|
+
return "{\\c%s}" % colour if colour else ""
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def ass_escape_markup(text: str, colour: bool = True) -> str:
|
|
203
|
+
"""ass_escape() for cue text that may carry SRT markup: the tags ffmpeg's SRT reader styles
|
|
204
|
+
become the same ASS overrides it writes for them (`<i>` -> `{\\i1}`, `<font color="#ffff00">`
|
|
205
|
+
-> `{\\c&H00FFFF&}`, `{\\an8}` kept), and everything else is escaped exactly as ass_escape()
|
|
206
|
+
escapes it. `colour=False` drops the <font> tags instead: karaoke's highlight IS the primary
|
|
207
|
+
colour, and a cue colour would replace it."""
|
|
208
|
+
out: "List[str]" = []
|
|
209
|
+
colours: "List[str]" = []
|
|
210
|
+
for markup, piece in srt_markup_tokens(text):
|
|
211
|
+
if markup:
|
|
212
|
+
out.append(_markup_to_ass(piece, colours, colour))
|
|
213
|
+
continue
|
|
214
|
+
escaped = ass_escape(piece)
|
|
215
|
+
if escaped.endswith("\\") and not escaped.endswith("\\"):
|
|
216
|
+
escaped += "" # a trailing backslash must not run into the override after it
|
|
217
|
+
out.append(escaped)
|
|
218
|
+
return "".join(out)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def reinsert_srt_markup(marked: str, lines: "Sequence[str]") -> "List[str]":
|
|
222
|
+
"""Put `marked`'s markup back into `lines`, a wrap of strip_srt_markup(marked).
|
|
223
|
+
|
|
224
|
+
A wrap keeps every visible character in order and only turns whitespace into a break (or puts a
|
|
225
|
+
break between two characters), so each tag is anchored to a character: a closing tag right
|
|
226
|
+
after the visible character before it, any other tag right before the visible character after
|
|
227
|
+
it. Lines that do not hold the stripped text in order come back unchanged (markup dropped):
|
|
228
|
+
tags would otherwise land in the wrong word.
|
|
229
|
+
|
|
230
|
+
A tag pair that encloses no visible character (`A<font color=red> </font>B`) has no character
|
|
231
|
+
to anchor to, and the rule above would put its closing tag after A and its opening tag before
|
|
232
|
+
B, colouring B. In a gap between two visible characters that holds such a pair, the tags keep
|
|
233
|
+
their source order instead: those before the pair's closing tag go right after the character
|
|
234
|
+
before the gap, the rest right before the character after it (both at the start of the next
|
|
235
|
+
line when the gap's whitespace became the break)."""
|
|
236
|
+
tokens = srt_markup_tokens(marked)
|
|
237
|
+
if not any(markup for markup, _p in tokens):
|
|
238
|
+
return list(lines)
|
|
239
|
+
# (line, column) of every non-space character of the wrapped lines, in reading order
|
|
240
|
+
slots = [(li, ci) for li, line in enumerate(lines) for ci, ch in enumerate(line) if not ch.isspace()]
|
|
241
|
+
if not slots:
|
|
242
|
+
return list(lines)
|
|
243
|
+
split_at = _empty_pair_splits(tokens)
|
|
244
|
+
inserts: "Dict[Tuple[int, int], List[str]]" = {}
|
|
245
|
+
seen = 0 # non-space visible characters passed so far
|
|
246
|
+
for index, (markup, piece) in enumerate(tokens):
|
|
247
|
+
if not markup:
|
|
248
|
+
for ch in piece:
|
|
249
|
+
if ch.isspace():
|
|
250
|
+
continue
|
|
251
|
+
if seen >= len(slots) or lines[slots[seen][0]][slots[seen][1]] != ch:
|
|
252
|
+
return list(lines)
|
|
253
|
+
seen += 1
|
|
254
|
+
continue
|
|
255
|
+
after_prev = (slots[seen - 1][0], slots[seen - 1][1] + 1) if seen else None
|
|
256
|
+
before_next = slots[seen] if seen < len(slots) else None
|
|
257
|
+
split = split_at.get(seen)
|
|
258
|
+
if split is not None:
|
|
259
|
+
# this gap holds a pair that encloses no visible character: keep the source order
|
|
260
|
+
if after_prev is None or before_next is None:
|
|
261
|
+
key = after_prev or before_next
|
|
262
|
+
elif after_prev[0] != before_next[0]:
|
|
263
|
+
key = before_next
|
|
264
|
+
else:
|
|
265
|
+
key = after_prev if index < split else before_next
|
|
266
|
+
elif piece.lstrip("< \t").startswith("/") and after_prev or before_next is None:
|
|
267
|
+
key = after_prev
|
|
268
|
+
else:
|
|
269
|
+
key = before_next
|
|
270
|
+
inserts.setdefault(key, []).append(piece)
|
|
271
|
+
if seen != len(slots):
|
|
272
|
+
return list(lines)
|
|
273
|
+
out = []
|
|
274
|
+
for li, line in enumerate(lines):
|
|
275
|
+
cols = sorted(ci for (l2, ci) in inserts if l2 == li)
|
|
276
|
+
built, last = "", 0
|
|
277
|
+
for ci in cols:
|
|
278
|
+
built += line[last:ci] + "".join(inserts[(li, ci)])
|
|
279
|
+
last = ci
|
|
280
|
+
out.append(built + line[last:])
|
|
281
|
+
return out
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def _empty_pair_splits(tokens: "Sequence[Tuple[bool, str]]") -> "Dict[int, int]":
|
|
285
|
+
"""For each gap between visible characters (keyed by the number of non-space characters
|
|
286
|
+
before it) that holds a tag pair enclosing none, the token index of the first such pair's
|
|
287
|
+
closing tag."""
|
|
288
|
+
splits: "Dict[int, int]" = {}
|
|
289
|
+
seen = 0
|
|
290
|
+
open_here: "List[str]" = [] # names of the tags opened in the current gap
|
|
291
|
+
for index, (markup, piece) in enumerate(tokens):
|
|
292
|
+
if not markup:
|
|
293
|
+
if piece.strip():
|
|
294
|
+
seen += sum(1 for ch in piece if not ch.isspace())
|
|
295
|
+
open_here = []
|
|
296
|
+
continue
|
|
297
|
+
m = _SRT_TAG_RE.fullmatch(piece)
|
|
298
|
+
if not m or m.group(4):
|
|
299
|
+
continue
|
|
300
|
+
name = (m.group(2) or "font").lower()
|
|
301
|
+
if piece.lstrip("< \t").startswith("/"):
|
|
302
|
+
if name in open_here:
|
|
303
|
+
splits.setdefault(seen, index)
|
|
304
|
+
del open_here[len(open_here) - 1 - open_here[::-1].index(name)]
|
|
305
|
+
else:
|
|
306
|
+
open_here.append(name)
|
|
307
|
+
return splits
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def carry_srt_markup(chunks: "Sequence[str]") -> "List[str]":
|
|
311
|
+
"""Consecutive cues cut from one marked cue, each made to stand alone: a tag still open at the
|
|
312
|
+
end of a piece is closed there and opened again at the start of the next, and the cue's
|
|
313
|
+
`{\\anN}` is repeated on every piece -- the second half of an italic, top-placed cue stays
|
|
314
|
+
italic and at the top."""
|
|
315
|
+
out: "List[str]" = []
|
|
316
|
+
carried: "List[str]" = []
|
|
317
|
+
# the cue's position, wherever in it the {\anN} stands: an earlier piece takes it too
|
|
318
|
+
align = next((a for a in (srt_alignment(c) for c in chunks) if a is not None), None)
|
|
319
|
+
for chunk in chunks:
|
|
320
|
+
lead = "".join(carried)
|
|
321
|
+
if align is not None and srt_alignment(chunk) is None:
|
|
322
|
+
lead = "{\\an%d}" % align + lead
|
|
323
|
+
opened: "List[str]" = list(carried)
|
|
324
|
+
for markup, piece in srt_markup_tokens(chunk):
|
|
325
|
+
if not markup:
|
|
326
|
+
continue
|
|
327
|
+
m = _SRT_TAG_RE.fullmatch(piece)
|
|
328
|
+
if not m or m.group(4):
|
|
329
|
+
continue
|
|
330
|
+
closing = piece.lstrip("< \t").startswith("/")
|
|
331
|
+
name = (m.group(2) or "font").lower()
|
|
332
|
+
if closing:
|
|
333
|
+
for k in range(len(opened) - 1, -1, -1):
|
|
334
|
+
if _tag_name(opened[k]) == name:
|
|
335
|
+
del opened[k]
|
|
336
|
+
break
|
|
337
|
+
else:
|
|
338
|
+
opened.append(piece)
|
|
339
|
+
tail = "".join("</%s>" % _tag_name(t) for t in reversed(opened))
|
|
340
|
+
out.append(lead + chunk + tail)
|
|
341
|
+
carried = opened
|
|
342
|
+
return out
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def _tag_name(tag: str) -> str:
|
|
346
|
+
m = _SRT_TAG_RE.fullmatch(tag)
|
|
347
|
+
return ((m.group(2) if m else None) or "font").lower()
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def text_overlay_ass(elements: Sequence[Dict[str, Any]], *, play_w: int, play_h: int,
|
|
351
|
+
path: str, fonts_dir: Optional[str] = None) -> str:
|
|
352
|
+
"""Write `elements` as an ASS file at `path` and return the path."""
|
|
353
|
+
header = [
|
|
354
|
+
"[Script Info]", "ScriptType: v4.00+", f"PlayResX: {play_w}", f"PlayResY: {play_h}",
|
|
355
|
+
# YCbCr Matrix: None -- the colours are RGB, to be put in the video's own matrix: FFmpeg 8.x's
|
|
356
|
+
# ass filter reads an absent header as BT.601 whatever the picture is tagged (drawn_chain)
|
|
357
|
+
"WrapStyle: 2", "ScaledBorderAndShadow: yes", "YCbCr Matrix: None", "",
|
|
358
|
+
"[V4+ Styles]",
|
|
359
|
+
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, "
|
|
360
|
+
"BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, "
|
|
361
|
+
"BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
|
362
|
+
]
|
|
363
|
+
events: List[str] = []
|
|
364
|
+
for i, el in enumerate(elements):
|
|
365
|
+
name = f"E{i}"
|
|
366
|
+
colour = ass_color(el.get("color", "FFFFFF"))
|
|
367
|
+
outline_colour = ass_color(el.get("outline_color", "000000"))
|
|
368
|
+
box = bool(el.get("box"))
|
|
369
|
+
back = ass_color(el.get("box_color", el.get("outline_color", "000000")),
|
|
370
|
+
int(el.get("box_alpha", 0)))
|
|
371
|
+
header.append(
|
|
372
|
+
f"Style: {name},{ass_field(el.get('font') or 'Sans')},{int(round(el['size']))},"
|
|
373
|
+
f"{colour},{colour},{outline_colour},{back},{-1 if el.get('bold') else 0},0,0,0,"
|
|
374
|
+
f"100,100,0,0,{3 if box else 1},{float(el.get('outline', 0)):.1f},"
|
|
375
|
+
f"{float(el.get('shadow', 0)):.1f},{int(el.get('align', 7))},0,0,0,{ass_base_encoding((el['text'],))}")
|
|
376
|
+
tags = [f"\\an{int(el.get('align', 7))}"]
|
|
377
|
+
move = el.get("move")
|
|
378
|
+
if move:
|
|
379
|
+
x1, y1, x2, y2, t1, t2 = move
|
|
380
|
+
tags.append(f"\\move({x1:.0f},{y1:.0f},{x2:.0f},{y2:.0f},{t1:.0f},{t2:.0f})")
|
|
381
|
+
else:
|
|
382
|
+
tags.append(f"\\pos({el['x']:.0f},{el['y']:.0f})")
|
|
383
|
+
fade = el.get("fade")
|
|
384
|
+
if fade:
|
|
385
|
+
tags.append(f"\\fad({fade[0]:.0f},{fade[1]:.0f})")
|
|
386
|
+
scale_t = el.get("scale_t")
|
|
387
|
+
if scale_t:
|
|
388
|
+
t1, t2, pct = scale_t
|
|
389
|
+
tags.append(f"\\fscx{pct:.0f}\\fscy{pct:.0f}\\t({t1:.0f},{t2:.0f},\\fscx100\\fscy100)")
|
|
390
|
+
events.append(
|
|
391
|
+
f"Dialogue: 0,{ass_time(el['start'])},{ass_time(el['end'])},{name},,0,0,0,,"
|
|
392
|
+
"{" + "".join(tags) + "}" + ass_text(el["text"]).replace(
|
|
393
|
+
EMOJI_SENTINEL, emoji_placeholder(el.get("box_px") or el["size"], int(el.get("box_alpha", 0)))))
|
|
394
|
+
body = "\n".join(header + ["", "[Events]",
|
|
395
|
+
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, "
|
|
396
|
+
"MarginV, Effect, Text"] + events) + "\n"
|
|
397
|
+
with open(path, "w", encoding="utf-8-sig") as fh:
|
|
398
|
+
fh.write(body)
|
|
399
|
+
return path
|