yta-video-opengl 0.0.5__py3-none-any.whl → 0.0.6__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.
- yta_video_opengl/classes.py +1091 -0
- yta_video_opengl/{reader.py → reader/__init__.py} +52 -5
- yta_video_opengl/reader/cache.py +155 -0
- yta_video_opengl/tests.py +675 -55
- yta_video_opengl/utils.py +24 -0
- yta_video_opengl/writer.py +40 -1
- {yta_video_opengl-0.0.5.dist-info → yta_video_opengl-0.0.6.dist-info}/METADATA +1 -1
- yta_video_opengl-0.0.6.dist-info/RECORD +11 -0
- yta_video_opengl-0.0.5.dist-info/RECORD +0 -8
- {yta_video_opengl-0.0.5.dist-info → yta_video_opengl-0.0.6.dist-info}/LICENSE +0 -0
- {yta_video_opengl-0.0.5.dist-info → yta_video_opengl-0.0.6.dist-info}/WHEEL +0 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
from yta_validation import PythonValidator
|
2
|
+
from typing import Union
|
3
|
+
|
4
|
+
import numpy as np
|
5
|
+
import moderngl
|
6
|
+
|
7
|
+
|
8
|
+
def frame_to_texture(
|
9
|
+
frame: Union['VideoFrame', 'np.ndarray'],
|
10
|
+
context: moderngl.Context,
|
11
|
+
numpy_format: str = 'rgb24'
|
12
|
+
):
|
13
|
+
"""
|
14
|
+
Transform the given 'frame' to an opengl
|
15
|
+
texture.
|
16
|
+
"""
|
17
|
+
# To numpy RGB inverted for opengl
|
18
|
+
frame: np.ndarray = (
|
19
|
+
np.flipud(frame.to_ndarray(format = numpy_format))
|
20
|
+
if PythonValidator.is_instance_of(frame, 'VideoFrame') else
|
21
|
+
np.flipud(frame)
|
22
|
+
)
|
23
|
+
|
24
|
+
return context.texture((frame.shape[1], frame.shape[0]), 3, frame.tobytes())
|
yta_video_opengl/writer.py
CHANGED
@@ -70,7 +70,22 @@ class VideoWriter:
|
|
70
70
|
|
71
71
|
return self
|
72
72
|
|
73
|
-
|
73
|
+
def set_video_stream_from_template(
|
74
|
+
self,
|
75
|
+
template: Stream
|
76
|
+
) -> 'VideoWriter':
|
77
|
+
"""
|
78
|
+
Set the video stream, that will overwrite any other
|
79
|
+
previous video stream set.
|
80
|
+
|
81
|
+
You can pass the video stream as it was
|
82
|
+
obtained from the reader.
|
83
|
+
"""
|
84
|
+
self.video_stream: VideoStream = self.output.add_stream_from_template(
|
85
|
+
template
|
86
|
+
)
|
87
|
+
|
88
|
+
return self
|
74
89
|
|
75
90
|
def set_audio_stream(
|
76
91
|
self,
|
@@ -156,6 +171,30 @@ class VideoWriter:
|
|
156
171
|
ParameterValidator.validate_mandatory_instance_of('packet', packet, Packet)
|
157
172
|
|
158
173
|
if packet.size > 0:
|
174
|
+
try:
|
175
|
+
self.output.mux(packet)
|
176
|
+
except Exception as e:
|
177
|
+
# TODO: What strategy should we adopt with
|
178
|
+
# the packets that cannot be handled
|
179
|
+
# properly (?)
|
180
|
+
print(packet)
|
181
|
+
pass
|
182
|
+
|
183
|
+
return self
|
184
|
+
|
185
|
+
# TODO: This below is to test fails
|
186
|
+
if (
|
187
|
+
packet.size > 0 and
|
188
|
+
# This is a new special case
|
189
|
+
packet.dts % 1024 == 0 and
|
190
|
+
packet.dts > 0
|
191
|
+
):
|
192
|
+
# av.Packet of #0, dts=-2, pts=0; 1225 bytes at 0x1ef2d8e0680>
|
193
|
+
# av.Packet of #0, dts=0, pts=2; 110 bytes at 0x1e1feb8c6d0>
|
194
|
+
# av.Packet of #0, dts=1, pts=1; 182 bytes at 0x153f6b3b400>
|
195
|
+
# are failing
|
196
|
+
print(packet)
|
197
|
+
print(packet.stream.type)
|
159
198
|
self.output.mux(packet)
|
160
199
|
|
161
200
|
return self
|
@@ -0,0 +1,11 @@
|
|
1
|
+
yta_video_opengl/__init__.py,sha256=ycAx_XYMVDfkuObSvtW6irQ0Wo-fgxEz3fjIRMe8PpY,205
|
2
|
+
yta_video_opengl/classes.py,sha256=fYPdqMRtyC_Latn1eAXIMWRCsaMZhq7uHlnJPvZe8K0,32584
|
3
|
+
yta_video_opengl/reader/__init__.py,sha256=aKB5Ik9oR9L05-Lpwnl0YI3lK2RtmmhXIY7jGg9Hc1I,11320
|
4
|
+
yta_video_opengl/reader/cache.py,sha256=Y3lQrirQJz7zFeiJQeJnkzyghYeMahkpKzsouzB90VI,4421
|
5
|
+
yta_video_opengl/tests.py,sha256=00LEGdwjy1QfuHmWhIFJMNJixhc7gcAqb9ESAXH7Oag,24956
|
6
|
+
yta_video_opengl/utils.py,sha256=T1Rj36yk1wnSfFhisD4Gn8ZOaJXwnNVUeenC_dLcrP4,641
|
7
|
+
yta_video_opengl/writer.py,sha256=G4Rk6gcuPsF6H7PjXSRc3wGOY9pdiJdNCO9GdM6v4mE,7606
|
8
|
+
yta_video_opengl-0.0.6.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
9
|
+
yta_video_opengl-0.0.6.dist-info/METADATA,sha256=OvvH6wKPtmPIZdOoMNeOCxEM7xWieoR10NkmdtBZxTU,670
|
10
|
+
yta_video_opengl-0.0.6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
11
|
+
yta_video_opengl-0.0.6.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
yta_video_opengl/__init__.py,sha256=ycAx_XYMVDfkuObSvtW6irQ0Wo-fgxEz3fjIRMe8PpY,205
|
2
|
-
yta_video_opengl/reader.py,sha256=ROjx5jSi_M2KWcp1Fksi4y-apb1IvItPhpLF32u5DpU,9869
|
3
|
-
yta_video_opengl/tests.py,sha256=7a_n-xW2xBVYR1sj-IuGm8c8F6It2LHZ8GqCH_SeY-U,6081
|
4
|
-
yta_video_opengl/writer.py,sha256=9i1SSaOxWF-uBTWvpToP8juIqSWhbIh_Nfyi69adWIw,6356
|
5
|
-
yta_video_opengl-0.0.5.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
6
|
-
yta_video_opengl-0.0.5.dist-info/METADATA,sha256=hH7uBbRBkNQ44kIEi1oKB_s3fGLtwcnd0rdZB_M3bVw,670
|
7
|
-
yta_video_opengl-0.0.5.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
8
|
-
yta_video_opengl-0.0.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|