@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,216 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
person_matte.py: CPU-friendly person cutout, freeze-frame sticker, background replacement,
|
|
4
|
+
and text-behind-head layering using rembg (ONNX) / mediapipe + OpenCV + FFmpeg.
|
|
5
|
+
|
|
6
|
+
Modes:
|
|
7
|
+
sticker Freeze a frame, isolate person, add crisp white outline -> transparent PNG
|
|
8
|
+
bg-replace Replace background of a clip using person segmentation -> MP4/MOV
|
|
9
|
+
behind-head Layer an overlay (image or alpha .mov) BEHIND the cut-out speaker -> MP4
|
|
10
|
+
matte Export grayscale alpha matte video for custom compositing in Kdenlive/FFmpeg
|
|
11
|
+
"""
|
|
12
|
+
import argparse
|
|
13
|
+
import os
|
|
14
|
+
import shutil
|
|
15
|
+
import subprocess
|
|
16
|
+
import sys
|
|
17
|
+
import tempfile
|
|
18
|
+
|
|
19
|
+
import cv2
|
|
20
|
+
import numpy as np
|
|
21
|
+
from PIL import Image
|
|
22
|
+
|
|
23
|
+
from _codec import h264_encode_args
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _segment_frame_rembg(frame_bgr: np.ndarray, session) -> np.ndarray:
|
|
27
|
+
from rembg import remove
|
|
28
|
+
rgb = cv2.cvtColor(frame_bgr, cv2.COLOR_BGR2RGB)
|
|
29
|
+
rgba = np.array(remove(Image.fromarray(rgb), session=session))
|
|
30
|
+
return rgba[:, :, 3]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _make_rembg_session(model_name: str):
|
|
34
|
+
from rembg import new_session
|
|
35
|
+
return new_session(model_name)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def make_sticker(
|
|
39
|
+
input_path: str,
|
|
40
|
+
output_path: str,
|
|
41
|
+
time_sec: float = 0.0,
|
|
42
|
+
outline: int = 12,
|
|
43
|
+
model_name: str = "u2net_human_seg",
|
|
44
|
+
) -> None:
|
|
45
|
+
"""Extract a frame at time_sec, cut out the person, add a solid white sticker border."""
|
|
46
|
+
cap = cv2.VideoCapture(input_path)
|
|
47
|
+
if not cap.isOpened():
|
|
48
|
+
sys.exit(f"[ERROR] Cannot open {input_path}")
|
|
49
|
+
cap.set(cv2.CAP_PROP_POS_MSEC, max(0.0, time_sec) * 1000.0)
|
|
50
|
+
ok, frame = cap.read()
|
|
51
|
+
cap.release()
|
|
52
|
+
if not ok:
|
|
53
|
+
sys.exit(f"[ERROR] Failed reading frame at {time_sec}s from {input_path}")
|
|
54
|
+
|
|
55
|
+
session = _make_rembg_session(model_name)
|
|
56
|
+
alpha = _segment_frame_rembg(frame, session)
|
|
57
|
+
mask = (alpha > 127).astype(np.uint8) * 255
|
|
58
|
+
|
|
59
|
+
# Smooth edges slightly then dilate for crisp sticker border
|
|
60
|
+
if outline > 0:
|
|
61
|
+
k = outline * 2 + 1
|
|
62
|
+
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (k, k))
|
|
63
|
+
border_mask = cv2.dilate(mask, kernel)
|
|
64
|
+
border_mask = cv2.GaussianBlur(border_mask, (5, 5), 0)
|
|
65
|
+
else:
|
|
66
|
+
border_mask = mask
|
|
67
|
+
|
|
68
|
+
h, w = frame.shape[:2]
|
|
69
|
+
out_rgba = np.zeros((h, w, 4), dtype=np.uint8)
|
|
70
|
+
# White sticker backing
|
|
71
|
+
out_rgba[:, :, :3] = 255
|
|
72
|
+
out_rgba[:, :, 3] = border_mask
|
|
73
|
+
|
|
74
|
+
# Composite person BGR onto white sticker backing using soft alpha
|
|
75
|
+
fg_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB).astype(np.float32)
|
|
76
|
+
a_fg = (alpha.astype(np.float32) / 255.0)[:, :, None]
|
|
77
|
+
base_rgb = out_rgba[:, :, :3].astype(np.float32)
|
|
78
|
+
out_rgba[:, :, :3] = np.clip(fg_rgb * a_fg + base_rgb * (1.0 - a_fg), 0, 255).astype(np.uint8)
|
|
79
|
+
out_rgba[:, :, 3] = np.maximum(out_rgba[:, :, 3], alpha)
|
|
80
|
+
|
|
81
|
+
Image.fromarray(out_rgba, mode="RGBA").save(output_path)
|
|
82
|
+
print(f"[OK] Sticker saved to {output_path}")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _extract_alpha_video(input_video: str, matte_video: str, model_name: str, every_n: int = 1) -> tuple[float, int, int]:
|
|
86
|
+
"""Compute per-frame person alpha matte (grayscale MP4) on CPU."""
|
|
87
|
+
cap = cv2.VideoCapture(input_video)
|
|
88
|
+
if not cap.isOpened():
|
|
89
|
+
sys.exit(f"[ERROR] Cannot open {input_video}")
|
|
90
|
+
fps = cap.get(cv2.CAP_PROP_FPS) or 30.0
|
|
91
|
+
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
92
|
+
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
93
|
+
|
|
94
|
+
session = _make_rembg_session(model_name)
|
|
95
|
+
tmp_raw = matte_video + ".tmp.avi"
|
|
96
|
+
writer = cv2.VideoWriter(tmp_raw, cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h), isColor=False)
|
|
97
|
+
|
|
98
|
+
idx = 0
|
|
99
|
+
last_alpha = None
|
|
100
|
+
while True:
|
|
101
|
+
ok, frame = cap.read()
|
|
102
|
+
if not ok:
|
|
103
|
+
break
|
|
104
|
+
if idx % every_n == 0 or last_alpha is None:
|
|
105
|
+
last_alpha = _segment_frame_rembg(frame, session)
|
|
106
|
+
last_alpha = cv2.GaussianBlur(last_alpha, (3, 3), 0)
|
|
107
|
+
writer.write(last_alpha)
|
|
108
|
+
idx += 1
|
|
109
|
+
|
|
110
|
+
cap.release()
|
|
111
|
+
writer.release()
|
|
112
|
+
|
|
113
|
+
subprocess.run(
|
|
114
|
+
["ffmpeg", "-y", "-i", tmp_raw, *h264_encode_args(crf=16, preset="fast"), matte_video],
|
|
115
|
+
check=True,
|
|
116
|
+
)
|
|
117
|
+
os.remove(tmp_raw)
|
|
118
|
+
return fps, w, h
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def behind_head(
|
|
122
|
+
input_video: str,
|
|
123
|
+
overlay_path: str,
|
|
124
|
+
output_video: str,
|
|
125
|
+
model_name: str = "u2net_human_seg",
|
|
126
|
+
every_n: int = 1,
|
|
127
|
+
) -> None:
|
|
128
|
+
"""Place an overlay (PNG or alpha .mov) BEHIND the cut-out speaker."""
|
|
129
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
130
|
+
matte = os.path.join(tmp, "matte.mp4")
|
|
131
|
+
_extract_alpha_video(input_video, matte, model_name, every_n=every_n)
|
|
132
|
+
is_image = overlay_path.lower().endswith((".png", ".jpg", ".jpeg", ".webp"))
|
|
133
|
+
in_args = ["-loop", "1", "-i", overlay_path] if is_image else ["-i", overlay_path]
|
|
134
|
+
fc = (
|
|
135
|
+
"[0:v][1:v]overlay=0:0:shortest=1[mid];"
|
|
136
|
+
"[0:v][2:v]alphamerge[fg];"
|
|
137
|
+
"[mid][fg]overlay=0:0:shortest=1[outv]"
|
|
138
|
+
)
|
|
139
|
+
cmd = [
|
|
140
|
+
"ffmpeg", "-y",
|
|
141
|
+
"-i", input_video,
|
|
142
|
+
*in_args,
|
|
143
|
+
"-i", matte,
|
|
144
|
+
"-filter_complex", fc,
|
|
145
|
+
"-map", "[outv]", "-map", "0:a?",
|
|
146
|
+
*h264_encode_args(crf=18, preset="fast"),
|
|
147
|
+
"-c:a", "copy",
|
|
148
|
+
output_video,
|
|
149
|
+
]
|
|
150
|
+
subprocess.run(cmd, check=True)
|
|
151
|
+
print(f"[OK] Behind-head composite saved to {output_video}")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def bg_replace(
|
|
155
|
+
input_video: str,
|
|
156
|
+
bg_path: str,
|
|
157
|
+
output_video: str,
|
|
158
|
+
model_name: str = "u2net_human_seg",
|
|
159
|
+
every_n: int = 1,
|
|
160
|
+
) -> None:
|
|
161
|
+
"""Replace the background behind the cut-out speaker with an image or video."""
|
|
162
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
163
|
+
matte = os.path.join(tmp, "matte.mp4")
|
|
164
|
+
_, w, h = _extract_alpha_video(input_video, matte, model_name, every_n=every_n)
|
|
165
|
+
is_image = bg_path.lower().endswith((".png", ".jpg", ".jpeg", ".webp"))
|
|
166
|
+
bg_args = ["-loop", "1", "-i", bg_path] if is_image else ["-stream_loop", "-1", "-i", bg_path]
|
|
167
|
+
fc = (
|
|
168
|
+
f"[1:v]scale={w}:{h}:force_original_aspect_ratio=increase,crop={w}:{h},setsar=1[bg];"
|
|
169
|
+
"[0:v][2:v]alphamerge[fg];"
|
|
170
|
+
"[bg][fg]overlay=0:0:shortest=1[outv]"
|
|
171
|
+
)
|
|
172
|
+
cmd = [
|
|
173
|
+
"ffmpeg", "-y",
|
|
174
|
+
"-i", input_video,
|
|
175
|
+
*bg_args,
|
|
176
|
+
"-i", matte,
|
|
177
|
+
"-filter_complex", fc,
|
|
178
|
+
"-map", "[outv]", "-map", "0:a?",
|
|
179
|
+
*h264_encode_args(crf=18, preset="fast"),
|
|
180
|
+
"-c:a", "copy",
|
|
181
|
+
output_video,
|
|
182
|
+
]
|
|
183
|
+
subprocess.run(cmd, check=True)
|
|
184
|
+
print(f"[OK] Background-replaced video saved to {output_video}")
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def main() -> None:
|
|
188
|
+
ap = argparse.ArgumentParser(description="Person cutout, sticker, behind-head, and bg-replace tool")
|
|
189
|
+
ap.add_argument("mode", choices=["sticker", "matte", "behind-head", "bg-replace"])
|
|
190
|
+
ap.add_argument("input", help="Input video file")
|
|
191
|
+
ap.add_argument("-o", "--output", required=True, help="Output file (.png for sticker, .mp4 for video)")
|
|
192
|
+
ap.add_argument("--time", type=float, default=0.0, help="Timestamp in seconds (sticker mode)")
|
|
193
|
+
ap.add_argument("--outline", type=int, default=12, help="White sticker border thickness in px")
|
|
194
|
+
ap.add_argument("--overlay", help="Overlay image or alpha .mov (behind-head mode)")
|
|
195
|
+
ap.add_argument("--bg", help="Background image or video (bg-replace mode)")
|
|
196
|
+
ap.add_argument("--model", default="u2net_human_seg", help="rembg model (u2net_human_seg, isnet-general-use, u2net)")
|
|
197
|
+
ap.add_argument("--every-n", type=int, default=1, help="Compute mask every N frames for faster CPU previews")
|
|
198
|
+
args = ap.parse_args()
|
|
199
|
+
|
|
200
|
+
if args.mode == "sticker":
|
|
201
|
+
make_sticker(args.input, args.output, args.time, args.outline, args.model)
|
|
202
|
+
elif args.mode == "matte":
|
|
203
|
+
_extract_alpha_video(args.input, args.output, args.model, args.every_n)
|
|
204
|
+
print(f"[OK] Matte saved to {args.output}")
|
|
205
|
+
elif args.mode == "behind-head":
|
|
206
|
+
if not args.overlay:
|
|
207
|
+
sys.exit("--overlay is required for behind-head mode")
|
|
208
|
+
behind_head(args.input, args.overlay, args.output, args.model, args.every_n)
|
|
209
|
+
elif args.mode == "bg-replace":
|
|
210
|
+
if not args.bg:
|
|
211
|
+
sys.exit("--bg is required for bg-replace mode")
|
|
212
|
+
bg_replace(args.input, args.bg, args.output, args.model, args.every_n)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if __name__ == "__main__":
|
|
216
|
+
main()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
record_demo.py: Automated Playwright browser demo recorder.
|
|
4
|
+
Captures a 1080p video recording of a web app interaction and logs timestamped
|
|
5
|
+
element bounding-box coordinates (zoom_cues.json) for Remotion auto-zoom framing.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
.venv/bin/python pipeline/scripts/record_demo.py https://example.com --out-dir pipeline/work/demo
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import time
|
|
15
|
+
from playwright.sync_api import sync_playwright
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def record_site(url: str, out_dir: str, wait_ms: int = 2500) -> None:
|
|
19
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
20
|
+
cues = []
|
|
21
|
+
start_ts = time.time()
|
|
22
|
+
|
|
23
|
+
with sync_playwright() as p:
|
|
24
|
+
browser = p.chromium.launch(headless=True)
|
|
25
|
+
context = browser.new_context(
|
|
26
|
+
viewport={"width": 1920, "height": 1080},
|
|
27
|
+
record_video_dir=out_dir,
|
|
28
|
+
record_video_size={"width": 1920, "height": 1080},
|
|
29
|
+
)
|
|
30
|
+
page = context.new_page()
|
|
31
|
+
page.goto(url, wait_until="networkidle")
|
|
32
|
+
cues.append({"t": round(time.time() - start_ts, 3), "event": "loaded", "url": url})
|
|
33
|
+
page.wait_for_timeout(wait_ms)
|
|
34
|
+
|
|
35
|
+
# Capture primary interactive target coordinates if available for Remotion zoom cues
|
|
36
|
+
cta = page.locator("a, button").first
|
|
37
|
+
if cta.count() > 0:
|
|
38
|
+
box = cta.bounding_box()
|
|
39
|
+
if box:
|
|
40
|
+
cues.append({
|
|
41
|
+
"t": round(time.time() - start_ts, 3),
|
|
42
|
+
"event": "focus_element",
|
|
43
|
+
"box": box,
|
|
44
|
+
})
|
|
45
|
+
page.wait_for_timeout(1500)
|
|
46
|
+
|
|
47
|
+
video_path = page.video.path() if page.video else None
|
|
48
|
+
context.close()
|
|
49
|
+
browser.close()
|
|
50
|
+
|
|
51
|
+
cues_path = os.path.join(out_dir, "zoom_cues.json")
|
|
52
|
+
with open(cues_path, "w", encoding="utf-8") as f:
|
|
53
|
+
json.dump(cues, f, indent=2)
|
|
54
|
+
|
|
55
|
+
print(f"[OK] Recorded demo video: {video_path}")
|
|
56
|
+
print(f"[OK] Saved Remotion zoom cues: {cues_path}")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def main():
|
|
60
|
+
parser = argparse.ArgumentParser(description="Playwright Demo Recorder for Remotion")
|
|
61
|
+
parser.add_argument("url", help="Target URL or localhost app URL to record")
|
|
62
|
+
parser.add_argument("--out-dir", default="pipeline/work/demo", help="Output directory")
|
|
63
|
+
parser.add_argument("--wait-ms", type=int, default=2500, help="Hold duration after load (ms)")
|
|
64
|
+
args = parser.parse_args()
|
|
65
|
+
record_site(args.url, args.out_dir, args.wait_ms)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
main()
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
whisper_cut.py: Performs speech-aware cuts on raw footage using WhisperX word-level timestamps.
|
|
4
|
+
Usage:
|
|
5
|
+
python3 whisper_cut.py input.mp4 whisperx_output.json output.mp4 [--max-silence 0.4]
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
import json
|
|
10
|
+
import argparse
|
|
11
|
+
import subprocess
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
from _codec import h264_encode_args
|
|
15
|
+
|
|
16
|
+
def parse_keep_intervals(json_path, max_silence=0.4):
|
|
17
|
+
with open(json_path, 'r', encoding='utf-8') as f:
|
|
18
|
+
data = json.load(f)
|
|
19
|
+
|
|
20
|
+
# Flatten words from segments
|
|
21
|
+
words = []
|
|
22
|
+
for seg in data.get('segments', []):
|
|
23
|
+
for w in seg.get('words', []):
|
|
24
|
+
if 'start' in w and 'end' in w:
|
|
25
|
+
words.append((w['start'], w['end'], w.get('word', '')))
|
|
26
|
+
|
|
27
|
+
if not words:
|
|
28
|
+
print("[WARN] No word timestamps found. Falling back to segments.")
|
|
29
|
+
return [(s['start'], s['end']) for s in data.get('segments', [])]
|
|
30
|
+
|
|
31
|
+
intervals = []
|
|
32
|
+
current_start = max(0.0, words[0][0] - 0.08) # slight pre-roll pad
|
|
33
|
+
current_end = words[0][1]
|
|
34
|
+
|
|
35
|
+
for i in range(1, len(words)):
|
|
36
|
+
start, end, _ = words[i]
|
|
37
|
+
silence_gap = start - current_end
|
|
38
|
+
if silence_gap > max_silence:
|
|
39
|
+
# End current chunk with slight post-roll
|
|
40
|
+
intervals.append((current_start, current_end + 0.08))
|
|
41
|
+
current_start = max(0.0, start - 0.08)
|
|
42
|
+
current_end = end
|
|
43
|
+
else:
|
|
44
|
+
current_end = max(current_end, end)
|
|
45
|
+
|
|
46
|
+
intervals.append((current_start, current_end + 0.08))
|
|
47
|
+
return intervals
|
|
48
|
+
|
|
49
|
+
def cut_and_concat(input_video, intervals, output_video):
|
|
50
|
+
if not intervals:
|
|
51
|
+
print("[ERROR] No valid intervals to cut.")
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
|
|
54
|
+
work_dir = os.path.dirname(output_video) or "."
|
|
55
|
+
list_file = os.path.join(work_dir, "concat_list.txt")
|
|
56
|
+
|
|
57
|
+
# Generate select filter complex for precise, frame-accurate cutting
|
|
58
|
+
filter_select = []
|
|
59
|
+
filter_aselect = []
|
|
60
|
+
for start, end in intervals:
|
|
61
|
+
filter_select.append(f"between(t,{start:.3f},{end:.3f})")
|
|
62
|
+
filter_aselect.append(f"between(t,{start:.3f},{end:.3f})")
|
|
63
|
+
|
|
64
|
+
v_filter = "+".join(filter_select)
|
|
65
|
+
a_filter = "+".join(filter_aselect)
|
|
66
|
+
|
|
67
|
+
complex_filter = f"[0:v]select='{v_filter}',setpts=N/FRAME_RATE/TB[v];[0:a]aselect='{a_filter}',asetpts=N/SR/TB[a]"
|
|
68
|
+
|
|
69
|
+
cmd = [
|
|
70
|
+
"ffmpeg", "-y", "-i", input_video,
|
|
71
|
+
"-filter_complex", complex_filter,
|
|
72
|
+
"-map", "[v]", "-map", "[a]",
|
|
73
|
+
*h264_encode_args(crf=18, preset="fast"),
|
|
74
|
+
"-c:a", "aac", "-b:a", "192k",
|
|
75
|
+
output_video
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
print(f"[INFO] Running FFmpeg cut with {len(intervals)} intervals...")
|
|
79
|
+
res = subprocess.run(cmd)
|
|
80
|
+
if res.returncode == 0:
|
|
81
|
+
print(f"[OK] Rough cut saved to: {output_video}")
|
|
82
|
+
else:
|
|
83
|
+
print(f"[ERROR] FFmpeg failed with exit code {res.returncode}")
|
|
84
|
+
sys.exit(res.returncode)
|
|
85
|
+
|
|
86
|
+
def main():
|
|
87
|
+
parser = argparse.ArgumentParser(description="Speech-aware cut generator from WhisperX JSON")
|
|
88
|
+
parser.add_argument("input_video", help="Path to input raw footage (MP4/MOV)")
|
|
89
|
+
parser.add_argument("json_file", help="Path to WhisperX output JSON file")
|
|
90
|
+
parser.add_argument("output_video", help="Path for rendered cut output")
|
|
91
|
+
parser.add_argument("--max-silence", type=float, default=0.4, help="Max silence allowed between words (seconds)")
|
|
92
|
+
|
|
93
|
+
args = parser.parse_args()
|
|
94
|
+
intervals = parse_keep_intervals(args.json_file, args.max_silence)
|
|
95
|
+
cut_and_concat(args.input_video, intervals, args.output_video)
|
|
96
|
+
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
main()
|