@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,197 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Freeze on one frame for a number of seconds -- an end-card hold, a comedic beat, a pause.
|
|
3
|
+
|
|
4
|
+
--at is the timestamp to freeze (default: the last frame). --hold is how
|
|
5
|
+
long the freeze lasts. --mode insert (default) inserts the hold into the
|
|
6
|
+
clip at --at, pushing everything after it later by --hold seconds; --mode
|
|
7
|
+
extend only works with --at at (or past) the end of the clip and simply
|
|
8
|
+
makes the last frame last --hold seconds longer, without touching anything
|
|
9
|
+
earlier. Audio is silent during the held frame in --mode insert (there is
|
|
10
|
+
no source audio for a frozen moment that didn't exist before); --mode
|
|
11
|
+
extend has no audio to extend either, since it only makes sense at the
|
|
12
|
+
clip's end.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
python3 freeze.py interview.mp4 --hold 2 # hold the last frame 2s longer
|
|
16
|
+
python3 freeze.py sketch.mp4 --at 12.5 --hold 1.5 # 1.5s freeze inserted at 12.5s
|
|
17
|
+
python3 freeze.py outro.mp4 --hold 3 --mode extend # extend only the very end by 3s
|
|
18
|
+
"""
|
|
19
|
+
import argparse
|
|
20
|
+
import sys
|
|
21
|
+
from fractions import Fraction
|
|
22
|
+
|
|
23
|
+
from _common.decision import av_trim, cfr_at_input, cfr_filter, delivered_rate, frame_durations, frame_rate, grid_at_or_after, on_frame, silence_filter, stream_starts, tpad_length
|
|
24
|
+
from _common.runner import with_mapped_chapters
|
|
25
|
+
from _common import add_common, apply_common, aac_args, cfr_args, with_cfr, default_output, die, emit, ffmpeg_base, info, probe, run_keeping_subtitles, video_args, X264_PRESETS, time_arg, fmt_secs, run
|
|
26
|
+
from _common.emit import input_length, refuse_still
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main() -> int:
|
|
30
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
31
|
+
ap.add_argument("input")
|
|
32
|
+
ap.add_argument("-o", "--output", help="output file (default: <name>_freeze.<ext>)")
|
|
33
|
+
ap.add_argument("--at", help="timestamp to freeze: seconds, mm:ss, hh:mm:ss.ms or SMPTE hh:mm:ss:ff (default: the last frame)")
|
|
34
|
+
ap.add_argument("--duration", "--hold", dest="hold", type=float, required=True, help="the duration of the freeze: how long it lasts, in seconds")
|
|
35
|
+
ap.add_argument("--mode", choices=["insert", "extend"], default="insert",
|
|
36
|
+
help="insert (default): hold pushes the rest of the clip later; extend: only valid at/after the clip's end, makes the last frame last longer with nothing pushed")
|
|
37
|
+
ap.set_defaults(crf=18) # --quality's default (the --crf alias was removed in 2.0)
|
|
38
|
+
ap.add_argument("--preset", default="medium", choices=X264_PRESETS, help="x264 preset")
|
|
39
|
+
add_common(ap)
|
|
40
|
+
args = ap.parse_args()
|
|
41
|
+
apply_common(args)
|
|
42
|
+
|
|
43
|
+
if args.hold <= 0:
|
|
44
|
+
die(f"--hold must be > 0, got {args.hold:g}")
|
|
45
|
+
|
|
46
|
+
meta = probe(args.input)
|
|
47
|
+
if not meta.get("video"):
|
|
48
|
+
die("input has no video stream")
|
|
49
|
+
dur = input_length(meta)
|
|
50
|
+
fps = meta["video"].get("fps") or 30.0
|
|
51
|
+
if args.at is not None:
|
|
52
|
+
at = time_arg(args.at, "--at", (meta.get("video") or {}).get("fps"))
|
|
53
|
+
else:
|
|
54
|
+
at = dur
|
|
55
|
+
if at < 0 or at > dur:
|
|
56
|
+
refuse_still(meta, args.input, f"--at {at:g} is past its one frame, which --at 0 holds") # not "0..0.000" (#531)
|
|
57
|
+
die(f"--at {at:g} is outside the clip (0..{dur:.3f})")
|
|
58
|
+
if args.mode == "extend" and at < dur - 0.01:
|
|
59
|
+
die(f"--mode extend needs --at at or after the clip's end ({dur:.3f}), got {at:g}")
|
|
60
|
+
has_audio = bool(meta.get("audio"))
|
|
61
|
+
output = args.output or default_output(args.input, "freeze")
|
|
62
|
+
|
|
63
|
+
# Both streams are cut at the same frame time and shifted by the same constants (#409): the
|
|
64
|
+
# head runs from the first frame, the tail from the first frame at or after --at. Rebasing each
|
|
65
|
+
# stream to its own start moved a sound that starts 0.3 s late 0.279 s early, and a picture that
|
|
66
|
+
# starts 0.1 s late 0.1 s early (147 frames for 150).
|
|
67
|
+
v0 = stream_starts(meta)[0]
|
|
68
|
+
rate = frame_rate(meta) or fps
|
|
69
|
+
if cfr_filter(meta):
|
|
70
|
+
# A VFR source is put on the delivered grid as it is decoded (the graph's cfr_at_input
|
|
71
|
+
# below), and every frame time is on that grid (#523): on the source's own frames the
|
|
72
|
+
# head ended at its last frame's nominal duration, so with --at inside a gap the hold, and
|
|
73
|
+
# everything after it, started the rest of the gap early against the sound, which is cut
|
|
74
|
+
# at --at (56 ms at --at 0.15, 93 ms at --at 2.2 on a 27 fps average clip with gaps from
|
|
75
|
+
# 0.1 and 2.1 s). A hold is then counted in frames of that rate, the rate its frames are
|
|
76
|
+
# cloned at.
|
|
77
|
+
rate = delivered_rate(meta) or rate
|
|
78
|
+
cut_at = grid_at_or_after(on_frame(at, v0, rate), v0, rate) # --at 1.902 is the frame at 1.9019 (#653)
|
|
79
|
+
# no frame at or after --at (no --at holds at the clip's end): the insert tail would be empty
|
|
80
|
+
# and the hold lost, so hold the last frame as --mode extend does (#416 review)
|
|
81
|
+
vend = v0 + (meta["video"].get("duration") or dur - v0)
|
|
82
|
+
holds_end = args.mode == "extend" or cut_at >= vend - 0.5 / rate
|
|
83
|
+
if holds_end:
|
|
84
|
+
# tpad's stop_duration clones the last frame for the given duration; no PTS surgery
|
|
85
|
+
# needed since it only ever appends past the real end.
|
|
86
|
+
vf = with_cfr(f"tpad=stop_mode=clone:stop_duration={args.hold:.3f}", meta)
|
|
87
|
+
cmd = ffmpeg_base() + ["-i", args.input, "-vf", vf, "-map", "0:v:0"]
|
|
88
|
+
if has_audio:
|
|
89
|
+
cmd += ["-map", "0:a:0?", "-af", silence_filter(meta["audio"].get("sample_rate"), tail=args.hold)]
|
|
90
|
+
elif at == 0 or cut_at <= v0 + 1e-6:
|
|
91
|
+
# A freeze at the very start has no preceding "head" segment to hold on to (the
|
|
92
|
+
# split/trim/concat approach below needs a non-empty head, which trim=end=0 can't give
|
|
93
|
+
# it -- ffmpeg fails filtering an empty stream). Symmetric to --mode extend at the other
|
|
94
|
+
# end: tpad's start_duration clones the *first* frame backwards instead.
|
|
95
|
+
vf = f"tpad=start_mode=clone:start_duration={args.hold:.3f}"
|
|
96
|
+
lead = tpad_length(args.hold, meta)
|
|
97
|
+
if cfr_filter(meta):
|
|
98
|
+
# A VFR picture is conformed before the hold, which then clones whole frames of the
|
|
99
|
+
# delivered rate, and the sound waits as long as they last, as a hold inside the clip
|
|
100
|
+
# does (#538). The fps filter after tpad's start pad ended a slot early: tpad passes
|
|
101
|
+
# its input's end on without the pad, and the filter then ends the picture at its last
|
|
102
|
+
# frame's start (134 frames of 135 for --hold 1 on a 27 fps average clip; a 30 fps clip
|
|
103
|
+
# through fps=30 the same, 149 of 150)
|
|
104
|
+
n = max(1, round(args.hold * rate))
|
|
105
|
+
vf, lead = f"{cfr_filter(meta)},tpad=start_mode=clone:start={n}", n / rate
|
|
106
|
+
cmd = ffmpeg_base() + ["-i", args.input, "-vf", vf, "-map", "0:v:0"]
|
|
107
|
+
if has_audio:
|
|
108
|
+
# the sound waits as long as the picture is held: whole frames (tpad_length), as the
|
|
109
|
+
# hold in the middle of a clip pads by the held frames' length
|
|
110
|
+
cmd += ["-map", "0:a:0?", "-af", silence_filter(meta["audio"].get("sample_rate"), lead=lead)]
|
|
111
|
+
else:
|
|
112
|
+
# freeze N frames at `at` by holding on that one source frame for --hold seconds, then
|
|
113
|
+
# resuming the rest of the clip: split the timeline at `at` and hold the remainder's
|
|
114
|
+
# FIRST frame -- the frame shown at `at` -- for --hold seconds (a segment of its own, below).
|
|
115
|
+
# Through 3.1.3 the head's last frame was held, the frame before `at`: at a cut, the last
|
|
116
|
+
# frame of the previous shot (#411).
|
|
117
|
+
n = max(1, round(args.hold * rate))
|
|
118
|
+
# The video hold length is rounded to a whole number of frames (n / fps), but the audio
|
|
119
|
+
# side used to pad by the raw --hold value -- up to half a frame duration off from what
|
|
120
|
+
# the video actually holds for, a permanent A/V drift from this point on. Pad audio by
|
|
121
|
+
# the same, frame-rounded duration the video actually gets.
|
|
122
|
+
actual_hold = n / rate
|
|
123
|
+
# a conformed VFR picture starts at 0 on the graph's clock (cfr_at_input's origin), so its
|
|
124
|
+
# trims are counted from its own start; the sound's stay on the input's clock
|
|
125
|
+
vo = v0 if cfr_filter(meta) else 0.0
|
|
126
|
+
head_v, head_a = av_trim(v0 - vo, cut_at - vo, rate)[0], av_trim(v0, cut_at, rate)[1]
|
|
127
|
+
tail_v, tail_a = av_trim(cut_at - vo, None, rate)[0], av_trim(cut_at, None, rate)[1]
|
|
128
|
+
# The hold is its own segment: the frame at cut_at, cut on the input's clock and cloned to
|
|
129
|
+
# n frames there (tpad's stop clone), then shifted like the tail. From FFmpeg 7.0 setpts
|
|
130
|
+
# leaves its output's frame rate unknown and its frames' durations 0, so the earlier tpad
|
|
131
|
+
# start clone after av_trim's setpts stamped every clone 0 and the hold was dropped (a 3 s
|
|
132
|
+
# freeze came out 1.97 s on 7.1). Cloning before setpts and concatenating the hold before
|
|
133
|
+
# the tail reads the same on every version; the tail's first frame then shows n + 1 times,
|
|
134
|
+
# as tpad's start clone showed it.
|
|
135
|
+
# The held frame is the first frame at or after the cut, whatever its time: on a variable
|
|
136
|
+
# frame rate a nominal one-frame window around cut_at can hold no frame (frames at 0.033
|
|
137
|
+
# and 0.100, --at 0.06), and the hold was lost (#416 review). A second trim keeps that one
|
|
138
|
+
# frame; on a constant rate it is the frame at cut_at, as before.
|
|
139
|
+
half = 0.5 / rate
|
|
140
|
+
# the graph closes on the rate the encoder line delivers (a VFR source is conformed to its
|
|
141
|
+
# average): closed on r_frame_rate, -r then resampled it and the picture ran late (#512)
|
|
142
|
+
hold_v = (f"trim=start={cut_at - vo - half:.6f},trim=end_frame=1,"
|
|
143
|
+
f"tpad=stop_mode=clone:stop={n - 1},setpts=PTS-STARTPTS")
|
|
144
|
+
# Every segment is a whole count of frames on one grid, so the joined picture's timestamps
|
|
145
|
+
# are rebuilt from its running frame count before the closing fps: FFmpeg 6.1.1's video
|
|
146
|
+
# concat gives a one-frame segment no length (it ends a segment at its last frame's
|
|
147
|
+
# timestamp), so a hold of one frame (--hold 0.04 at 30 fps) was dropped and the rest of
|
|
148
|
+
# the picture ran a frame before its sound, as speedramp.py's one-frame segments did
|
|
149
|
+
grid = frame_durations(meta, delivered_rate(meta) or rate)
|
|
150
|
+
q = Fraction(grid[len("fps="):]) if "/" in grid else Fraction(delivered_rate(meta) or rate).limit_denominator(1001)
|
|
151
|
+
vf = (f"[0:v]split=3[a][b][c];[a]{head_v}[head];"
|
|
152
|
+
f"[b]{hold_v}[hold];[c]{tail_v}[tail];"
|
|
153
|
+
f"[head][hold][tail]concat=n=3:v=1:a=0,setpts=N*{q.denominator}/({q.numerator}*TB),{grid}[outv]")
|
|
154
|
+
# the grid is laid from the picture's start (the picture moved to 0 ahead of the fps
|
|
155
|
+
# filter, and the trims above counted from there), on a microsecond time base: laid from
|
|
156
|
+
# the clock's 0, a picture that starts 50 ms in came out a frame early after the hold, and
|
|
157
|
+
# on the fps filter's base of one frame the trim's half-frame bound 3.907407 (--at 3.9)
|
|
158
|
+
# became frame 105 itself, which was cut from the head and held in place of frame 106.
|
|
159
|
+
# It is not moved back after the conform: from FFmpeg 7.0 a setpts leaves its frames no
|
|
160
|
+
# duration and no rate, and the hold's tpad after it cloned nothing (109 frames for 135
|
|
161
|
+
# on 7.1)
|
|
162
|
+
vf = cfr_at_input(vf, meta, origin=v0)
|
|
163
|
+
cmd = ffmpeg_base() + ["-i", args.input, "-filter_complex", vf, "-map", "[outv]"]
|
|
164
|
+
if has_audio:
|
|
165
|
+
af = (f"[0:a]asplit[aa][ab];[aa]{head_a}[ahead];"
|
|
166
|
+
f"[ab]{tail_a}[atail];"
|
|
167
|
+
f"[ahead]apad=pad_dur={actual_hold:.6f}[afrozen];"
|
|
168
|
+
f"[afrozen][atail]concat=n=2:v=0:a=1[outa]")
|
|
169
|
+
cmd = ffmpeg_base() + ["-i", args.input, "-filter_complex", f"{vf};{af}", "-map", "[outv]", "-map", "[outa]"]
|
|
170
|
+
cmd += video_args(meta, args.crf, args.preset)
|
|
171
|
+
cmd += cfr_args(meta)
|
|
172
|
+
if has_audio:
|
|
173
|
+
cmd += aac_args()
|
|
174
|
+
else:
|
|
175
|
+
cmd += ["-an"]
|
|
176
|
+
if not holds_end:
|
|
177
|
+
moved = lead if at == 0 or cut_at <= v0 + 1e-6 else actual_hold
|
|
178
|
+
cmd = with_mapped_chapters(cmd, meta, lambda t: t + moved if t >= cut_at - 1e-6 else t, None) # (#470)
|
|
179
|
+
# the picture gains `hold` seconds at `at`; a stream-copied subtitle track would keep its
|
|
180
|
+
# old timestamps and every cue after the freeze would fire early (same reasoning as
|
|
181
|
+
# fit.py --method speed). Drop it rather than ship captions that lie. A hold of the last
|
|
182
|
+
# frame (the default with no --at, or an --at at the end) moves nothing, so the track is
|
|
183
|
+
# kept as --mode extend keeps it (A180)
|
|
184
|
+
run(cmd + [output])
|
|
185
|
+
dropped_streams = bool(meta.get("subtitle_streams") or meta.get("data_streams"))
|
|
186
|
+
else:
|
|
187
|
+
dropped_streams = run_keeping_subtitles(cmd, output)
|
|
188
|
+
|
|
189
|
+
result = probe(output, role="output")
|
|
190
|
+
v = result["video"]
|
|
191
|
+
info(f"wrote {output} ({fmt_secs(result['duration'])}, {v['width']}x{v['height']}, froze {args.hold:g}s at {at:g}s, mode={args.mode})")
|
|
192
|
+
emit(output, dropped_non_av_streams=dropped_streams)
|
|
193
|
+
return 0
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == "__main__":
|
|
197
|
+
sys.exit(main())
|