@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,235 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Composite several video clips into one COLSxROWS grid, e.g. a 4x2 wall of
|
|
3
|
+
takes, angles, or A/B renders side by side.
|
|
4
|
+
|
|
5
|
+
Every cell is letterboxed (not stretched) to a common --cell-width/--cell-height
|
|
6
|
+
so clips of different aspect ratios and resolutions line up cleanly. By default
|
|
7
|
+
each cell gets its source filename (extension stripped) burnt into the bottom
|
|
8
|
+
right corner -- --label none turns that off. The grid has no audio unless
|
|
9
|
+
--audio-from picks one input's track to carry through; mixing every clip's
|
|
10
|
+
audio together is rarely what a comparison grid is for, so this tool never
|
|
11
|
+
does it silently.
|
|
12
|
+
|
|
13
|
+
The grid runs only as long as its shortest clip by default, or is padded to
|
|
14
|
+
the longest clip's duration with --pad (each shorter cell holds its last
|
|
15
|
+
frame, and --audio-from's track is padded with silence, out to that length);
|
|
16
|
+
a mismatched frame rate across sources is conformed to --fps first so cells
|
|
17
|
+
stay in sync.
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
python3 grid.py take1.mp4 take2.mp4 take3.mp4 take4.mp4 take5.mp4 take6.mp4 take7.mp4 take8.mp4 --cols 4 --rows 2
|
|
21
|
+
python3 grid.py a.mp4 b.mp4 c.mp4 d.mp4 --cols 2 --rows 2 --label none -o compare.mp4
|
|
22
|
+
python3 grid.py cam1.mp4 cam2.mp4 --cols 2 --rows 1 --audio-from 0 --pad
|
|
23
|
+
"""
|
|
24
|
+
import argparse
|
|
25
|
+
import os
|
|
26
|
+
import sys
|
|
27
|
+
|
|
28
|
+
from _common import add_common, apply_common, aac_args, cfr_args, default_output, die, emit, X264_PRESETS, fmt_secs, \
|
|
29
|
+
as_limited, draws_chroma, drawn_chain, drawtext_text_opts, escape_drawtext, ffmpeg_base, info, mix_color_chains, probe, run, validate_color, video_args
|
|
30
|
+
from _common.fonts import font_choice, record_font_choice
|
|
31
|
+
from _common import drawtext_fontfile # noqa: E402
|
|
32
|
+
from _common import ffmpeg_filters, filter_missing_hint # noqa: E402
|
|
33
|
+
from _common.emit import note, record_fallback # noqa: E402
|
|
34
|
+
from _common.fonts import script_font_for_text # noqa: E402
|
|
35
|
+
from _common.probe import is_still_input, square_pixels, still_loop_args # noqa: E402
|
|
36
|
+
from _common.wrap import text_width_em # noqa: E402
|
|
37
|
+
from _common.emit import input_length # noqa: E402
|
|
38
|
+
from _common.decision import conform_output_t, conform_to_length # noqa: E402
|
|
39
|
+
|
|
40
|
+
LABEL_MARGIN = 10
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _fit_label(stem: str, cell_width: int, font_size: int) -> str:
|
|
44
|
+
"""The label as drawn: `stem` when it fits the cell (less the margin and the box's border on
|
|
45
|
+
each side), else its head with an ellipsis. It is right-aligned, so a label wider than the
|
|
46
|
+
cell used to lose its start off the left edge and show only its tail (#411). The width is the
|
|
47
|
+
averaged advance table's estimate."""
|
|
48
|
+
room = (cell_width - 2 * LABEL_MARGIN - 8) / float(max(1, font_size))
|
|
49
|
+
if text_width_em(stem) <= room:
|
|
50
|
+
return stem
|
|
51
|
+
if room <= 1:
|
|
52
|
+
return stem[:1] # no room for an ellipsis: keep the start, as a shortened label does (#416 review)
|
|
53
|
+
head = stem
|
|
54
|
+
while head and text_width_em(head + "\u2026") > room:
|
|
55
|
+
head = head[:-1]
|
|
56
|
+
return (head.rstrip() + "\u2026") if head else stem[:1]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def main() -> int:
|
|
60
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
61
|
+
ap.add_argument("inputs", nargs="+", help="video clips, filled into the grid left-to-right, top-to-bottom")
|
|
62
|
+
ap.add_argument("-o", "--output", help="output file (default: <first name>_grid.<ext>)")
|
|
63
|
+
ap.add_argument("--cols", type=int, required=True, help="grid columns: the layout is --cols by --rows")
|
|
64
|
+
ap.add_argument("--rows", type=int, required=True, help="grid rows")
|
|
65
|
+
ap.add_argument("--cell-width", type=int, default=480, help="each cell's width in px, must be even (default 480)")
|
|
66
|
+
ap.add_argument("--cell-height", type=int, default=270, help="each cell's height in px, must be even (default 270)")
|
|
67
|
+
ap.add_argument("--fps", type=float, default=30.0, help="output frame rate every cell is conformed to (default 30)")
|
|
68
|
+
ap.add_argument("--label", choices=["auto", "none"], default="auto",
|
|
69
|
+
help="auto (default): burn each cell's filename (extension stripped) into its bottom-right corner; none: no label")
|
|
70
|
+
ap.add_argument("--font", default="DejaVu Sans", help="label font (fontconfig family name, default DejaVu Sans)")
|
|
71
|
+
ap.add_argument("--font-size", type=int, default=16, help="label font size (default 16)")
|
|
72
|
+
ap.add_argument("--font-color", default="white", help="label text colour (default white)")
|
|
73
|
+
ap.add_argument("--pad", action="store_true", help="hold each shorter cell's last frame (and pad --audio-from's track with silence) out to the longest clip's duration, instead of stopping at the shortest")
|
|
74
|
+
ap.add_argument("--audio", "--audio-from", dest="audio_from", type=int, help="0-based index into inputs to take audio from (default: no audio)")
|
|
75
|
+
ap.add_argument("--gap", type=int, default=0, help="gap between cells in px, must be even (default 0, cells touch)")
|
|
76
|
+
ap.add_argument("--pad-color", "--background", dest="background", default="black", help="colour of the gap/pad borders, the pad-color of other tools (default black)")
|
|
77
|
+
ap.set_defaults(crf=18) # --quality's default (the --crf alias was removed in 2.0)
|
|
78
|
+
ap.add_argument("--preset", default="medium", choices=X264_PRESETS, help="x264 preset")
|
|
79
|
+
add_common(ap)
|
|
80
|
+
args = ap.parse_args()
|
|
81
|
+
apply_common(args)
|
|
82
|
+
if args.label == "auto" and ffmpeg_filters() and "drawtext" not in ffmpeg_filters():
|
|
83
|
+
# the labels are the only drawtext in the grid: without the filter (Homebrew's plain
|
|
84
|
+
# ffmpeg) draw the grid unlabelled and say so, as look.py does for its stamps (#394)
|
|
85
|
+
args.label = "none"
|
|
86
|
+
record_fallback("this ffmpeg build has no drawtext filter, so the cells are not labelled "
|
|
87
|
+
"(the same as --label none)", "grid_no_drawtext")
|
|
88
|
+
note("no cell labels: this ffmpeg build has no drawtext filter (" + filter_missing_hint("drawtext") + ")")
|
|
89
|
+
|
|
90
|
+
n = args.cols * args.rows
|
|
91
|
+
if args.cols <= 0 or args.rows <= 0:
|
|
92
|
+
die(f"--cols/--rows must be > 0, got cols={args.cols} rows={args.rows}")
|
|
93
|
+
if n == 1:
|
|
94
|
+
# xstack takes two inputs or more: a 1x1 grid used to reach ffmpeg and fail there (exit 222)
|
|
95
|
+
die("--cols 1 --rows 1 is a single cell; a grid needs at least two (fit.py letterboxes one clip)")
|
|
96
|
+
if len(args.inputs) != n:
|
|
97
|
+
die(f"--cols {args.cols} --rows {args.rows} needs exactly {n} inputs, got {len(args.inputs)}")
|
|
98
|
+
if args.cell_width <= 0 or args.cell_height <= 0:
|
|
99
|
+
die(f"--cell-width/--cell-height must be > 0, got width={args.cell_width} height={args.cell_height}")
|
|
100
|
+
if args.cell_width % 2 or args.cell_height % 2:
|
|
101
|
+
die(f"--cell-width/--cell-height must be even (4:2:0 chroma), got width={args.cell_width} height={args.cell_height}")
|
|
102
|
+
if args.fps <= 0:
|
|
103
|
+
die(f"--fps must be > 0, got {args.fps:g}")
|
|
104
|
+
if args.gap < 0 or args.gap % 2:
|
|
105
|
+
die(f"--gap must be >= 0 and even, got {args.gap}")
|
|
106
|
+
validate_color(args.background, "--background")
|
|
107
|
+
if args.font_color:
|
|
108
|
+
validate_color(args.font_color, "--font-color")
|
|
109
|
+
if args.audio_from is not None and not 0 <= args.audio_from < n:
|
|
110
|
+
die(f"--audio-from {args.audio_from}: must be an input index 0..{n - 1}")
|
|
111
|
+
|
|
112
|
+
metas = [probe(p) for p in args.inputs]
|
|
113
|
+
for p, m in zip(args.inputs, metas):
|
|
114
|
+
if not m.get("video"):
|
|
115
|
+
die(f"{p}: input has no video stream")
|
|
116
|
+
if args.audio_from is not None and not metas[args.audio_from].get("audio"):
|
|
117
|
+
die(f"--audio-from {args.audio_from}: {args.inputs[args.audio_from]} has no audio stream")
|
|
118
|
+
|
|
119
|
+
# a still picture has no length of its own: it lasts as long as the grid (#510). Counted as a
|
|
120
|
+
# clip of 0 s, it made the grid 0 s long, and the run ended in a traceback on the empty file.
|
|
121
|
+
stills = [is_still_input(m) for m in metas]
|
|
122
|
+
if all(stills):
|
|
123
|
+
die("every cell is a still picture, so the grid has no length to take from a clip", kind="input",
|
|
124
|
+
hint="give at least one video cell, or make a clip of a still first (insert.py STILL --duration T)")
|
|
125
|
+
durations = [input_length(m) for m, still in zip(metas, stills) if not still]
|
|
126
|
+
target_duration = max(durations) if args.pad else min(durations)
|
|
127
|
+
durations = [target_duration if still else input_length(m) for m, still in zip(metas, stills)]
|
|
128
|
+
|
|
129
|
+
# each label is drawn with a font that covers its own script, as every other text-drawing tool
|
|
130
|
+
# picks one (through 3.1.3 a Japanese or Thai filename came out as tofu, #411); `font_used` is
|
|
131
|
+
# the first label's choice, and a grid whose labels needed different fonts says so in a note
|
|
132
|
+
stems = [os.path.splitext(os.path.basename(p))[0] for p in args.inputs]
|
|
133
|
+
font_explicit = args.font != ap.get_default("font")
|
|
134
|
+
label_fonts = []
|
|
135
|
+
for stem in (stems if args.label == "auto" else []):
|
|
136
|
+
_sc, script_file, script_family = script_font_for_text(stem, font=args.font, font_explicit=font_explicit)
|
|
137
|
+
label_fonts.append(font_choice(args.font, script_file=script_file, script_family=script_family))
|
|
138
|
+
font_used = label_fonts[0] if label_fonts else font_choice(args.font)
|
|
139
|
+
if args.label == "auto":
|
|
140
|
+
record_font_choice(font_used)
|
|
141
|
+
if len({f.get("file") for f in label_fonts}) > 1:
|
|
142
|
+
note("cell labels drawn with more than one font, by script: "
|
|
143
|
+
+ "; ".join(sorted({str(f.get("family") or f.get("file")) for f in label_fonts})))
|
|
144
|
+
labels = [_fit_label(stem, args.cell_width, args.font_size) for stem in stems]
|
|
145
|
+
cut = [stem for stem, lab in zip(stems, labels) if lab != stem]
|
|
146
|
+
if args.label == "auto" and cut:
|
|
147
|
+
note(f"{len(cut)} cell label(s) wider than the {args.cell_width} px cell at --font-size "
|
|
148
|
+
f"{args.font_size} were shortened from the end with an ellipsis")
|
|
149
|
+
# named after the first cell; a still there would give its own extension (white_grid.png), and
|
|
150
|
+
# the image muxer cannot write the grid's frames to one file name (review of #532)
|
|
151
|
+
output = args.output or default_output(args.inputs[0], "grid", "mp4" if stills[0] else None)
|
|
152
|
+
|
|
153
|
+
cmd = ffmpeg_base()
|
|
154
|
+
for p, still in zip(args.inputs, stills):
|
|
155
|
+
cmd += (still_loop_args(p, target_duration) if still else []) + ["-i", p]
|
|
156
|
+
|
|
157
|
+
colours = [args.background] + ([args.font_color] if args.label == "auto" else [])
|
|
158
|
+
chroma = draws_chroma(colours, None)
|
|
159
|
+
convert = mix_color_chains(metas, None, draws_colour=chroma)
|
|
160
|
+
parts = []
|
|
161
|
+
for i, p in enumerate(args.inputs):
|
|
162
|
+
drawn = [ # (with this colour, with black)
|
|
163
|
+
(f"pad={args.cell_width}:{args.cell_height}:(ow-iw)/2:(oh-ih)/2:color={args.background}",
|
|
164
|
+
f"pad={args.cell_width}:{args.cell_height}:(ow-iw)/2:(oh-ih)/2:color=black"),
|
|
165
|
+
("setsar=1",) * 2,
|
|
166
|
+
]
|
|
167
|
+
if args.pad and durations[i] < target_duration:
|
|
168
|
+
drawn.append((f"tpad=stop_mode=clone:stop_duration={target_duration - durations[i]:.3f}",) * 2)
|
|
169
|
+
elif not args.pad:
|
|
170
|
+
drawn.append((f"trim=duration={target_duration:.3f}",) * 2)
|
|
171
|
+
if args.label == "auto":
|
|
172
|
+
font_file = label_fonts[i]["file"]
|
|
173
|
+
font_opt = drawtext_fontfile(font_file) if font_file else f"font='{escape_drawtext(args.font)}'"
|
|
174
|
+
# the textfile= route every other drawn text takes: escape_drawtext() is for a font name,
|
|
175
|
+
# and dropped an apostrophe or a percent sign from a file name's label (A178)
|
|
176
|
+
drawn.append((f"drawtext={drawtext_text_opts(labels[i])}:{font_opt}:fontsize={args.font_size}:"
|
|
177
|
+
f"fontcolor={args.font_color}:x=w-tw-{LABEL_MARGIN}:y=h-th-{LABEL_MARGIN}:"
|
|
178
|
+
f"box=1:boxcolor=black@0.5:boxborderw=4", "null"))
|
|
179
|
+
gap_r = args.gap if i % args.cols < args.cols - 1 else 0
|
|
180
|
+
gap_b = args.gap if i // args.cols < args.rows - 1 else 0
|
|
181
|
+
if chroma and (gap_r or gap_b):
|
|
182
|
+
drawn.append((f"pad=iw+{gap_r}:ih+{gap_b}:0:0:color={args.background}", f"pad=iw+{gap_r}:ih+{gap_b}:0:0:color=black"))
|
|
183
|
+
# a non-square-pixel clip is squared at its display aspect before it is fitted (#411)
|
|
184
|
+
sq = (square_pixels(metas[i]["video"]) + ",") if square_pixels(metas[i]["video"]) else ""
|
|
185
|
+
chain = f"fps={args.fps:g},{sq}scale={args.cell_width}:{args.cell_height}:force_original_aspect_ratio=decrease,"
|
|
186
|
+
chain += drawn_chain(",".join(c for c, _n in drawn), as_limited(metas[i]), colours, ",".join(n for _c, n in drawn),
|
|
187
|
+
line_meta=None, tag=f"c{i}", labelled=True)
|
|
188
|
+
parts.append(f"[{i}:v]{convert[i]}{chain}[v{i}]")
|
|
189
|
+
|
|
190
|
+
cw, ch = args.cell_width + args.gap, args.cell_height + args.gap
|
|
191
|
+
layout = "|".join(f"{c * cw}_{r * ch}" for r in range(args.rows) for c in range(args.cols))
|
|
192
|
+
parts.append("".join(f"[v{i}]" for i in range(n)) + f"xstack=inputs={n}:layout={layout}:fill={args.background}[out]")
|
|
193
|
+
# The sound ends with the grid, to the sample (#493): padded when its clip is shorter than a
|
|
194
|
+
# --pad grid, trimmed when it is longer. `apad,atrim=duration={:.3f}` and the output's
|
|
195
|
+
# `-t {:.3f}` both cut it to the millisecond (59244 samples at 48 kHz came out as 59232). A dry
|
|
196
|
+
# run's pending input has no rate to count in yet, and keeps the old filter, as audio.py does.
|
|
197
|
+
audio_rate = (metas[args.audio_from]["audio"].get("sample_rate") or 0) if args.audio_from is not None else 0
|
|
198
|
+
conformed = bool(audio_rate and target_duration > 0)
|
|
199
|
+
audio_source = None
|
|
200
|
+
if conformed:
|
|
201
|
+
parts.append(f"[{args.audio_from}:a:0]{conform_to_length(target_duration, audio_rate)}[aout]")
|
|
202
|
+
audio_source = "[aout]"
|
|
203
|
+
elif args.audio_from is not None and args.pad and durations[args.audio_from] < target_duration:
|
|
204
|
+
parts.append(f"[{args.audio_from}:a:0]apad,atrim=duration={target_duration:.3f}[aout]")
|
|
205
|
+
audio_source = "[aout]"
|
|
206
|
+
elif args.audio_from is not None:
|
|
207
|
+
audio_source = f"{args.audio_from}:a:0"
|
|
208
|
+
cmd += ["-filter_complex", ";".join(parts), "-map", "[out]"]
|
|
209
|
+
|
|
210
|
+
if audio_source:
|
|
211
|
+
cmd += ["-map", audio_source]
|
|
212
|
+
# A grid is an 8-bit SDR composite by design (a comparison/contact artefact, not a
|
|
213
|
+
# deliverable); an HDR input is flattened like look.py's contact sheet flattens it. Say so
|
|
214
|
+
# once so the caller is not surprised by the 8-bit output.
|
|
215
|
+
if any((m.get("video") or {}).get("bt2020_or_hdr") for m in metas):
|
|
216
|
+
info("note: an HDR input is composited into an 8-bit SDR grid (grid.py is a comparison artefact); use color.py --to-sdr first for a graded conversion")
|
|
217
|
+
cmd += video_args(None, args.crf, args.preset)
|
|
218
|
+
cmd += cfr_args(None, args.fps)
|
|
219
|
+
if args.audio_from is not None:
|
|
220
|
+
cmd += aac_args()
|
|
221
|
+
else:
|
|
222
|
+
cmd += ["-an"]
|
|
223
|
+
cmd += ["-t", conform_output_t(target_duration, audio_rate) if conformed else f"{target_duration:.3f}", output]
|
|
224
|
+
run(cmd)
|
|
225
|
+
|
|
226
|
+
result = probe(output, role="output")
|
|
227
|
+
v = result["video"]
|
|
228
|
+
info(f"wrote {output} ({fmt_secs(result['duration'])}, {v['width']}x{v['height']}, {args.cols}x{args.rows} grid, "
|
|
229
|
+
f"{n} clips, {'padded to longest' if args.pad else 'stopped at shortest'})")
|
|
230
|
+
emit(output, cols=args.cols, rows=args.rows, clips=n, **({"font_used": font_used} if args.label == "auto" else {}))
|
|
231
|
+
return 0
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if __name__ == "__main__":
|
|
235
|
+
sys.exit(main())
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Turn a still image into a silent, timed video clip.
|
|
3
|
+
|
|
4
|
+
Produces a fixed-duration, constant-frame-rate video from one image -- for
|
|
5
|
+
example a title card, an end slate, or a placeholder to slot into join.py
|
|
6
|
+
alongside real footage. The output has no audio track: pair it with audio.py
|
|
7
|
+
or export.py's own audio handling if the surrounding edit needs sound under
|
|
8
|
+
the still.
|
|
9
|
+
|
|
10
|
+
--width/--height set the output frame size the same way fit.py does: give
|
|
11
|
+
one and the other follows the image's own aspect; give both for an exact
|
|
12
|
+
frame (the image is scaled to fill it, centre-cropping any excess -- never
|
|
13
|
+
distorted). Omit both to keep the image's native size (evened for 4:2:0).
|
|
14
|
+
|
|
15
|
+
--zoom in|out applies a Ken Burns effect: a slow, linear zoom across the
|
|
16
|
+
clip's duration (--zoom-amount sets the end/start zoom factor, default 1.3 =
|
|
17
|
+
30% zoomed in by the end). --pan left|right|up|down drifts the visible
|
|
18
|
+
window across the image while zoomed (ignored, with a warning, if --zoom is
|
|
19
|
+
not also given -- panning needs the extra image area a zoom exposes).
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
python3 insert.py title.png --duration 3
|
|
23
|
+
python3 insert.py slate.jpg --duration 5 --width 1920 --height 1080 --fps 30 -o slate.mp4
|
|
24
|
+
python3 insert.py photo.jpg --duration 6 --zoom in --pan right --width 1920 --height 1080
|
|
25
|
+
"""
|
|
26
|
+
import argparse
|
|
27
|
+
import math
|
|
28
|
+
import sys
|
|
29
|
+
|
|
30
|
+
from _common import still_input_args # noqa: E402
|
|
31
|
+
from _common import add_common, apply_common, default_output, die, emit, ffmpeg_base, info, probe, run, video_args, X264_PRESETS, time_arg, fmt_secs
|
|
32
|
+
from _common.emit import note
|
|
33
|
+
from _common.probe import display_size, square_pixels, square_pixels_note
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def even(n: float) -> int:
|
|
37
|
+
v = int(round(n))
|
|
38
|
+
return v if v % 2 == 0 else v + 1
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main() -> int:
|
|
42
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
43
|
+
ap.add_argument("input", help="still image (PNG/JPG/...)")
|
|
44
|
+
ap.add_argument("-o", "--output", help="output file (default: <name>_insert.mp4)")
|
|
45
|
+
ap.add_argument("--duration", required=True, help="clip duration (seconds or mm:ss)")
|
|
46
|
+
ap.add_argument("--width", type=int, help="output width in px; with --height also given, both are used directly (a size or resolution WxH is --width W --height H)")
|
|
47
|
+
ap.add_argument("--height", type=int, help="output height in px; with --width also given, both are used directly")
|
|
48
|
+
ap.add_argument("--fps", type=float, default=30.0, help="output frame rate (default 30)")
|
|
49
|
+
ap.add_argument("--zoom", choices=["in", "out"], help="Ken Burns: slow linear zoom in or out across the clip")
|
|
50
|
+
ap.add_argument("--zoom-amount", type=float, default=1.3, help="end (zoom in) or start (zoom out) zoom factor, > 1.0 (default 1.3)")
|
|
51
|
+
ap.add_argument("--pan", choices=["left", "right", "up", "down"], help="drift the visible window this direction while zoomed (needs --zoom)")
|
|
52
|
+
ap.set_defaults(crf=18) # --quality's default (the --crf alias was removed in 2.0)
|
|
53
|
+
ap.add_argument("--preset", default="medium", choices=X264_PRESETS, help="x264 preset")
|
|
54
|
+
add_common(ap)
|
|
55
|
+
args = ap.parse_args()
|
|
56
|
+
apply_common(args)
|
|
57
|
+
|
|
58
|
+
target = time_arg(args.duration, "--duration", args.fps)
|
|
59
|
+
if target <= 0:
|
|
60
|
+
die("--duration must be > 0")
|
|
61
|
+
if args.fps <= 0:
|
|
62
|
+
die("--fps must be > 0")
|
|
63
|
+
if args.zoom_amount <= 1.0:
|
|
64
|
+
die(f"--zoom-amount must be > 1.0, got {args.zoom_amount}")
|
|
65
|
+
if args.pan and not args.zoom:
|
|
66
|
+
die("--pan needs --zoom in|out")
|
|
67
|
+
|
|
68
|
+
meta = probe(args.input)
|
|
69
|
+
if not meta.get("video"):
|
|
70
|
+
die("input has no image/video stream")
|
|
71
|
+
if (meta.get("duration") or 0) > 0.5 or meta.get("audio"):
|
|
72
|
+
die(f"{args.input} is a video, not a still image; insert.py animates a still (Ken Burns). "
|
|
73
|
+
f"For a clip use broll.py (cutaway) or cut.py/join.py")
|
|
74
|
+
# the displayed picture: ffmpeg turns an EXIF-rotated still upright on decode (probe reads
|
|
75
|
+
# the Orientation off the decoded frame), and non-square pixels are squared (#411)
|
|
76
|
+
sw, sh = display_size(meta["video"])
|
|
77
|
+
if square_pixels(meta["video"]):
|
|
78
|
+
note(square_pixels_note(meta["video"]))
|
|
79
|
+
ratio = sw / sh
|
|
80
|
+
|
|
81
|
+
if args.width and args.height:
|
|
82
|
+
out_w, out_h = even(args.width), even(args.height)
|
|
83
|
+
elif args.width:
|
|
84
|
+
out_w = even(args.width)
|
|
85
|
+
out_h = even(out_w / ratio)
|
|
86
|
+
elif args.height:
|
|
87
|
+
out_h = even(args.height)
|
|
88
|
+
out_w = even(out_h * ratio)
|
|
89
|
+
else:
|
|
90
|
+
out_w, out_h = even(sw), even(sh)
|
|
91
|
+
|
|
92
|
+
if args.zoom:
|
|
93
|
+
frames = max(1, round(target * args.fps))
|
|
94
|
+
amount = args.zoom_amount
|
|
95
|
+
if args.zoom == "in":
|
|
96
|
+
zexpr = f"if(eq(on,0),1,min(zoom+{(amount - 1) / frames:.8f},{amount:g}))"
|
|
97
|
+
else:
|
|
98
|
+
zexpr = f"if(eq(on,0),{amount:g},max(zoom-{(amount - 1) / frames:.8f},1))"
|
|
99
|
+
pan_x = {
|
|
100
|
+
"left": f"(iw-iw/zoom)*(1-on/{frames})",
|
|
101
|
+
"right": f"(iw-iw/zoom)*on/{frames}",
|
|
102
|
+
}.get(args.pan, "iw/2-(iw/zoom/2)")
|
|
103
|
+
pan_y = {
|
|
104
|
+
"up": f"(ih-ih/zoom)*(1-on/{frames})",
|
|
105
|
+
"down": f"(ih-ih/zoom)*on/{frames}",
|
|
106
|
+
}.get(args.pan, "ih/2-(ih/zoom/2)")
|
|
107
|
+
# zoompan samples from the still at its native resolution; scale it up first so the
|
|
108
|
+
# zoomed-in crop still has real pixels to draw from instead of upscaling blur.
|
|
109
|
+
upscale = max(2, math.ceil(amount * 2))
|
|
110
|
+
vf = [
|
|
111
|
+
f"scale={out_w * upscale}:{out_h * upscale}:force_original_aspect_ratio=increase",
|
|
112
|
+
f"crop={out_w * upscale}:{out_h * upscale}",
|
|
113
|
+
f"zoompan=z='{zexpr}':x='{pan_x}':y='{pan_y}':d={frames}:s={out_w}x{out_h}:fps={args.fps:g}",
|
|
114
|
+
"setsar=1",
|
|
115
|
+
]
|
|
116
|
+
else:
|
|
117
|
+
vf = [
|
|
118
|
+
f"scale={out_w}:{out_h}:force_original_aspect_ratio=increase",
|
|
119
|
+
f"crop={out_w}:{out_h}",
|
|
120
|
+
"setsar=1",
|
|
121
|
+
f"fps={args.fps:g}",
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
if square_pixels(meta["video"]):
|
|
125
|
+
vf.insert(0, square_pixels(meta["video"])) # the scale and crop above size the squared picture
|
|
126
|
+
output = args.output or default_output(args.input, "insert", "mp4")
|
|
127
|
+
cmd = ffmpeg_base() + ["-loop", "1", *still_input_args(args.input), "-i", args.input, "-t", f"{target:.3f}", "-vf", ",".join(vf)]
|
|
128
|
+
# the SDR line, whatever the image is; its RGB (PNG) or BT.601 (JPEG) pixels are converted to
|
|
129
|
+
# the BT.709 that line is tagged with
|
|
130
|
+
cmd += video_args(None, args.crf, args.preset, source=meta)
|
|
131
|
+
cmd += ["-an", output]
|
|
132
|
+
run(cmd)
|
|
133
|
+
|
|
134
|
+
result = probe(output, role="output")
|
|
135
|
+
v = result["video"]
|
|
136
|
+
info(f"wrote {output} ({fmt_secs(result['duration'])}, {v['width']}x{v['height']}, {v['fps']:g}fps)")
|
|
137
|
+
emit(output)
|
|
138
|
+
return 0
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if __name__ == "__main__":
|
|
142
|
+
sys.exit(main())
|