videopython 0.59.0__tar.gz → 0.60.1__tar.gz

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.
Files changed (95) hide show
  1. {videopython-0.59.0 → videopython-0.60.1}/PKG-INFO +3 -4
  2. {videopython-0.59.0 → videopython-0.60.1}/pyproject.toml +5 -8
  3. videopython-0.60.1/src/videopython/_exceptions.py +63 -0
  4. {videopython-0.59.0/src/videopython/base → videopython-0.60.1/src/videopython}/_ffmpeg.py +49 -18
  5. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/_revisions.py +7 -6
  6. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/remux.py +2 -2
  7. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/transforms.py +11 -16
  8. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/audio.py +130 -71
  9. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/video_analysis/source_metadata.py +2 -2
  10. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/audio/__init__.py +3 -1
  11. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/audio/audio.py +3 -2
  12. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/__init__.py +10 -18
  13. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/_video_io.py +14 -17
  14. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/video.py +13 -4
  15. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/__init__.py +6 -0
  16. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/audio_ops.py +2 -2
  17. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/effects.py +2 -2
  18. videopython-0.60.1/src/videopython/editing/errors.py +98 -0
  19. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/operation.py +2 -3
  20. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/streaming.py +2 -2
  21. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/transcription_overlay.py +1 -1
  22. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/transforms.py +1 -1
  23. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/video_edit.py +41 -29
  24. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/mcp/server.py +1 -1
  25. videopython-0.59.0/src/videopython/base/exceptions.py +0 -219
  26. {videopython-0.59.0 → videopython-0.60.1}/.gitignore +0 -0
  27. {videopython-0.59.0 → videopython-0.60.1}/LICENSE +0 -0
  28. {videopython-0.59.0 → videopython-0.60.1}/README.md +0 -0
  29. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/__init__.py +0 -0
  30. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/__init__.py +0 -0
  31. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/_device.py +0 -0
  32. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/_ollama.py +0 -0
  33. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/_optional.py +0 -0
  34. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/_predictor.py +0 -0
  35. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/__init__.py +0 -0
  36. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/backend.py +0 -0
  37. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/catalog.py +0 -0
  38. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/editor.py +0 -0
  39. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/local.py +0 -0
  40. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/models.py +0 -0
  41. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/auto_edit/resolve.py +0 -0
  42. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/__init__.py +0 -0
  43. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/_tts_backend.py +0 -0
  44. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/audio_ops.py +0 -0
  45. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/config.py +0 -0
  46. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/dubber.py +0 -0
  47. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/models.py +0 -0
  48. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/pipeline.py +0 -0
  49. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/quality.py +0 -0
  50. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/separation.py +0 -0
  51. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/timing.py +0 -0
  52. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/translation.py +0 -0
  53. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/dubbing/voice_sample.py +0 -0
  54. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/effects.py +0 -0
  55. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/errors.py +0 -0
  56. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/generation/__init__.py +0 -0
  57. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/generation/audio.py +0 -0
  58. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/generation/image.py +0 -0
  59. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/generation/video.py +0 -0
  60. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/keyframe.py +0 -0
  61. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/ops.py +0 -0
  62. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/__init__.py +0 -0
  63. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/_detector.py +0 -0
  64. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/classification.py +0 -0
  65. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/faces.py +0 -0
  66. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/image.py +0 -0
  67. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/objects.py +0 -0
  68. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/understanding/temporal.py +0 -0
  69. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/video_analysis/__init__.py +0 -0
  70. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/video_analysis/analyzer.py +0 -0
  71. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/video_analysis/detectors.py +0 -0
  72. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/video_analysis/models.py +0 -0
  73. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/ai/video_analysis/sampling.py +0 -0
  74. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/audio/analysis.py +0 -0
  75. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/_dimensions.py +0 -0
  76. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/description.py +0 -0
  77. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/draw_detections.py +0 -0
  78. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/Anton-OFL.txt +0 -0
  79. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/Anton-Regular.ttf +0 -0
  80. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/BebasNeue-OFL.txt +0 -0
  81. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/BebasNeue-Regular.ttf +0 -0
  82. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/DejaVuSans.ttf +0 -0
  83. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/LICENSE_DEJAVU +0 -0
  84. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/Lato-Bold.ttf +0 -0
  85. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/Lato-OFL.txt +0 -0
  86. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/Poppins-Bold.ttf +0 -0
  87. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/Poppins-OFL.txt +0 -0
  88. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/fonts/__init__.py +0 -0
  89. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/base/transcription.py +0 -0
  90. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/_ass.py +0 -0
  91. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/_easing.py +0 -0
  92. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/editing/_schema.py +0 -0
  93. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/mcp/__init__.py +0 -0
  94. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/mcp/_models.py +0 -0
  95. {videopython-0.59.0 → videopython-0.60.1}/src/videopython/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: videopython
3
- Version: 0.59.0
3
+ Version: 0.60.1
4
4
  Summary: LLM-friendly Python video editing with JSON plans, local AI, and MCP tools.
5
5
  Project-URL: Homepage, https://videopython.com
6
6
  Project-URL: Repository, https://github.com/bartwojtowicz/videopython/
@@ -28,11 +28,11 @@ Provides-Extra: ai
28
28
  Requires-Dist: accelerate>=0.29.2; extra == 'ai'
29
29
  Requires-Dist: demucs>=4.0.0; extra == 'ai'
30
30
  Requires-Dist: diffusers>=0.35.0; extra == 'ai'
31
+ Requires-Dist: faster-whisper>=1.2.1; extra == 'ai'
31
32
  Requires-Dist: ftfy>=6.1; extra == 'ai'
32
33
  Requires-Dist: imagehash>=4.3; extra == 'ai'
33
34
  Requires-Dist: numba>=0.62; extra == 'ai'
34
35
  Requires-Dist: ollama>=0.5.0; extra == 'ai'
35
- Requires-Dist: openai-whisper>=20240930; extra == 'ai'
36
36
  Requires-Dist: pyannote-audio>=4.0.0; extra == 'ai'
37
37
  Requires-Dist: pyloudnorm>=0.1.1; extra == 'ai'
38
38
  Requires-Dist: silero-vad>=5.1; extra == 'ai'
@@ -44,11 +44,10 @@ Requires-Dist: transformers>=5.2.0; extra == 'ai'
44
44
  Requires-Dist: transnetv2-pytorch>=1.0.5; extra == 'ai'
45
45
  Requires-Dist: videopython-chatterbox>=0.1.7.post1; extra == 'ai'
46
46
  Provides-Extra: mcp
47
+ Requires-Dist: faster-whisper>=1.2.1; extra == 'mcp'
47
48
  Requires-Dist: imagehash>=4.3; extra == 'mcp'
48
49
  Requires-Dist: mcp<2,>=1.27; extra == 'mcp'
49
- Requires-Dist: numba>=0.62; extra == 'mcp'
50
50
  Requires-Dist: ollama>=0.5.0; extra == 'mcp'
51
- Requires-Dist: openai-whisper>=20240930; extra == 'mcp'
52
51
  Requires-Dist: torch>=2.8.0; extra == 'mcp'
53
52
  Requires-Dist: torchvision>=0.23.0; extra == 'mcp'
54
53
  Requires-Dist: transformers>=5.2.0; extra == 'mcp'
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "videopython"
3
- version = "0.59.0"
3
+ version = "0.60.1"
4
4
  description = "LLM-friendly Python video editing with JSON plans, local AI, and MCP tools."
5
5
  authors = [
6
6
  { name = "Bartosz Wójtowicz", email = "bartoszwojtowicz@outlook.com" },
@@ -77,11 +77,9 @@ ai = ["videopython[ai]"]
77
77
  [project.optional-dependencies]
78
78
  ai = [
79
79
  # Speech recognition / diarization (understanding/audio.py)
80
- "openai-whisper>=20240930",
81
- # Floored, not capped: numba declares the numpy cap, and without a floor a
82
- # resolver satisfies a newer numpy by backtracking numba instead, breaking
83
- # `import whisper`. 0.62 is the oldest release for the lower supported
84
- # Python versions; Numba's metadata selects a compatible release on 3.14.
80
+ "faster-whisper>=1.2.1",
81
+ # videopython-chatterbox imports librosa, which imports numba. Keep the resolver
82
+ # from backtracking to a numba release incompatible with the selected NumPy.
85
83
  "numba>=0.62",
86
84
  "pyannote-audio>=4.0.0",
87
85
  "silero-vad>=5.1",
@@ -123,8 +121,7 @@ ai = [
123
121
  # dubbing, diarization, source separation, or TTS. Pin MCP <2 — v2 is breaking.
124
122
  mcp = [
125
123
  "mcp>=1.27,<2",
126
- "openai-whisper>=20240930",
127
- "numba>=0.62",
124
+ "faster-whisper>=1.2.1",
128
125
  "transnetv2-pytorch>=1.0.5",
129
126
  "transformers>=5.2.0",
130
127
  "imagehash>=4.3",
@@ -0,0 +1,63 @@
1
+ """Exception hierarchy shared by the package layers."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ class VideoPythonError(Exception):
7
+ """Base exception for all videopython errors."""
8
+
9
+ pass
10
+
11
+
12
+ class FFmpegError(VideoPythonError):
13
+ """Base exception for ffmpeg/ffprobe subprocess failures."""
14
+
15
+ pass
16
+
17
+
18
+ class FFmpegProbeError(FFmpegError):
19
+ """Raised when an ffprobe invocation or its JSON output fails."""
20
+
21
+ pass
22
+
23
+
24
+ class FFmpegRunError(FFmpegError):
25
+ """Raised when a blocking ffmpeg run returns a non-zero exit code."""
26
+
27
+ pass
28
+
29
+
30
+ class VideoError(VideoPythonError):
31
+ """Base exception for video-related errors."""
32
+
33
+ pass
34
+
35
+
36
+ class VideoLoadError(VideoError):
37
+ """Raised when there's an error loading a video file."""
38
+
39
+ pass
40
+
41
+
42
+ class VideoMetadataError(VideoError):
43
+ """Raised when there's an error getting video metadata."""
44
+
45
+ pass
46
+
47
+
48
+ class AudioError(VideoPythonError):
49
+ """Base exception for audio-related errors."""
50
+
51
+ pass
52
+
53
+
54
+ class AudioLoadError(AudioError):
55
+ """Raised when there's an error loading audio."""
56
+
57
+ pass
58
+
59
+
60
+ class TransformError(VideoPythonError):
61
+ """Base exception for transformation errors."""
62
+
63
+ pass
@@ -11,11 +11,17 @@ from __future__ import annotations
11
11
 
12
12
  import json
13
13
  import subprocess
14
+ import tempfile
14
15
  from contextlib import contextmanager
15
16
  from pathlib import Path
16
- from typing import Any, Iterator, Sequence
17
+ from typing import Any, BinaryIO, Iterator, Sequence, cast
17
18
 
18
- from videopython.base.exceptions import FFmpegProbeError, FFmpegRunError
19
+ from videopython._exceptions import FFmpegProbeError, FFmpegRunError
20
+
21
+
22
+ def _strict_decode_command(cmd: Sequence[str]) -> list[str]:
23
+ argv = list(cmd)
24
+ return [argv[0], "-hide_banner", "-loglevel", "error", "-xerror", *argv[1:]]
19
25
 
20
26
 
21
27
  def run(cmd: Sequence[str], *, stdin: bytes | None = None) -> bytes:
@@ -86,13 +92,37 @@ def _terminate(proc: subprocess.Popen[bytes], *, timeout: float = 5) -> None:
86
92
  proc.wait()
87
93
 
88
94
 
95
+ class _DecodeProcess:
96
+ """FFmpeg decode process with diagnostics stored outside the pipe."""
97
+
98
+ def __init__(self, process: subprocess.Popen[bytes], errors: BinaryIO):
99
+ self._process = process
100
+ self._errors = errors
101
+
102
+ @property
103
+ def stdout(self) -> BinaryIO:
104
+ return cast(BinaryIO, self._process.stdout)
105
+
106
+ def communicate(self) -> tuple[bytes, None]:
107
+ stdout, _ = self._process.communicate()
108
+ return stdout, None
109
+
110
+ def check(self) -> None:
111
+ if self._process.wait() == 0:
112
+ return
113
+ self._errors.seek(0)
114
+ detail = self._errors.read().decode(errors="replace")
115
+ raise FFmpegRunError(f"ffmpeg failed (exit {self._process.returncode}): {detail}")
116
+
117
+
89
118
  @contextmanager
90
- def popen_decode(cmd: Sequence[str], *, bufsize: int = -1) -> Iterator[subprocess.Popen[bytes]]:
119
+ def popen_decode(cmd: Sequence[str], *, bufsize: int = -1) -> Iterator[_DecodeProcess]:
91
120
  """Context manager wrapping an ffmpeg decode process.
92
121
 
93
- Yields a Popen with ``stdout=PIPE`` and ``stderr=DEVNULL``. Callers
94
- read raw bytes from ``proc.stdout``. On exit, the process is
95
- terminated (with kill fallback) and stdout is closed.
122
+ Yields a :class:`_DecodeProcess` with ``stdout=PIPE`` and diagnostics
123
+ stored in a temporary file. A caller that drains stdout must call
124
+ :meth:`_DecodeProcess.check`; a caller that stops early can leave the
125
+ context and the process is terminated without a decode error.
96
126
 
97
127
  Args:
98
128
  cmd: Full ffmpeg argv. The output target is typically ``pipe:1``.
@@ -100,18 +130,19 @@ def popen_decode(cmd: Sequence[str], *, bufsize: int = -1) -> Iterator[subproces
100
130
  (e.g. ``10**8``) for batched reads or a frame-sized value
101
131
  for streaming reads.
102
132
  """
103
- proc = subprocess.Popen(
104
- list(cmd),
105
- stdout=subprocess.PIPE,
106
- stderr=subprocess.DEVNULL,
107
- bufsize=bufsize,
108
- )
109
- try:
110
- yield proc
111
- finally:
112
- _terminate(proc)
113
- if proc.stdout is not None and not proc.stdout.closed:
114
- proc.stdout.close()
133
+ with tempfile.TemporaryFile() as errors:
134
+ proc = subprocess.Popen(
135
+ _strict_decode_command(cmd),
136
+ stdout=subprocess.PIPE,
137
+ stderr=errors,
138
+ bufsize=bufsize,
139
+ )
140
+ try:
141
+ yield _DecodeProcess(proc, errors)
142
+ finally:
143
+ _terminate(proc)
144
+ if proc.stdout is not None and not proc.stdout.closed:
145
+ proc.stdout.close()
115
146
 
116
147
 
117
148
  @contextmanager
@@ -38,12 +38,6 @@ Usage:
38
38
  # argument. The repo id + revision are resolved internally by the
39
39
  # chatterbox package, so there is nothing for us to pass a ``revision`` to.
40
40
  #
41
- # * openai-whisper CDN models -- ai/understanding/audio.py loads transcription
42
- # weights via ``whisper.load_model(name="turbo", ...)`` (tiny/base/small/
43
- # medium/large/turbo). openai-whisper downloads these from OpenAI's own CDN
44
- # by name, NOT through a HF ``from_pretrained`` repo, so there is no HF
45
- # commit SHA to pin. (The faster-whisper backend, if/when used, WOULD map to
46
- # a HF repo and could be pinned -- this code path does not use it.)
47
41
  # ---------------------------------------------------------------------------
48
42
  """
49
43
 
@@ -54,6 +48,13 @@ from __future__ import annotations
54
48
  # ``pinned(model_id)`` resolves with a plain dict lookup. SHAs captured from
55
49
  # the HuggingFace model API (see module docstring for refresh instructions).
56
50
  MODEL_REVISIONS: dict[str, str] = {
51
+ # CTranslate2 Whisper models (ai/understanding/audio.py: AudioToText).
52
+ "Systran/faster-whisper-tiny": "d90ca5fe260221311c53c58e660288d3deb8d356",
53
+ "Systran/faster-whisper-base": "ebe41f70d5b6dfa9166e2c581c45c9c0cfc57b66",
54
+ "Systran/faster-whisper-small": "536b0662742c02347bc0e980a01041f333bce120",
55
+ "Systran/faster-whisper-medium": "08e178d48790749d25932bbc082711ddcfdfbc4f",
56
+ "Systran/faster-whisper-large-v3": "edaa852ec7e145841d8ffdb056a99866b5f0a478",
57
+ "mobiuslabsgmbh/faster-whisper-large-v3-turbo": "0a363e9161cbc7ed1431c9597a8ceaf0c4f78fcf",
57
58
  # Speaker diarization (ai/understanding/audio.py: PYANNOTE_DIARIZATION_MODEL).
58
59
  # Gated repo (auto-approved); from_pretrained needs an accepted HF token.
59
60
  "pyannote/speaker-diarization-community-1": "3533c8cf8e369892e6b79ff1bf80f7b0286a54ee",
@@ -10,9 +10,9 @@ from typing import TYPE_CHECKING
10
10
 
11
11
  import numpy as np
12
12
 
13
+ from videopython import _ffmpeg
14
+ from videopython._exceptions import FFmpegRunError
13
15
  from videopython.ai.errors import AiError
14
- from videopython.base import _ffmpeg
15
- from videopython.base.exceptions import FFmpegRunError
16
16
 
17
17
  if TYPE_CHECKING:
18
18
  from videopython.audio import Audio
@@ -10,12 +10,12 @@ from pathlib import Path
10
10
  from typing import ClassVar, Literal
11
11
 
12
12
  import numpy as np
13
- from pydantic import Field
13
+ from pydantic import Field, PositiveInt
14
14
  from tqdm import tqdm
15
15
 
16
+ from videopython._ffmpeg import escape_filter_value
16
17
  from videopython.ai.understanding.faces import FaceSmoothingTracker
17
18
  from videopython.base._dimensions import floor_to_even
18
- from videopython.base._ffmpeg import escape_filter_value
19
19
  from videopython.base.video import FrameIterator, VideoMetadata
20
20
  from videopython.editing.operation import FilterCtx, OpCategory, Operation
21
21
 
@@ -46,30 +46,28 @@ class FaceTrackingCrop(Operation):
46
46
  category: ClassVar[OpCategory] = OpCategory.TRANSFORM
47
47
  compiles_from_source: ClassVar[bool] = True
48
48
 
49
- target_aspect: tuple[int, int] = Field((9, 16), description="Output aspect ratio as (width, height).")
49
+ target_aspect: tuple[PositiveInt, PositiveInt] = Field(
50
+ (9, 16), description="Output aspect ratio as (width, height)."
51
+ )
50
52
  face_selection: Literal["largest", "centered", "index"] = Field(
51
53
  "largest", description="Strategy for selecting which face to track."
52
54
  )
53
55
  face_index: int = Field(0, ge=0, description='Index of face to track when using ``face_selection="index"``.')
54
- padding: float = Field(0.3, ge=0, description="Extra space around face (0.3 = 30% padding on each side).")
55
56
  vertical_offset: float = Field(-0.1, description='Vertical position offset used by ``framing_rule="offset"``.')
56
- framing_rule: Literal["offset", "center", "headroom", "thirds", "dynamic"] = Field(
57
+ framing_rule: Literal["offset", "center", "headroom", "thirds"] = Field(
57
58
  "offset",
58
59
  description=(
59
60
  'Subject framing strategy. "offset": apply ``vertical_offset``; '
60
61
  '"center": keep face centered; "headroom": extra room above the face; '
61
- '"thirds": face near the upper-third line; "dynamic": currently same as "headroom".'
62
+ '"thirds": face near the upper-third line.'
62
63
  ),
63
64
  )
64
65
  headroom: float = Field(0.15, description="Headroom amount for framing rules that use it.")
65
66
  smoothing: float = Field(0.8, ge=0, le=1, description="Position smoothing factor (0-1, higher = smoother).")
66
67
  max_speed: float | None = Field(None, gt=0, description="Optional max camera movement per frame (normalized).")
67
- fallback: Literal["center", "last_position", "full_frame"] = Field(
68
+ fallback: Literal["center", "last_position"] = Field(
68
69
  "last_position",
69
- description=(
70
- 'Behavior when no face detected. "center" and "full_frame" both center the crop '
71
- 'while "last_position" holds the last tracked crop.'
72
- ),
70
+ description='Behavior when no face is detected. "center" centers the crop; "last_position" holds it.',
73
71
  )
74
72
  detection_interval: int = Field(3, ge=1, description="Frames between face detections.")
75
73
 
@@ -80,10 +78,7 @@ class FaceTrackingCrop(Operation):
80
78
  return (face_cx, face_cy)
81
79
  if self.framing_rule == "headroom":
82
80
  return (face_cx, face_cy - self.headroom)
83
- if self.framing_rule == "thirds":
84
- return (face_cx, face_cy - (1 / 3 - 0.5))
85
- # "dynamic" — placeholder until motion/look-direction framing is implemented.
86
- return (face_cx, face_cy - self.headroom)
81
+ return (face_cx, face_cy - (1 / 3 - 0.5))
87
82
 
88
83
  def _resolved_output_dims(self, w: int, h: int) -> tuple[int, int]:
89
84
  """Output ``(width, height)`` -- the fixed crop-window size.
@@ -154,7 +149,7 @@ class FaceTrackingCrop(Operation):
154
149
  positions.append((x, y))
155
150
  elif self.fallback == "last_position":
156
151
  positions.append(last)
157
- else: # "center" / "full_frame"
152
+ else:
158
153
  positions.append(default)
159
154
  return positions
160
155