yta-video-opengl 0.0.26__tar.gz → 0.0.27__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yta-video-opengl
3
- Version: 0.0.26
3
+ Version: 0.0.27
4
4
  Summary: Youtube Autonomous Video OpenGL Module
5
5
  Author: danialcala94
6
6
  Author-email: danielalcalavalera@gmail.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yta-video-opengl"
3
- version = "0.0.26"
3
+ version = "0.0.27"
4
4
  description = "Youtube Autonomous Video OpenGL Module"
5
5
  authors = [
6
6
  {name = "danialcala94",email = "danielalcalavalera@gmail.com"}
@@ -1,7 +1,9 @@
1
1
  from yta_video_opengl.nodes.video.opengl import WavingNode
2
2
  from yta_video_opengl.nodes.audio import ChorusNode
3
3
  from yta_video_opengl.nodes import TimedNode
4
+ from yta_video_opengl.utils import texture_to_frame
4
5
  from yta_validation.parameter import ParameterValidator
6
+ from yta_validation import PythonValidator
5
7
  from yta_programming.decorators import singleton_old
6
8
  from typing import Union
7
9
 
@@ -379,6 +381,46 @@ class EffectsStack:
379
381
 
380
382
  return self
381
383
 
382
- # TODO: Maybe create an 'apply_video_effects' (?)
383
- # TODO: Maybe create an 'apply_audio_effects' (?)
384
+ def apply_video_effects(
385
+ self,
386
+ frame: 'np.ndarray',
387
+ t: Union[int, float, 'Fraction']
388
+ ) -> 'np.ndarray':
389
+ """
390
+ Apply all the video effects that must be
391
+ applied for the given 't' time moment to
392
+ the provided 'frame' (that must be the
393
+ video frame of that time moment).
394
+ """
395
+ for effect in self.get_video_effects_for_t(t):
396
+ frame = effect.process(frame, t)
397
+
398
+ # TODO: Check when the frame comes as a
399
+ # Texture and when as a numpy array. I
400
+ # think when we apply an opengl node it
401
+ # is a texture, but we need to return it
402
+ # as a numpy, always
403
+ return (
404
+ texture_to_frame(frame)
405
+ if PythonValidator.is_instance_of(frame, moderngl.Texture) else
406
+ frame
407
+ )
408
+
409
+ def apply_audio_effects(
410
+ self,
411
+ frame: 'np.ndarray',
412
+ t: Union[int, float, 'Fraction']
413
+ ) -> 'np.ndarray':
414
+ """
415
+ Apply all the video effects that must be
416
+ applied for the given 't' time moment to
417
+ the provided 'frame' (that must be the
418
+ audio frame of that time moment).
419
+ """
420
+ for effect in self.get_audio_effects_for_t(t):
421
+ frame = effect.process(frame, t)
422
+
423
+ # Frame can only by a numpy array here
424
+ return frame
425
+
384
426
  # TODO: Create 'remove_effect'
@@ -131,11 +131,11 @@ class TimedNode:
131
131
 
132
132
  def process(
133
133
  self,
134
- frame: Union['VideoFrame', 'AudioFrame', moderngl.Texture],
134
+ frame: Union[moderngl.Texture, 'np.ndarray'],
135
135
  t: float
136
136
  # TODO: Maybe we need 'fps' and 'number_of_frames'
137
137
  # to calculate progressions or similar...
138
- ) -> Union['VideoFrame', 'AudioFrame', 'Texture']:
138
+ ) -> Union[moderngl.Texture, 'np.ndarray']:
139
139
  """
140
140
  Process the frame if the provided 't' time
141
141
  moment is in the range of this TimedNode