yta-editor-parameters 0.0.5__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,13 @@
1
+ """
2
+ Module to include the functionality related to the
3
+ parameters and how we define them to be used in our
4
+ 'yta-editor' video editor library.
5
+ """
6
+ from yta_editor_parameters.constant import ConstantVideoEditorParameter
7
+ from yta_editor_parameters.eased import EasedVideoEditorParameter
8
+
9
+
10
+ __all__ = [
11
+ 'ConstantVideoEditorParameter',
12
+ 'EasedVideoEditorParameter'
13
+ ]
@@ -0,0 +1,18 @@
1
+ from yta_editor_parameters.context import VideoEditorEvaluationContext
2
+ from yta_parameters.abstract import Parameter
3
+ from abc import abstractmethod
4
+
5
+
6
+ class VideoEditorParameter(Parameter):
7
+ """
8
+ A parameter that uses a video editor context
9
+ to be evaluated.
10
+ """
11
+
12
+ @abstractmethod
13
+ def evaluate(
14
+ self,
15
+ # This is mandatory, even though it is not used
16
+ evaluation_context: VideoEditorEvaluationContext
17
+ ):
18
+ pass
@@ -0,0 +1,26 @@
1
+ from yta_editor_parameters.context import VideoEditorEvaluationContext
2
+ from yta_editor_parameters.abstract import VideoEditorParameter
3
+ from yta_parameters.types import BASIC_NON_ITERABLE_TYPE
4
+
5
+
6
+ class ConstantVideoEditorParameter(VideoEditorParameter):
7
+ """
8
+ A parameter that has always the same value and
9
+ is unaware of the context.
10
+ """
11
+
12
+ def __init__(
13
+ self,
14
+ value: BASIC_NON_ITERABLE_TYPE
15
+ ):
16
+ self.value: BASIC_NON_ITERABLE_TYPE = value
17
+ """
18
+ The constant value of this parameter.
19
+ """
20
+
21
+ def evaluate(
22
+ self,
23
+ # This is mandatory, even though it is not used
24
+ evaluation_context: VideoEditorEvaluationContext
25
+ ):
26
+ return self.value
@@ -0,0 +1,109 @@
1
+ from yta_parameters.context.abstract import EvaluationContext
2
+ from typing import Union
3
+
4
+
5
+ class VideoEditorEvaluationContext(EvaluationContext):
6
+ """
7
+ Evaluation context that includes all the parameters
8
+ needed to be able to evaluate the parameter for a
9
+ video editor, including information about the local
10
+ and global time moment, the frame index and the
11
+ total number of frames of the local item, or the fps
12
+ of the video.
13
+ """
14
+
15
+ # We should not accept 'None' to be more strict
16
+ # and build always the context with all the info
17
+ def __init__(
18
+ self,
19
+ t_normalized: float,
20
+ t: Union[float, None] = None,
21
+ t_global_normalized: Union[float, None] = None,
22
+ t_global: Union[float, None] = None,
23
+ frame_index: Union[int, None] = None,
24
+ # TODO: This value is not clear at all
25
+ number_of_frames: Union[int, None] = None,
26
+ fps: Union[float, None] = None
27
+ ):
28
+ # Local time
29
+ self.t_normalized: float = t_normalized
30
+ """
31
+ The local normalized time moment in which the
32
+ parameter must be evaluated, that is based on
33
+ the segment or item in which the parameter is
34
+ being used. This can be a transition, a node,
35
+ etc.
36
+
37
+ A value in the `[0.0, 1.0]` range representing
38
+ the progress of the local item.
39
+ """
40
+ self.t: Union[float, None] = t
41
+ """
42
+ The local not normalized time moment in which
43
+ the parameter must be evaluated, that is based
44
+ on the segment or item in which the parameter
45
+ is being used. This can be a a transition, a
46
+ node, etc.
47
+
48
+ The time (in seconds) elapsed since the
49
+ `t_start` of the local item.
50
+ """
51
+
52
+ # Global (track) time
53
+ self.t_global_normalized: Union[float, None] = t_global_normalized
54
+ """
55
+ The global normalized time moment that is
56
+ useful to compare the `t` with it. This is
57
+ based on the global timeline in which the
58
+ element that includes t he parameter is placed.
59
+
60
+ A value in the `[0.0, 1.0]` range representing
61
+ the progress of the global track.
62
+ """
63
+ self.t_global: Union[float, None] = t_global
64
+ """
65
+ The global not normalized time moment that is
66
+ useful to compare the `t` with it. This is
67
+ based on the global timeline in which the
68
+ element that includes the parameter is placed.
69
+
70
+ The time (in seconds) elapsed since the
71
+ `t_start` of the global track.
72
+ """
73
+
74
+ # Frame (local) indexes
75
+ self.frame_index: Union[int, None] = frame_index
76
+ """
77
+ The index of the frame in which the parameter
78
+ is being evaluated.
79
+
80
+ The index according to the local item.
81
+ """
82
+ self.number_of_frames: Union[int, None] = number_of_frames
83
+ """
84
+ The total number of frames of the local item.
85
+ """
86
+
87
+ self.fps: Union[float, None] = fps
88
+ """
89
+ The number of frames per seconds that are being
90
+ used for the video in which the element this
91
+ parameter belongs to is being evaluated.
92
+ """
93
+
94
+ """
95
+ Other fields that could be interesting (?):
96
+
97
+ self.node_outputs = node_outputs
98
+ self.curves = curves
99
+ self.backend = backend
100
+
101
+ INTERESTING VALUES:
102
+ Tiempo
103
+ Frame index
104
+ FPS
105
+ Resolución
106
+ Seed
107
+ Flags de ejecución
108
+ Cualquier metadata futura
109
+ """
@@ -0,0 +1,65 @@
1
+ from yta_editor_parameters.abstract import VideoEditorParameter
2
+ from yta_editor_parameters.context import VideoEditorEvaluationContext
3
+ from yta_math_easings.abstract import EasingFunctionName
4
+ from yta_math_easings.animated.abstract import EasingAnimatedFunction
5
+ from typing import Union
6
+
7
+
8
+ class EasedVideoEditorParameter(VideoEditorParameter):
9
+ """
10
+ A parameter to be used within a video editor context
11
+ that uses easing functions to calculate the values.
12
+ """
13
+
14
+ @property
15
+ def start_value(
16
+ self
17
+ ) -> float:
18
+ """
19
+ The start value of this eased parameter.
20
+ """
21
+ return self._easing_animated_function.start_value
22
+
23
+ @property
24
+ def end_value(
25
+ self
26
+ ) -> float:
27
+ """
28
+ The end value of this eased parameter.
29
+ """
30
+ return self._easing_animated_function.end_value
31
+
32
+ def __init__(
33
+ self,
34
+ start_value: float,
35
+ end_value: float,
36
+ easing_function_name: Union[EasingFunctionName, str] = 'linear'
37
+ ):
38
+ easing_function_name = EasingFunctionName.to_enum(easing_function_name)
39
+
40
+ self._easing_animated_function: EasingAnimatedFunction = EasingAnimatedFunction.get(easing_function_name)(
41
+ start_value = start_value,
42
+ end_value = end_value
43
+ # By now the 'duration' is not important at all
44
+ )
45
+ """
46
+ *For internal use only*
47
+
48
+ The internal easing animated function that will be
49
+ able to calculate the values.
50
+ """
51
+
52
+ def evaluate(
53
+ self,
54
+ evaluation_context: VideoEditorEvaluationContext,
55
+ ) -> float:
56
+ """
57
+ Get the value using the `evaluation_context`
58
+ provided.
59
+
60
+ This method will return the real not normalized
61
+ value.
62
+ """
63
+ return self._easing_animated_function.get_value_from_t_normalized(
64
+ t_normalized = evaluation_context.t_normalized
65
+ )
@@ -0,0 +1,39 @@
1
+ from yta_editor_parameters.abstract import VideoEditorParameter
2
+ from yta_editor_parameters import ConstantVideoEditorParameter
3
+ from yta_validation import PythonValidator
4
+
5
+
6
+ def parse_parameters(
7
+ parameters: dict
8
+ ) -> dict[str, 'VideoEditorParameter']:
9
+ """
10
+ Parse the `parameters` provided and raise an exception
11
+ if some of them is unaccepted. It will transform the
12
+ basic types into `ConstantVideoEditorParameter`
13
+ instances, and return the new dict with the values
14
+ transformed.
15
+
16
+ These types will be transformed into constant values:
17
+ - `int`
18
+ - `float`
19
+ - `bool`
20
+ - `str`
21
+ - `None`
22
+ """
23
+ parameters_parsed = {}
24
+
25
+ for name, value in parameters.items():
26
+ if PythonValidator.is_instance_of(value, VideoEditorParameter):
27
+ parameters_parsed[name] = value
28
+ continue
29
+
30
+ if (
31
+ PythonValidator.is_basic_non_iterable_type(value) or
32
+ value is None
33
+ ):
34
+ parameters_parsed[name] = ConstantVideoEditorParameter(value)
35
+ continue
36
+
37
+ raise Exception(f'The "{name}" parameter is not a "VideoEditorParameter" nor a basic and non iterable type')
38
+
39
+ return parameters_parsed
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: yta-editor-parameters
3
+ Version: 0.0.5
4
+ Summary: Youtube Autonomous Editor Parameters Module.
5
+ License-File: LICENSE
6
+ Author: danialcala94
7
+ Author-email: danielalcalavalera@gmail.com
8
+ Requires-Python: ==3.9
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Requires-Dist: yta_parameters (>=0.0.1,<1.0.0)
12
+ Requires-Dist: yta_validation (>=0.0.1,<1.0.0)
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Youtube Autonomous Editor Parameters Module
16
+
17
+ The module related to the parameters and how we define them to be used in the video editor 'yta-editor'.
@@ -0,0 +1,10 @@
1
+ yta_editor_parameters/__init__.py,sha256=XGakjObV8mHolgzdmjKaIMyUb0O4teMe77lur7nWZUI,379
2
+ yta_editor_parameters/abstract.py,sha256=1JytolMQYj6ZOWSvu1g11etTbCcMTpP7VHImEgYZJkA,477
3
+ yta_editor_parameters/constant.py,sha256=SwnoFnlRFru9P8wNqJQhKbH5zt4204vjqBMCMopOuh8,754
4
+ yta_editor_parameters/context/__init__.py,sha256=ibjdlSGd01UwkWvXytXKhZEDorfKbVNj_-gDUARbCNo,3525
5
+ yta_editor_parameters/eased.py,sha256=-e-dSeBR6Q0AQIt9hlTTZjBwqC30ATMA8mM8SwySQXI,2003
6
+ yta_editor_parameters/utils.py,sha256=Bt059pyYBYXQW-__aD1UQV60kDxxNIOuqAdbsWlB4Rg,1246
7
+ yta_editor_parameters-0.0.5.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
8
+ yta_editor_parameters-0.0.5.dist-info/METADATA,sha256=FnpGlvRadqXpAEKfi1KXinNuvHb0biW2xl-VC2wbVlo,613
9
+ yta_editor_parameters-0.0.5.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
10
+ yta_editor_parameters-0.0.5.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.