caffeinism-utils 0.0.168__py3-none-any.whl → 0.0.170__py3-none-any.whl
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.
- caffeinism_utils/aiteration.py +6 -1
- caffeinism_utils/av/io.py +16 -9
- caffeinism_utils/prefetch.py +1 -1
- {caffeinism_utils-0.0.168.dist-info → caffeinism_utils-0.0.170.dist-info}/METADATA +1 -1
- {caffeinism_utils-0.0.168.dist-info → caffeinism_utils-0.0.170.dist-info}/RECORD +6 -6
- {caffeinism_utils-0.0.168.dist-info → caffeinism_utils-0.0.170.dist-info}/WHEEL +1 -1
caffeinism_utils/aiteration.py
CHANGED
|
@@ -26,6 +26,8 @@ async def rate_limit_iterator(aiterator, iters_per_second):
|
|
|
26
26
|
|
|
27
27
|
T = TypeVar("T")
|
|
28
28
|
|
|
29
|
+
__CLOSE = object()
|
|
30
|
+
|
|
29
31
|
|
|
30
32
|
class StreamQueue(Generic[T]):
|
|
31
33
|
def __init__(self):
|
|
@@ -35,6 +37,9 @@ class StreamQueue(Generic[T]):
|
|
|
35
37
|
return self.queue.put(data)
|
|
36
38
|
|
|
37
39
|
async def __aiter__(self) -> AsyncGenerator[T]:
|
|
38
|
-
while (iterator := await self.queue.get()) is not
|
|
40
|
+
while (iterator := await self.queue.get()) is not __CLOSE:
|
|
39
41
|
async for it in iterator:
|
|
40
42
|
yield it
|
|
43
|
+
|
|
44
|
+
async def close(self):
|
|
45
|
+
await self.queue.put(__CLOSE)
|
caffeinism_utils/av/io.py
CHANGED
|
@@ -388,10 +388,9 @@ class PyAVWriter(PyAVInterface):
|
|
|
388
388
|
if self.future is not None:
|
|
389
389
|
self.future.result()
|
|
390
390
|
del self.future
|
|
391
|
-
|
|
392
391
|
self.future = self.pool.submit(func, *args, **kwargs)
|
|
393
392
|
|
|
394
|
-
return
|
|
393
|
+
return _func
|
|
395
394
|
|
|
396
395
|
def write(self, array):
|
|
397
396
|
frame = self.array_to_frame(array)
|
|
@@ -420,8 +419,15 @@ class PyAVWriter(PyAVInterface):
|
|
|
420
419
|
|
|
421
420
|
return cc
|
|
422
421
|
|
|
423
|
-
def _encode_video_frame(self, stream: av.VideoStream, frame: av.VideoFrame):
|
|
422
|
+
def _encode_video_frame(self, stream: av.VideoStream, frame: av.VideoFrame | None):
|
|
424
423
|
cc = self._codex_contexts.get(stream.index)
|
|
424
|
+
if frame is None:
|
|
425
|
+
if cc is not None:
|
|
426
|
+
for packet in cc.encode_lazy():
|
|
427
|
+
packet.stream = stream
|
|
428
|
+
yield packet
|
|
429
|
+
return
|
|
430
|
+
|
|
425
431
|
if cc is None:
|
|
426
432
|
stream.width = frame.width
|
|
427
433
|
stream.height = frame.height
|
|
@@ -437,7 +443,7 @@ class PyAVWriter(PyAVInterface):
|
|
|
437
443
|
elif (stream.width, stream.height) != (frame.width, frame.height):
|
|
438
444
|
stream.width = frame.width
|
|
439
445
|
stream.height = frame.height
|
|
440
|
-
for packet in cc.
|
|
446
|
+
for packet in cc.encode_lazy():
|
|
441
447
|
packet.stream = stream
|
|
442
448
|
yield packet
|
|
443
449
|
cc = self.create_codec_context(stream)
|
|
@@ -498,15 +504,16 @@ class PyAVWriter(PyAVInterface):
|
|
|
498
504
|
del self.future
|
|
499
505
|
self.future = None
|
|
500
506
|
|
|
501
|
-
if self.alpha_extractor is not None:
|
|
502
|
-
self.alpha_extractor.close()
|
|
503
507
|
for stream in self.streams:
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
508
|
+
for packet in self._encode_video_frame(stream, None):
|
|
509
|
+
self.container.mux_one(packet)
|
|
510
|
+
|
|
507
511
|
if self.audio_stream is not None:
|
|
508
512
|
self.container.mux(self.audio_stream.encode())
|
|
509
513
|
|
|
514
|
+
if self.alpha_extractor is not None:
|
|
515
|
+
self.alpha_extractor.close()
|
|
516
|
+
|
|
510
517
|
def __exit__(
|
|
511
518
|
self,
|
|
512
519
|
t: type[BaseException] | None,
|
caffeinism_utils/prefetch.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
caffeinism_utils/__init__.py,sha256=MER0q-NVosxQWibvx3a3bKwxRWGVXWeso9-qaU6oH_E,43
|
|
2
|
-
caffeinism_utils/aiteration.py,sha256=
|
|
2
|
+
caffeinism_utils/aiteration.py,sha256=PD2PMU4rkjz2xlVDyBiNd19_-2zBpF3KWrIGS3QNl_c,1130
|
|
3
3
|
caffeinism_utils/asyncio.py,sha256=33yJ51vY0JvS6HJiBsEXXxAE3UlpLeudK8tanlu599Y,4811
|
|
4
4
|
caffeinism_utils/av/__init__.py,sha256=J7dtpfW9R9BH-HJmlubAaFMqcEOMOu--zH64XJ7A2hI,423
|
|
5
5
|
caffeinism_utils/av/codecs.py,sha256=gkOeazEqJWC1fRTLGpjdQbeorpVZpRHDzN7Ky01AML8,3360
|
|
6
6
|
caffeinism_utils/av/filters.py,sha256=P2cMPTOMTU-oDKkqgPv-5YGO0JPFpMdNVrYdRv1OD0w,15381
|
|
7
|
-
caffeinism_utils/av/io.py,sha256=
|
|
7
|
+
caffeinism_utils/av/io.py,sha256=RwlyYRRluDBn9JA6_Q_KChMELUZYzYqBJ1rFwp3hJXo,16724
|
|
8
8
|
caffeinism_utils/http.py,sha256=ZDcdHxaSPzbo6Jy2RfWl6Ib5Hii2170AkXlb-KKuI4I,424
|
|
9
9
|
caffeinism_utils/io.py,sha256=cgA7LwV8zgfEd3Qaubogow3V21IR4yp2drRmOgql6Tw,3771
|
|
10
10
|
caffeinism_utils/iteration.py,sha256=7BddGudGRBmNyJi3cTpmcQ2zWplu5zjxYCN4J_cWe3c,3026
|
|
11
|
-
caffeinism_utils/prefetch.py,sha256=
|
|
11
|
+
caffeinism_utils/prefetch.py,sha256=yNTbBaSF-BA5iA1zUfnWVvcMm3br5nlBmPgvBMXHO7I,4144
|
|
12
12
|
caffeinism_utils/utils.py,sha256=-g0DDuiCrck4xjN9T5ZUaklClXqDLCfOB6PKN4D8mlE,927
|
|
13
13
|
caffeinism_utils/zip.py,sha256=L1d8qfphao-iD5G7bDu4LMQNg6ULc4kCqUk5gJbhSdE,1679
|
|
14
|
-
caffeinism_utils-0.0.
|
|
15
|
-
caffeinism_utils-0.0.
|
|
16
|
-
caffeinism_utils-0.0.
|
|
14
|
+
caffeinism_utils-0.0.170.dist-info/METADATA,sha256=f0uoS1I0M3QiGiOm4c6n3K9X7SJJIuihVUcbBVcWMkQ,899
|
|
15
|
+
caffeinism_utils-0.0.170.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
16
|
+
caffeinism_utils-0.0.170.dist-info/RECORD,,
|