yta-video-opengl 0.0.4__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.
@@ -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())
@@ -70,7 +70,22 @@ class VideoWriter:
70
70
 
71
71
  return self
72
72
 
73
- # TODO: Maybe 'add_video_stream_from_template' (?)
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yta-video-opengl
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Youtube Autonomous Video OpenGL Module
5
5
  Author: danialcala94
6
6
  Author-email: danielalcalavalera@gmail.com
@@ -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=Mfhx4DHLfpmRXZYgkCcrzLbEsxGoKIj7RteHu4gOp8c,10691
3
- yta_video_opengl/tests.py,sha256=YnvSxxqWigTefUtc4IM0gUd3ovZKk8MwS6uyDqO42xA,5864
4
- yta_video_opengl/writer.py,sha256=9i1SSaOxWF-uBTWvpToP8juIqSWhbIh_Nfyi69adWIw,6356
5
- yta_video_opengl-0.0.4.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
6
- yta_video_opengl-0.0.4.dist-info/METADATA,sha256=bvLctvd0BL3lUflS8K39Dtl0ubHRIeqLSzOeuo0MlMw,670
7
- yta_video_opengl-0.0.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
8
- yta_video_opengl-0.0.4.dist-info/RECORD,,