numpyimage 3.8.0__tar.gz → 3.8.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.
- {numpyimage-3.8.0 → numpyimage-3.8.1}/PKG-INFO +1 -1
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/vidio.py +43 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/numpyimage.egg-info/PKG-INFO +1 -1
- {numpyimage-3.8.0 → numpyimage-3.8.1}/pyproject.toml +1 -1
- {numpyimage-3.8.0 → numpyimage-3.8.1}/LICENSE +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/README.md +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/__init__.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/align.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/graphics.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/imageio.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/nrrd_utils.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/operations.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/npimage/utils.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/numpyimage.egg-info/SOURCES.txt +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/numpyimage.egg-info/dependency_links.txt +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/numpyimage.egg-info/requires.txt +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/numpyimage.egg-info/top_level.txt +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/setup.cfg +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/tests/test_heic.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/tests/test_pbm.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/tests/test_video_streamer.py +0 -0
- {numpyimage-3.8.0 → numpyimage-3.8.1}/tests/test_video_writers.py +0 -0
|
@@ -21,6 +21,8 @@ Class list:
|
|
|
21
21
|
from typing import Union, Tuple, Iterator, Literal
|
|
22
22
|
from pathlib import Path
|
|
23
23
|
import subprocess
|
|
24
|
+
import shutil
|
|
25
|
+
import sys
|
|
24
26
|
import threading
|
|
25
27
|
import json
|
|
26
28
|
import math
|
|
@@ -70,6 +72,43 @@ def _import_av():
|
|
|
70
72
|
' run `pip install av` and try again')
|
|
71
73
|
|
|
72
74
|
|
|
75
|
+
def _check_ffmpeg_available(program: Literal['ffmpeg', 'ffprobe'] = 'ffmpeg'):
|
|
76
|
+
"""
|
|
77
|
+
Check that ffmpeg or ffprobe is on PATH, and raise a
|
|
78
|
+
FileNotFoundError with installation instructions if not.
|
|
79
|
+
"""
|
|
80
|
+
if shutil.which(program) is not None:
|
|
81
|
+
return
|
|
82
|
+
if sys.platform.startswith('linux'):
|
|
83
|
+
install_hint = (
|
|
84
|
+
'On Debian/Ubuntu: sudo apt install ffmpeg\n'
|
|
85
|
+
' On Fedora/RHEL: sudo dnf install ffmpeg\n'
|
|
86
|
+
' On Arch: sudo pacman -S ffmpeg'
|
|
87
|
+
)
|
|
88
|
+
elif sys.platform == 'darwin':
|
|
89
|
+
install_hint = (
|
|
90
|
+
'With Homebrew: brew install ffmpeg\n'
|
|
91
|
+
' With MacPorts: sudo port install ffmpeg'
|
|
92
|
+
)
|
|
93
|
+
elif sys.platform.startswith('win'):
|
|
94
|
+
install_hint = (
|
|
95
|
+
'With winget: winget install ffmpeg\n'
|
|
96
|
+
' With Chocolatey: choco install ffmpeg\n'
|
|
97
|
+
' Or download a static build from https://ffmpeg.org/download.html'
|
|
98
|
+
' and add it to your PATH.'
|
|
99
|
+
)
|
|
100
|
+
else:
|
|
101
|
+
install_hint = (
|
|
102
|
+
'See https://ffmpeg.org/download.html for installation'
|
|
103
|
+
' instructions for your platform.'
|
|
104
|
+
)
|
|
105
|
+
raise FileNotFoundError(
|
|
106
|
+
f"`{program}` was not found on PATH. npimage.vidio needs the ffmpeg"
|
|
107
|
+
f" suite installed to read and write video files.\n\n"
|
|
108
|
+
f"Install ffmpeg:\n {install_hint}"
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
73
112
|
def load_video(filename,
|
|
74
113
|
return_framerate=False,
|
|
75
114
|
progress_bar=True) -> Union[np.ndarray, Tuple[np.ndarray, float]]:
|
|
@@ -285,6 +324,7 @@ class VideoStreamer:
|
|
|
285
324
|
print('Falling back to ffprobe...')
|
|
286
325
|
frames_pts = []
|
|
287
326
|
# Fallback to ffprobe if PyAV didn't work
|
|
327
|
+
_check_ffmpeg_available('ffprobe')
|
|
288
328
|
cmd = ['ffprobe',
|
|
289
329
|
'-select_streams', 'v:0',
|
|
290
330
|
'-show_frames',
|
|
@@ -945,6 +985,7 @@ class FFmpegVideoWriter:
|
|
|
945
985
|
command.append(str(self.filename))
|
|
946
986
|
|
|
947
987
|
# Start FFmpeg process
|
|
988
|
+
_check_ffmpeg_available('ffmpeg')
|
|
948
989
|
self._process = subprocess.Popen(
|
|
949
990
|
command,
|
|
950
991
|
stdin=subprocess.PIPE,
|
|
@@ -1176,6 +1217,8 @@ def _get_rotation_from_metadata(filename):
|
|
|
1176
1217
|
We could use PyAV to do this perhaps faster, but for an already fast operation
|
|
1177
1218
|
like this, we stick with ffprobe to avoid the memory leaks in PyAV.
|
|
1178
1219
|
"""
|
|
1220
|
+
if shutil.which('ffprobe') is None:
|
|
1221
|
+
return None
|
|
1179
1222
|
cmd = ['ffprobe',
|
|
1180
1223
|
'-v', 'quiet',
|
|
1181
1224
|
'-select_streams', 'v:0',
|
|
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
|