videopython 0.55.3__tar.gz → 0.55.4__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.
- {videopython-0.55.3 → videopython-0.55.4}/PKG-INFO +1 -1
- {videopython-0.55.3 → videopython-0.55.4}/pyproject.toml +1 -1
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/audio/audio.py +41 -12
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/video.py +8 -12
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/operation.py +4 -5
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/streaming.py +1 -1
- {videopython-0.55.3 → videopython-0.55.4}/.gitignore +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/LICENSE +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/README.md +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/_device.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/_ollama.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/_optional.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/_predictor.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/_revisions.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/backend.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/catalog.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/editor.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/local.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/models.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/auto_edit/resolve.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/_tts_backend.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/audio_ops.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/config.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/dubber.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/models.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/pipeline.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/quality.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/remux.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/separation.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/timing.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/translation.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/dubbing/voice_sample.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/effects.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/errors.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/generation/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/generation/audio.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/generation/image.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/generation/video.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/keyframe.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/ops.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/transforms.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/_detector.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/audio.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/classification.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/faces.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/image.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/objects.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/temporal.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/analyzer.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/detectors.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/models.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/sampling.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/source_metadata.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/audio/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/audio/analysis.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/_dimensions.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/_ffmpeg.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/_video_io.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/description.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/draw_detections.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/exceptions.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/Anton-OFL.txt +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/Anton-Regular.ttf +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/BebasNeue-OFL.txt +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/BebasNeue-Regular.ttf +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/DejaVuSans.ttf +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/LICENSE_DEJAVU +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/Lato-Bold.ttf +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/Lato-OFL.txt +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/Poppins-Bold.ttf +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/Poppins-OFL.txt +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/fonts/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/base/transcription.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/_ass.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/_easing.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/_schema.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/audio_ops.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/effects.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/transcription_overlay.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/transforms.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/editing/video_edit.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/mcp/__init__.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/mcp/server.py +0 -0
- {videopython-0.55.3 → videopython-0.55.4}/src/videopython/py.typed +0 -0
|
@@ -199,15 +199,16 @@ class Audio:
|
|
|
199
199
|
Args:
|
|
200
200
|
file_path: Path to the audio file
|
|
201
201
|
sample_rate: Decode at this rate instead of the source's.
|
|
202
|
-
channels: Decode to
|
|
203
|
-
|
|
202
|
+
channels: Decode to mono (``1``) or stereo (``2``). Sources with
|
|
203
|
+
more than two channels decode to stereo by default.
|
|
204
204
|
|
|
205
205
|
Returns:
|
|
206
206
|
Audio: New Audio instance
|
|
207
207
|
|
|
208
208
|
Raises:
|
|
209
209
|
FileNotFoundError: If the file doesn't exist
|
|
210
|
-
ValueError: If ``sample_rate`` or ``channels`` is
|
|
210
|
+
ValueError: If ``sample_rate`` is not positive or ``channels`` is
|
|
211
|
+
not ``1`` or ``2``.
|
|
211
212
|
AudioLoadError: If there's an error loading the audio
|
|
212
213
|
"""
|
|
213
214
|
file_path = Path(file_path)
|
|
@@ -215,12 +216,12 @@ class Audio:
|
|
|
215
216
|
raise FileNotFoundError(f"File not found: {file_path}")
|
|
216
217
|
if sample_rate is not None and sample_rate <= 0:
|
|
217
218
|
raise ValueError("Sample rate must be positive")
|
|
218
|
-
if channels is not None and channels
|
|
219
|
-
raise ValueError("Channel count must be
|
|
219
|
+
if channels is not None and channels not in {1, 2}:
|
|
220
|
+
raise ValueError("Channel count must be 1 or 2")
|
|
220
221
|
|
|
221
222
|
info = cls._get_ffmpeg_info(file_path)
|
|
222
223
|
target_rate = info["sample_rate"] if sample_rate is None else sample_rate
|
|
223
|
-
target_channels = info["channels"] if channels is None else channels
|
|
224
|
+
target_channels = min(info["channels"], 2) if channels is None else channels
|
|
224
225
|
|
|
225
226
|
# Raw PCM rather than a WAV round-trip. Piped WAV comes back as pcm_s16le
|
|
226
227
|
# whatever the source's bit depth -- `-bits_per_raw_sample` is a hint the
|
|
@@ -334,8 +335,16 @@ class Audio:
|
|
|
334
335
|
>>> silence = Audio.silence(duration=5.0) # 5 seconds of silence
|
|
335
336
|
>>> silence = Audio.silence(duration=2.0, sample_rate=22050, channels=1)
|
|
336
337
|
"""
|
|
338
|
+
if duration <= 0:
|
|
339
|
+
raise ValueError("Duration must be positive")
|
|
340
|
+
if sample_rate <= 0:
|
|
341
|
+
raise ValueError("Sample rate must be positive")
|
|
342
|
+
if channels not in {1, 2}:
|
|
343
|
+
raise ValueError("Channel count must be 1 or 2")
|
|
344
|
+
|
|
337
345
|
frame_count = int(duration * sample_rate)
|
|
338
|
-
|
|
346
|
+
shape = (frame_count,) if channels == 1 else (frame_count, channels)
|
|
347
|
+
data = np.zeros(shape, dtype=np.float32)
|
|
339
348
|
|
|
340
349
|
metadata = AudioMetadata(
|
|
341
350
|
sample_rate=sample_rate,
|
|
@@ -579,9 +588,13 @@ class Audio:
|
|
|
579
588
|
# clamped (line below), not rejected.
|
|
580
589
|
duration_tolerance = 0.1
|
|
581
590
|
|
|
591
|
+
if end_seconds is not None and end_seconds < start_seconds:
|
|
592
|
+
raise ValueError("end_seconds must be greater than start_seconds")
|
|
593
|
+
if start_seconds > duration_seconds + duration_tolerance:
|
|
594
|
+
raise ValueError("start_seconds cannot exceed audio duration")
|
|
595
|
+
start_seconds = min(start_seconds, duration_seconds)
|
|
596
|
+
|
|
582
597
|
if end_seconds is not None:
|
|
583
|
-
if end_seconds < start_seconds:
|
|
584
|
-
raise ValueError("end_seconds must be greater than start_seconds")
|
|
585
598
|
if end_seconds > duration_seconds + duration_tolerance:
|
|
586
599
|
raise ValueError("end_seconds cannot exceed audio duration")
|
|
587
600
|
end_seconds = min(end_seconds, duration_seconds)
|
|
@@ -819,8 +832,15 @@ class Audio:
|
|
|
819
832
|
"""
|
|
820
833
|
file_path = Path(file_path)
|
|
821
834
|
|
|
822
|
-
|
|
823
|
-
|
|
835
|
+
clipped = np.clip(self.data, -1.0, 1.0)
|
|
836
|
+
if self.metadata.sample_width == 1:
|
|
837
|
+
pcm_data = np.rint((clipped + 1.0) * 127.5).astype(np.uint8)
|
|
838
|
+
elif self.metadata.sample_width == 2:
|
|
839
|
+
pcm_data = np.rint(clipped * np.iinfo(np.int16).max).astype("<i2")
|
|
840
|
+
elif self.metadata.sample_width == 4:
|
|
841
|
+
pcm_data = np.rint(clipped.astype(np.float64) * np.iinfo(np.int32).max).astype("<i4")
|
|
842
|
+
else:
|
|
843
|
+
raise ValueError("Sample width must be 1, 2, or 4 bytes")
|
|
824
844
|
|
|
825
845
|
# Create WAV in memory
|
|
826
846
|
wav_io = io.BytesIO()
|
|
@@ -828,7 +848,7 @@ class Audio:
|
|
|
828
848
|
wav_file.setnchannels(self.metadata.channels)
|
|
829
849
|
wav_file.setsampwidth(self.metadata.sample_width)
|
|
830
850
|
wav_file.setframerate(self.metadata.sample_rate)
|
|
831
|
-
wav_file.writeframes(
|
|
851
|
+
wav_file.writeframes(pcm_data.tobytes())
|
|
832
852
|
|
|
833
853
|
wav_io.seek(0)
|
|
834
854
|
|
|
@@ -935,8 +955,12 @@ class Audio:
|
|
|
935
955
|
>>> for timestamp, levels in levels_over_time:
|
|
936
956
|
... print(f"{timestamp:.2f}s: {levels.db_rms:.1f} dB")
|
|
937
957
|
"""
|
|
958
|
+
if window_seconds <= 0:
|
|
959
|
+
raise ValueError("window_seconds must be positive")
|
|
938
960
|
if hop_seconds is None:
|
|
939
961
|
hop_seconds = window_seconds / 2
|
|
962
|
+
if hop_seconds <= 0:
|
|
963
|
+
raise ValueError("hop_seconds must be positive")
|
|
940
964
|
|
|
941
965
|
results = []
|
|
942
966
|
current_time = 0.0
|
|
@@ -1051,6 +1075,11 @@ class Audio:
|
|
|
1051
1075
|
"""
|
|
1052
1076
|
from videopython.audio.analysis import AudioSegment
|
|
1053
1077
|
|
|
1078
|
+
if segment_length <= 0:
|
|
1079
|
+
raise ValueError("segment_length must be positive")
|
|
1080
|
+
if not 0 <= overlap < 1:
|
|
1081
|
+
raise ValueError("overlap must be at least 0 and less than 1")
|
|
1082
|
+
|
|
1054
1083
|
hop_length = segment_length * (1 - overlap)
|
|
1055
1084
|
segments = []
|
|
1056
1085
|
current_time = 0.0
|
|
@@ -653,18 +653,14 @@ class Video:
|
|
|
653
653
|
if not isinstance(val, slice):
|
|
654
654
|
raise ValueError("Only slices are supported for video indexing!")
|
|
655
655
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if stop < 0:
|
|
665
|
-
stop = len(self.frames) + stop
|
|
666
|
-
|
|
667
|
-
# Slice audio to match video duration
|
|
656
|
+
start, stop, step = val.indices(len(self.frames))
|
|
657
|
+
if step != 1:
|
|
658
|
+
raise ValueError("Video slices must use a step of 1")
|
|
659
|
+
if start >= stop:
|
|
660
|
+
raise ValueError("Video slices cannot be empty")
|
|
661
|
+
|
|
662
|
+
sliced = self.from_frames(self.frames[start:stop], fps=self.fps)
|
|
663
|
+
|
|
668
664
|
audio_start = start / self.fps
|
|
669
665
|
audio_end = stop / self.fps
|
|
670
666
|
sliced.audio = self.audio.slice(start_seconds=audio_start, end_seconds=audio_end)
|
|
@@ -474,9 +474,8 @@ class Effect(Operation):
|
|
|
474
474
|
:attr:`compiles_to_filter` and implement :meth:`to_ffmpeg_filter` (and, for
|
|
475
475
|
audio-coupled effects like ``Fade``/``VolumeAdjust``,
|
|
476
476
|
:meth:`to_ffmpeg_audio_filter`) so the window stays coherent across the
|
|
477
|
-
decode/encode graph.
|
|
478
|
-
|
|
479
|
-
with ``src/tests/editing/test_filter_parity.py`` pinning them together.
|
|
477
|
+
decode/encode graph. Each effect has one video execution path: a native
|
|
478
|
+
filter or per-frame Python.
|
|
480
479
|
"""
|
|
481
480
|
|
|
482
481
|
category: ClassVar[OpCategory] = OpCategory.EFFECT
|
|
@@ -541,8 +540,8 @@ class Effect(Operation):
|
|
|
541
540
|
def streams(self) -> bool:
|
|
542
541
|
"""An effect streams via per-frame Python (``process_frame``) or a filter.
|
|
543
542
|
|
|
544
|
-
Frame effects override :meth:`process_frame`; filter effects
|
|
545
|
-
|
|
543
|
+
Frame effects override :meth:`process_frame`; filter effects such as
|
|
544
|
+
``add_subtitles`` instead set
|
|
546
545
|
:attr:`compiles_to_filter` and implement :meth:`to_ffmpeg_filter`.
|
|
547
546
|
``add_subtitles`` streams *only* via the filter path (it does not override
|
|
548
547
|
``process_frame``), so ``compiles_to_filter`` is consulted per-instance.
|
|
@@ -142,7 +142,7 @@ def _classify_op_list(ops: Sequence[Operation], location_prefix: str) -> list[Op
|
|
|
142
142
|
)
|
|
143
143
|
continue
|
|
144
144
|
if op.compiles_to_filter:
|
|
145
|
-
# Filter-class
|
|
145
|
+
# Filter-class effects such as add_subtitles join the
|
|
146
146
|
# decode filter chain at this plan position -- or the encode
|
|
147
147
|
# chain when frame effects precede it -- so it streams in plan
|
|
148
148
|
# order either way and does not block later transforms the way
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/understanding/classification.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{videopython-0.55.3 → videopython-0.55.4}/src/videopython/ai/video_analysis/source_metadata.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|