numpyimage 2.7.0__tar.gz → 2.9.0__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-2.7.0/numpyimage.egg-info → numpyimage-2.9.0}/PKG-INFO +1 -1
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/vidio.py +14 -2
- {numpyimage-2.7.0 → numpyimage-2.9.0/numpyimage.egg-info}/PKG-INFO +1 -1
- {numpyimage-2.7.0 → numpyimage-2.9.0}/pyproject.toml +1 -1
- {numpyimage-2.7.0 → numpyimage-2.9.0}/LICENSE +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/README.md +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/__init__.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/align.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/graphics.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/imageio.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/nrrd_utils.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/operations.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/npimage/utils.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/numpyimage.egg-info/SOURCES.txt +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/numpyimage.egg-info/dependency_links.txt +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/numpyimage.egg-info/requires.txt +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/numpyimage.egg-info/top_level.txt +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/setup.cfg +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/tests/test_heic.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/tests/test_pbm.py +0 -0
- {numpyimage-2.7.0 → numpyimage-2.9.0}/tests/test_video.py +0 -0
|
@@ -439,8 +439,16 @@ class VideoWriter:
|
|
|
439
439
|
self.stream.height = 0
|
|
440
440
|
|
|
441
441
|
def write(self, frame):
|
|
442
|
+
if self._closed:
|
|
443
|
+
raise RuntimeError('VideoWriter is closed, cannot write more frames.')
|
|
442
444
|
if not isinstance(frame, self.av.VideoFrame):
|
|
443
|
-
if frame
|
|
445
|
+
if not isinstance(frame, np.ndarray):
|
|
446
|
+
frame = np.array(frame)
|
|
447
|
+
if frame.ndim == 4:
|
|
448
|
+
for i in range(frame.shape[0]):
|
|
449
|
+
self.write(frame[i])
|
|
450
|
+
return
|
|
451
|
+
elif frame.ndim == 3 and frame.shape[-1] == 3:
|
|
444
452
|
frame = self.av.VideoFrame.from_ndarray(frame, format='rgb24')
|
|
445
453
|
elif frame.ndim == 3 and frame.shape[-1] == 4:
|
|
446
454
|
# While some video codecs support an alpha channel, most don't,
|
|
@@ -449,7 +457,8 @@ class VideoWriter:
|
|
|
449
457
|
elif frame.ndim == 2:
|
|
450
458
|
frame = self.av.VideoFrame.from_ndarray(frame, format='gray')
|
|
451
459
|
else:
|
|
452
|
-
raise ValueError(
|
|
460
|
+
raise ValueError('Frame must have shape (H, W) (H, W, 3) (H, W, 4)'
|
|
461
|
+
f' (t, H, W, 3) or (t, H, W, 4) but was {frame.shape}')
|
|
453
462
|
if self.stream.width == 0:
|
|
454
463
|
self.stream.width = frame.width
|
|
455
464
|
if self.stream.height == 0:
|
|
@@ -461,6 +470,9 @@ class VideoWriter:
|
|
|
461
470
|
return self
|
|
462
471
|
|
|
463
472
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
473
|
+
self.close()
|
|
474
|
+
|
|
475
|
+
def close(self):
|
|
464
476
|
# Flush stream
|
|
465
477
|
for packet in self.stream.encode():
|
|
466
478
|
self.container.mux(packet)
|
|
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
|