yta-video-frame-time 0.0.16__py3-none-any.whl → 0.0.17__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_frame_time/interval.py +353 -126
- {yta_video_frame_time-0.0.16.dist-info → yta_video_frame_time-0.0.17.dist-info}/METADATA +1 -1
- yta_video_frame_time-0.0.17.dist-info/RECORD +8 -0
- yta_video_frame_time-0.0.16.dist-info/RECORD +0 -8
- {yta_video_frame_time-0.0.16.dist-info → yta_video_frame_time-0.0.17.dist-info}/WHEEL +0 -0
- {yta_video_frame_time-0.0.16.dist-info → yta_video_frame_time-0.0.17.dist-info}/licenses/LICENSE +0 -0
yta_video_frame_time/interval.py
CHANGED
|
@@ -14,7 +14,7 @@ Number = Union[int, float, Fraction]
|
|
|
14
14
|
"""
|
|
15
15
|
Custom type to represent numbers.
|
|
16
16
|
"""
|
|
17
|
-
TimeIntervalType = Union['
|
|
17
|
+
TimeIntervalType = Union['NewTimeInterval', tuple[float, float]]
|
|
18
18
|
"""
|
|
19
19
|
The type we accept as time interval, that could be a
|
|
20
20
|
tuple we transform into a time interval.
|
|
@@ -765,8 +765,8 @@ class NewTimeInterval:
|
|
|
765
765
|
A copy of this instance.
|
|
766
766
|
"""
|
|
767
767
|
time_interval = NewTimeInterval(
|
|
768
|
-
start = self.
|
|
769
|
-
end = self.
|
|
768
|
+
start = self.original_start,
|
|
769
|
+
end = self.original_end,
|
|
770
770
|
fps = self.fps
|
|
771
771
|
)
|
|
772
772
|
|
|
@@ -793,6 +793,16 @@ class NewTimeInterval:
|
|
|
793
793
|
is capable of cutting time intervals.
|
|
794
794
|
"""
|
|
795
795
|
return TimeIntervalCutter
|
|
796
|
+
|
|
797
|
+
@property
|
|
798
|
+
def extender(
|
|
799
|
+
self
|
|
800
|
+
) -> 'TimeIntervalExtender':
|
|
801
|
+
"""
|
|
802
|
+
Shortcut to the static class `TimeIntervalExtender` that
|
|
803
|
+
is capable of extending time intervals.
|
|
804
|
+
"""
|
|
805
|
+
return TimeIntervalExtender
|
|
796
806
|
|
|
797
807
|
def __init__(
|
|
798
808
|
self,
|
|
@@ -856,29 +866,6 @@ class NewTimeInterval:
|
|
|
856
866
|
The current `end` value of this time interval.
|
|
857
867
|
"""
|
|
858
868
|
|
|
859
|
-
# TODO: Is this that necessary (?)
|
|
860
|
-
def _validate_t(
|
|
861
|
-
self,
|
|
862
|
-
t: Number,
|
|
863
|
-
do_include_start: bool = False,
|
|
864
|
-
do_include_end: bool = False
|
|
865
|
-
) -> None:
|
|
866
|
-
"""
|
|
867
|
-
Validate that the provided `t` value is between the `start`
|
|
868
|
-
and the `end` parameters provided, including them or not
|
|
869
|
-
according to the boolean parameters provided.
|
|
870
|
-
"""
|
|
871
|
-
# TODO: Maybe we should validate also according to the
|
|
872
|
-
# original values
|
|
873
|
-
ParameterValidator.validate_mandatory_number_between(
|
|
874
|
-
name = 't',
|
|
875
|
-
value = t,
|
|
876
|
-
lower_limit = self.start,
|
|
877
|
-
upper_limit = self.end,
|
|
878
|
-
do_include_lower_limit = do_include_start,
|
|
879
|
-
do_include_upper_limit = do_include_end
|
|
880
|
-
)
|
|
881
|
-
|
|
882
869
|
"""
|
|
883
870
|
Apparently, the professional video editors use always
|
|
884
871
|
the `truncate` method to obtain the `start` of the
|
|
@@ -1047,8 +1034,7 @@ class NewTimeInterval:
|
|
|
1047
1034
|
# TODO: Rename, please
|
|
1048
1035
|
def get_trim_starts(
|
|
1049
1036
|
self,
|
|
1050
|
-
t_variation: Number
|
|
1051
|
-
limit: Union[Number, None] = None
|
|
1037
|
+
t_variation: Number
|
|
1052
1038
|
) -> tuple['NewTimeInterval', 'NewTimeInterval']:
|
|
1053
1039
|
"""
|
|
1054
1040
|
Get a tuple containing the 2 new `TimeInterval` instances
|
|
@@ -1073,15 +1059,13 @@ class NewTimeInterval:
|
|
|
1073
1059
|
return self.cutter.trim_start(
|
|
1074
1060
|
time_interval = self,
|
|
1075
1061
|
# TODO: maybe a 'decorator' to do this '_truncate' (?)
|
|
1076
|
-
t_variation = self._truncate(t_variation)
|
|
1077
|
-
limit = limit
|
|
1062
|
+
t_variation = self._truncate(t_variation)
|
|
1078
1063
|
)
|
|
1079
1064
|
|
|
1080
1065
|
# TODO: Rename, please
|
|
1081
1066
|
def get_trim_start(
|
|
1082
1067
|
self,
|
|
1083
|
-
t_variation: Number
|
|
1084
|
-
limit: Union[Number, None] = None
|
|
1068
|
+
t_variation: Number
|
|
1085
1069
|
) -> 'NewTimeInterval':
|
|
1086
1070
|
"""
|
|
1087
1071
|
Get this time interval instance but trimmed from the `start`
|
|
@@ -1096,14 +1080,12 @@ class NewTimeInterval:
|
|
|
1096
1080
|
returns a new one.
|
|
1097
1081
|
"""
|
|
1098
1082
|
return self.get_trim_starts(
|
|
1099
|
-
t_variation = t_variation
|
|
1100
|
-
limit = limit
|
|
1083
|
+
t_variation = t_variation
|
|
1101
1084
|
)[1]
|
|
1102
1085
|
|
|
1103
|
-
def
|
|
1086
|
+
def _trim_start(
|
|
1104
1087
|
self,
|
|
1105
|
-
t_variation: Number
|
|
1106
|
-
limit: Union[Number, None] = None
|
|
1088
|
+
t_variation: Number
|
|
1107
1089
|
) -> 'NewTimeInterval':
|
|
1108
1090
|
"""
|
|
1109
1091
|
(!) This method will modify this instance.
|
|
@@ -1115,8 +1097,7 @@ class NewTimeInterval:
|
|
|
1115
1097
|
This method returns this same instance but modified.
|
|
1116
1098
|
"""
|
|
1117
1099
|
cut = self.get_trim_start(
|
|
1118
|
-
t_variation = t_variation
|
|
1119
|
-
limit = limit
|
|
1100
|
+
t_variation = t_variation
|
|
1120
1101
|
)
|
|
1121
1102
|
|
|
1122
1103
|
self.start = cut.start
|
|
@@ -1149,18 +1130,18 @@ class NewTimeInterval:
|
|
|
1149
1130
|
The `t_variation` must be a positive value, the amount of
|
|
1150
1131
|
seconds to be trimmed.
|
|
1151
1132
|
"""
|
|
1133
|
+
ParameterValidator.validate_number_between('limit', limit, self.start, self.original_end)
|
|
1134
|
+
|
|
1152
1135
|
return self.cutter.trim_end(
|
|
1153
1136
|
time_interval = self,
|
|
1154
1137
|
# TODO: maybe a 'decorator' to do this '_truncate' (?)
|
|
1155
|
-
t_variation = self._truncate(t_variation)
|
|
1156
|
-
limit = limit
|
|
1138
|
+
t_variation = self._truncate(t_variation)
|
|
1157
1139
|
)
|
|
1158
1140
|
|
|
1159
1141
|
# TODO: Rename, please
|
|
1160
1142
|
def get_trim_end(
|
|
1161
1143
|
self,
|
|
1162
|
-
t_variation: Number
|
|
1163
|
-
limit: Union[Number, None] = None
|
|
1144
|
+
t_variation: Number
|
|
1164
1145
|
) -> 'NewTimeInterval':
|
|
1165
1146
|
"""
|
|
1166
1147
|
Get this time interval instance but trimmed from the `end`
|
|
@@ -1175,14 +1156,12 @@ class NewTimeInterval:
|
|
|
1175
1156
|
returns a new one.
|
|
1176
1157
|
"""
|
|
1177
1158
|
return self.get_trim_ends(
|
|
1178
|
-
t_variation = t_variation
|
|
1179
|
-
limit = limit
|
|
1159
|
+
t_variation = t_variation
|
|
1180
1160
|
)[0]
|
|
1181
1161
|
|
|
1182
|
-
def
|
|
1162
|
+
def _trim_end(
|
|
1183
1163
|
self,
|
|
1184
|
-
t_variation: Number
|
|
1185
|
-
limit: Union[Number, None] = None
|
|
1164
|
+
t_variation: Number
|
|
1186
1165
|
) -> 'NewTimeInterval':
|
|
1187
1166
|
"""
|
|
1188
1167
|
(!) This method will modify this instance.
|
|
@@ -1194,8 +1173,7 @@ class NewTimeInterval:
|
|
|
1194
1173
|
This method returns this same instance but modified.
|
|
1195
1174
|
"""
|
|
1196
1175
|
cut = self.get_trim_end(
|
|
1197
|
-
t_variation = t_variation
|
|
1198
|
-
limit = limit
|
|
1176
|
+
t_variation = t_variation
|
|
1199
1177
|
)
|
|
1200
1178
|
|
|
1201
1179
|
self.start = cut.start
|
|
@@ -1268,6 +1246,186 @@ class NewTimeInterval:
|
|
|
1268
1246
|
split_left, split_right
|
|
1269
1247
|
)
|
|
1270
1248
|
|
|
1249
|
+
def _extend_end(
|
|
1250
|
+
self,
|
|
1251
|
+
t_variation: Number
|
|
1252
|
+
) -> 'NewTimeInterval':
|
|
1253
|
+
"""
|
|
1254
|
+
(!) This method will modify this instance.
|
|
1255
|
+
|
|
1256
|
+
Transform this time interval into a new one in which
|
|
1257
|
+
the `end` has been extended the `t_variation` provided
|
|
1258
|
+
if the result respected the also given `limit`.
|
|
1259
|
+
|
|
1260
|
+
This method returns this same instance but modified.
|
|
1261
|
+
"""
|
|
1262
|
+
ParameterValidator.validate_mandatory_positive_number('t_variation', t_variation, do_include_zero = False)
|
|
1263
|
+
|
|
1264
|
+
extended = self.extender.extend_end(
|
|
1265
|
+
time_interval = self,
|
|
1266
|
+
t_variation = (
|
|
1267
|
+
self._truncate(t_variation)
|
|
1268
|
+
if self.fps is not None else
|
|
1269
|
+
t_variation
|
|
1270
|
+
)
|
|
1271
|
+
)
|
|
1272
|
+
|
|
1273
|
+
# TODO: Is this above a bit useless (?)
|
|
1274
|
+
self.end = extended.end
|
|
1275
|
+
|
|
1276
|
+
return self
|
|
1277
|
+
|
|
1278
|
+
def _extend_start(
|
|
1279
|
+
self,
|
|
1280
|
+
t_variation: Number
|
|
1281
|
+
) -> 'NewTimeInterval':
|
|
1282
|
+
"""
|
|
1283
|
+
(!) This method will modify this instance.
|
|
1284
|
+
|
|
1285
|
+
Transform this time interval into a new one in which
|
|
1286
|
+
the `start` has been extended the `t_variation` provided
|
|
1287
|
+
if the result respected the also given `limit`.
|
|
1288
|
+
|
|
1289
|
+
This method returns this same instance but modified.
|
|
1290
|
+
"""
|
|
1291
|
+
ParameterValidator.validate_mandatory_positive_number('t_variation', t_variation, do_include_zero = False)
|
|
1292
|
+
|
|
1293
|
+
extended = self.extender.extend_start(
|
|
1294
|
+
time_interval = self,
|
|
1295
|
+
t_variation = (
|
|
1296
|
+
self._truncate(t_variation)
|
|
1297
|
+
if self.fps is not None else
|
|
1298
|
+
t_variation
|
|
1299
|
+
)
|
|
1300
|
+
)
|
|
1301
|
+
|
|
1302
|
+
# TODO: Is this above a bit useless (?)
|
|
1303
|
+
self.start = extended.start
|
|
1304
|
+
|
|
1305
|
+
return self
|
|
1306
|
+
|
|
1307
|
+
def modify_start(
|
|
1308
|
+
self,
|
|
1309
|
+
t_variation: Number
|
|
1310
|
+
) -> 'NewTimeInterval':
|
|
1311
|
+
"""
|
|
1312
|
+
(!) This method will modify this instance.
|
|
1313
|
+
|
|
1314
|
+
Giving a negative `t_variation` value will make the
|
|
1315
|
+
time interval longer, extending the `start` value.
|
|
1316
|
+
|
|
1317
|
+
Transform this time interval into a new one in which
|
|
1318
|
+
the `start` has been extended or trimmed the
|
|
1319
|
+
`t_variation` value provided if the result respects
|
|
1320
|
+
the also given `limit`.
|
|
1321
|
+
|
|
1322
|
+
The new `start` can never be lower than the original
|
|
1323
|
+
(min) `start` value of this time interval instance.
|
|
1324
|
+
|
|
1325
|
+
This method returns this same instance but modified.
|
|
1326
|
+
"""
|
|
1327
|
+
ParameterValidator.validate_mandatory_number(t_variation, t_variation, do_include_zero = False)
|
|
1328
|
+
|
|
1329
|
+
return (
|
|
1330
|
+
self._trim_start(
|
|
1331
|
+
t_variation = abs(t_variation)
|
|
1332
|
+
)
|
|
1333
|
+
if t_variation > 0 else
|
|
1334
|
+
self._extend_start(
|
|
1335
|
+
t_variation = abs(t_variation)
|
|
1336
|
+
)
|
|
1337
|
+
)
|
|
1338
|
+
|
|
1339
|
+
def modify_start_to(
|
|
1340
|
+
self,
|
|
1341
|
+
start: Number
|
|
1342
|
+
) -> 'NewTimeInterval':
|
|
1343
|
+
"""
|
|
1344
|
+
(!) This method will modify this instance.
|
|
1345
|
+
|
|
1346
|
+
Transform this time interval into a new one in which
|
|
1347
|
+
the `start` has been extended or trimmed until
|
|
1348
|
+
reaching the new `start` parameter value provided (if
|
|
1349
|
+
valid).
|
|
1350
|
+
|
|
1351
|
+
The new `start` can never be lower than the original
|
|
1352
|
+
(min) `start` value of this time interval instance.
|
|
1353
|
+
|
|
1354
|
+
This method returns this same instance but modified.
|
|
1355
|
+
"""
|
|
1356
|
+
ParameterValidator.validate_mandatory_number(start, start, do_include_zero = True)
|
|
1357
|
+
|
|
1358
|
+
if (
|
|
1359
|
+
start >= self.original_start and
|
|
1360
|
+
start < self.end and
|
|
1361
|
+
start != self.start
|
|
1362
|
+
):
|
|
1363
|
+
self.start = start
|
|
1364
|
+
|
|
1365
|
+
return self
|
|
1366
|
+
|
|
1367
|
+
def modify_end(
|
|
1368
|
+
self,
|
|
1369
|
+
t_variation: Number,
|
|
1370
|
+
limit: Union[Number, None] = None
|
|
1371
|
+
) -> 'NewTimeInterval':
|
|
1372
|
+
"""
|
|
1373
|
+
(!) This method will modify this instance.
|
|
1374
|
+
|
|
1375
|
+
Giving a positive `t_variation` value will make the
|
|
1376
|
+
time interval longer, extending the `end` value.
|
|
1377
|
+
|
|
1378
|
+
Transform this time interval into a new one in which
|
|
1379
|
+
the `end` has been extended or trimmed the
|
|
1380
|
+
`t_variation` value provided if the result respects
|
|
1381
|
+
the also given `limit`.
|
|
1382
|
+
|
|
1383
|
+
The new `end` can never be greater than the original
|
|
1384
|
+
(min) `end` value of this time interval instance.
|
|
1385
|
+
|
|
1386
|
+
This method returns this same instance but modified.
|
|
1387
|
+
"""
|
|
1388
|
+
ParameterValidator.validate_mandatory_number(t_variation, t_variation, do_include_zero = False)
|
|
1389
|
+
|
|
1390
|
+
return (
|
|
1391
|
+
self._trim_end(
|
|
1392
|
+
t_variation = abs(t_variation)
|
|
1393
|
+
)
|
|
1394
|
+
if t_variation < 0 else
|
|
1395
|
+
self._extend_end(
|
|
1396
|
+
t_variation = abs(t_variation)
|
|
1397
|
+
)
|
|
1398
|
+
)
|
|
1399
|
+
|
|
1400
|
+
def modify_end_to(
|
|
1401
|
+
self,
|
|
1402
|
+
t: Number
|
|
1403
|
+
) -> 'NewTimeInterval':
|
|
1404
|
+
"""
|
|
1405
|
+
(!) This method will modify this instance.
|
|
1406
|
+
|
|
1407
|
+
Transform this time interval into a new one in which
|
|
1408
|
+
the `end` has been extended or trimmed until
|
|
1409
|
+
reaching the new `t` parameter value provided (if
|
|
1410
|
+
valid).
|
|
1411
|
+
|
|
1412
|
+
The new `end` can never be greater than the original
|
|
1413
|
+
(min) `end` value of this time interval instance.
|
|
1414
|
+
|
|
1415
|
+
This method returns this same instance but modified.
|
|
1416
|
+
"""
|
|
1417
|
+
ParameterValidator.validate_mandatory_number(t, t, do_include_zero = True)
|
|
1418
|
+
|
|
1419
|
+
if (
|
|
1420
|
+
t <= self.original_end and
|
|
1421
|
+
t > self.start and
|
|
1422
|
+
t != self.end
|
|
1423
|
+
):
|
|
1424
|
+
self.end = t
|
|
1425
|
+
|
|
1426
|
+
return self
|
|
1427
|
+
|
|
1428
|
+
|
|
1271
1429
|
# TODO: Implement 'extend' methods using the 'original'
|
|
1272
1430
|
# values
|
|
1273
1431
|
|
|
@@ -1452,14 +1610,6 @@ class TimeIntervalCutter:
|
|
|
1452
1610
|
time intervals.
|
|
1453
1611
|
"""
|
|
1454
1612
|
|
|
1455
|
-
"""
|
|
1456
|
-
TODO: Methods I have to implement:
|
|
1457
|
-
trim_end → recorta la parte final
|
|
1458
|
-
trim_start → recorta la parte inicial
|
|
1459
|
-
cut_segment → elimina un tramo [a, b)
|
|
1460
|
-
split_at → divide en dos en un punto dado
|
|
1461
|
-
"""
|
|
1462
|
-
|
|
1463
1613
|
@staticmethod
|
|
1464
1614
|
# @parameter_to_time_interval('time_interval')
|
|
1465
1615
|
@parameter_to_new_time_interval('time_interval')
|
|
@@ -1476,8 +1626,8 @@ class TimeIntervalCutter:
|
|
|
1476
1626
|
The `t` time moment provided must be a value between the
|
|
1477
1627
|
`start` and `end` of the `time_interval` provided.
|
|
1478
1628
|
"""
|
|
1479
|
-
time_interval
|
|
1480
|
-
|
|
1629
|
+
_validate_new_time_interval_current_limits(time_interval, t)
|
|
1630
|
+
|
|
1481
1631
|
return (
|
|
1482
1632
|
TimeInterval(
|
|
1483
1633
|
start = time_interval.start,
|
|
@@ -1494,8 +1644,7 @@ class TimeIntervalCutter:
|
|
|
1494
1644
|
@parameter_to_new_time_interval('time_interval')
|
|
1495
1645
|
def trim_end(
|
|
1496
1646
|
time_interval: TimeIntervalType,
|
|
1497
|
-
t_variation: Number
|
|
1498
|
-
limit: Union[Number, None] = None,
|
|
1647
|
+
t_variation: Number
|
|
1499
1648
|
) -> tuple['TimeInterval', 'TimeInterval']:
|
|
1500
1649
|
"""
|
|
1501
1650
|
Get a tuple containing the 2 new `TimeInterval` instances
|
|
@@ -1504,39 +1653,14 @@ class TimeIntervalCutter:
|
|
|
1504
1653
|
first tuple is the requested by the user, and the second one
|
|
1505
1654
|
is the remaining.
|
|
1506
1655
|
|
|
1507
|
-
This method will raise an exception if the new `end` value
|
|
1508
|
-
becomes a value under the time interval `start` value or
|
|
1509
|
-
the `limit`, that must be greater than the `start` and lower
|
|
1510
|
-
than the time interval `end` value.
|
|
1511
|
-
|
|
1512
1656
|
The `t_variation` must be a positive value, the amount of
|
|
1513
1657
|
seconds to be trimmed.
|
|
1514
1658
|
"""
|
|
1515
1659
|
ParameterValidator.validate_mandatory_positive_number('t_variation', t_variation, do_include_zero = False)
|
|
1516
|
-
ParameterValidator.validate_number_between('limit', limit, time_interval.start, time_interval.end, False, False)
|
|
1517
|
-
|
|
1518
|
-
new_end = time_interval.end - t_variation
|
|
1519
|
-
limit = (
|
|
1520
|
-
time_interval.start
|
|
1521
|
-
if limit is None else
|
|
1522
|
-
limit
|
|
1523
|
-
)
|
|
1524
1660
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
if new_end <= limit:
|
|
1529
|
-
raise Exception('The "t_variation" value provided makes the new end value be lower than the "limit" value provided.')
|
|
1530
|
-
|
|
1531
|
-
return (
|
|
1532
|
-
TimeInterval(
|
|
1533
|
-
start = time_interval.start,
|
|
1534
|
-
end = new_end
|
|
1535
|
-
),
|
|
1536
|
-
TimeInterval(
|
|
1537
|
-
start = new_end,
|
|
1538
|
-
end = time_interval.end
|
|
1539
|
-
)
|
|
1661
|
+
return TimeIntervalCutter.trim_end_to(
|
|
1662
|
+
time_interval = time_interval,
|
|
1663
|
+
t = time_interval.end - t_variation
|
|
1540
1664
|
)
|
|
1541
1665
|
|
|
1542
1666
|
@staticmethod
|
|
@@ -1555,8 +1679,8 @@ class TimeIntervalCutter:
|
|
|
1555
1679
|
The `t` time moment provided must be a value between the
|
|
1556
1680
|
`start` and `end` of the `time_interval` provided.
|
|
1557
1681
|
"""
|
|
1558
|
-
time_interval
|
|
1559
|
-
|
|
1682
|
+
_validate_new_time_interval_current_limits(time_interval, t)
|
|
1683
|
+
|
|
1560
1684
|
return (
|
|
1561
1685
|
TimeInterval(
|
|
1562
1686
|
start = time_interval.start,
|
|
@@ -1573,8 +1697,7 @@ class TimeIntervalCutter:
|
|
|
1573
1697
|
@parameter_to_new_time_interval('time_interval')
|
|
1574
1698
|
def trim_start(
|
|
1575
1699
|
time_interval: TimeIntervalType,
|
|
1576
|
-
t_variation: Number
|
|
1577
|
-
limit: Union[Number, None] = None,
|
|
1700
|
+
t_variation: Number
|
|
1578
1701
|
) -> tuple['TimeInterval', 'TimeInterval']:
|
|
1579
1702
|
"""
|
|
1580
1703
|
Get a tuple containing the 2 new `TimeInterval` instances
|
|
@@ -1583,39 +1706,14 @@ class TimeIntervalCutter:
|
|
|
1583
1706
|
first tuple is the remaining, and the second one is the
|
|
1584
1707
|
new time interval requested by the user.
|
|
1585
1708
|
|
|
1586
|
-
This method will raise an exception if the new `end` value
|
|
1587
|
-
becomes a value under the time interval `start` value or
|
|
1588
|
-
the `limit`, that must be greater than the `start` and lower
|
|
1589
|
-
than the time interval `end` value.
|
|
1590
|
-
|
|
1591
1709
|
The `t_variation` must be a positive value, the amount of
|
|
1592
1710
|
seconds to be trimmed.
|
|
1593
1711
|
"""
|
|
1594
1712
|
ParameterValidator.validate_mandatory_positive_number('t_variation', t_variation, do_include_zero = False)
|
|
1595
|
-
ParameterValidator.validate_number_between('limit', limit, time_interval.start, time_interval.end, False, False)
|
|
1596
1713
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
time_interval.
|
|
1600
|
-
if limit is None else
|
|
1601
|
-
limit
|
|
1602
|
-
)
|
|
1603
|
-
|
|
1604
|
-
if new_start >= time_interval.end:
|
|
1605
|
-
raise Exception('The "t_variation" value provided makes the new end value be lower than the "end" value.')
|
|
1606
|
-
|
|
1607
|
-
if new_start >= limit:
|
|
1608
|
-
raise Exception('The "t_variation" value provided makes the new end value be greater than the "limit" value provided.')
|
|
1609
|
-
|
|
1610
|
-
return (
|
|
1611
|
-
TimeInterval(
|
|
1612
|
-
start = time_interval.start,
|
|
1613
|
-
end = new_start
|
|
1614
|
-
),
|
|
1615
|
-
TimeInterval(
|
|
1616
|
-
start = new_start,
|
|
1617
|
-
end = time_interval.end
|
|
1618
|
-
)
|
|
1714
|
+
return TimeIntervalCutter.trim_start_to(
|
|
1715
|
+
time_interval = time_interval,
|
|
1716
|
+
t = time_interval.start + t_variation
|
|
1619
1717
|
)
|
|
1620
1718
|
|
|
1621
1719
|
@staticmethod
|
|
@@ -1654,8 +1752,8 @@ class TimeIntervalCutter:
|
|
|
1654
1752
|
which you are calling to this one) to choose the tuple you
|
|
1655
1753
|
want to return.
|
|
1656
1754
|
"""
|
|
1657
|
-
time_interval
|
|
1658
|
-
time_interval
|
|
1755
|
+
_validate_new_time_interval_current_limits(time_interval, start)
|
|
1756
|
+
_validate_new_time_interval_current_limits(time_interval, end)
|
|
1659
1757
|
|
|
1660
1758
|
return (
|
|
1661
1759
|
# TODO: What about this case, should we raise except (?)
|
|
@@ -1716,9 +1814,9 @@ class TimeIntervalCutter:
|
|
|
1716
1814
|
# @parameter_to_time_interval('time_interval')
|
|
1717
1815
|
@parameter_to_new_time_interval('time_interval')
|
|
1718
1816
|
def split(
|
|
1719
|
-
time_interval:
|
|
1817
|
+
time_interval: NewTimeInterval,
|
|
1720
1818
|
t: Number,
|
|
1721
|
-
) -> tuple[
|
|
1819
|
+
) -> tuple[NewTimeInterval, NewTimeInterval]:
|
|
1722
1820
|
"""
|
|
1723
1821
|
Split the interval at the provided `t` time moment and
|
|
1724
1822
|
get the 2 new time intervals as a result (as a tuple).
|
|
@@ -1753,6 +1851,135 @@ class TimeIntervalCutter:
|
|
|
1753
1851
|
)
|
|
1754
1852
|
)
|
|
1755
1853
|
|
|
1854
|
+
# TODO: Mix this class with the cutter and make single
|
|
1855
|
+
# methods able to extend or cut based on if the variation
|
|
1856
|
+
# is positive or negative
|
|
1857
|
+
class TimeIntervalExtender:
|
|
1858
|
+
"""
|
|
1859
|
+
Class to wrap the functionality related to extending
|
|
1860
|
+
"""
|
|
1861
|
+
|
|
1862
|
+
@staticmethod
|
|
1863
|
+
@parameter_to_new_time_interval('time_interval')
|
|
1864
|
+
def extend_end(
|
|
1865
|
+
time_interval: 'NewTimeInterval',
|
|
1866
|
+
t_variation: Number
|
|
1867
|
+
):
|
|
1868
|
+
"""
|
|
1869
|
+
Extend the end of the given `time_interval` the `t_variation`
|
|
1870
|
+
amount of seconds provided.
|
|
1871
|
+
"""
|
|
1872
|
+
ParameterValidator.validate_mandatory_positive_number('t_variation', t_variation, do_include_zero = False)
|
|
1873
|
+
|
|
1874
|
+
return TimeIntervalExtender.extend_end_to(
|
|
1875
|
+
time_interval = time_interval,
|
|
1876
|
+
t = time_interval.end + t_variation
|
|
1877
|
+
)
|
|
1878
|
+
|
|
1879
|
+
@staticmethod
|
|
1880
|
+
@parameter_to_new_time_interval('time_interval')
|
|
1881
|
+
def extend_end_to(
|
|
1882
|
+
time_interval: 'NewTimeInterval',
|
|
1883
|
+
t: Number
|
|
1884
|
+
):
|
|
1885
|
+
"""
|
|
1886
|
+
Extend the end of the given `time_interval` the to the `t`
|
|
1887
|
+
time moment provided.
|
|
1888
|
+
"""
|
|
1889
|
+
_validate_new_time_interval_original_limits(time_interval, t)
|
|
1890
|
+
|
|
1891
|
+
if t < time_interval.end:
|
|
1892
|
+
raise Exception('The "t" parameter provided is lower than the current time interval `end` and this method is to extend it.')
|
|
1893
|
+
|
|
1894
|
+
return NewTimeInterval(
|
|
1895
|
+
start = time_interval.start,
|
|
1896
|
+
end = t,
|
|
1897
|
+
fps = time_interval.fps
|
|
1898
|
+
)
|
|
1899
|
+
|
|
1900
|
+
@staticmethod
|
|
1901
|
+
@parameter_to_new_time_interval('time_interval')
|
|
1902
|
+
def extend_start(
|
|
1903
|
+
time_interval: 'NewTimeInterval',
|
|
1904
|
+
t_variation: Number
|
|
1905
|
+
):
|
|
1906
|
+
"""
|
|
1907
|
+
Extend the start of the given `time_interval` the `t_variation`
|
|
1908
|
+
amount of seconds provided if the new `start` is greater than
|
|
1909
|
+
the `limit` provided and than the original (and min) `start`
|
|
1910
|
+
value of the time interval.
|
|
1911
|
+
"""
|
|
1912
|
+
ParameterValidator.validate_mandatory_positive_number('t_variation', t_variation, do_include_zero = False)
|
|
1913
|
+
|
|
1914
|
+
return TimeIntervalExtender.extend_start_to(
|
|
1915
|
+
time_interval = time_interval,
|
|
1916
|
+
t = time_interval.start - t_variation
|
|
1917
|
+
)
|
|
1918
|
+
|
|
1919
|
+
@staticmethod
|
|
1920
|
+
@parameter_to_new_time_interval('time_interval')
|
|
1921
|
+
def extend_start_to(
|
|
1922
|
+
time_interval: 'NewTimeInterval',
|
|
1923
|
+
t: Number
|
|
1924
|
+
):
|
|
1925
|
+
"""
|
|
1926
|
+
Extend the start of the given `time_interval` the to the `t`
|
|
1927
|
+
time moment provided.
|
|
1928
|
+
"""
|
|
1929
|
+
_validate_new_time_interval_original_limits(time_interval, t)
|
|
1930
|
+
|
|
1931
|
+
if t > time_interval.start:
|
|
1932
|
+
raise Exception('The "t" parameter provided is greater than the current time interval `start` and this method is to extend it.')
|
|
1933
|
+
|
|
1934
|
+
return NewTimeInterval(
|
|
1935
|
+
start = t,
|
|
1936
|
+
end = time_interval.end,
|
|
1937
|
+
fps = time_interval.fps
|
|
1938
|
+
)
|
|
1939
|
+
|
|
1940
|
+
def _validate_new_time_interval_original_limits(
|
|
1941
|
+
time_interval: NewTimeInterval,
|
|
1942
|
+
t: Number
|
|
1943
|
+
) -> None:
|
|
1944
|
+
"""
|
|
1945
|
+
*For internal use only*
|
|
1946
|
+
|
|
1947
|
+
This method will raise an exception if the `t` time moment
|
|
1948
|
+
parameter value provided is out of the `time_interval`
|
|
1949
|
+
original limits.
|
|
1950
|
+
|
|
1951
|
+
TODO: How and where to put this (?)
|
|
1952
|
+
"""
|
|
1953
|
+
if (
|
|
1954
|
+
t < time_interval.original_start or
|
|
1955
|
+
t > time_interval.original_end
|
|
1956
|
+
):
|
|
1957
|
+
raise Exception(f'The "t" parameter value provided ({str(float(t))}) is out of the time interval original limits (max and min) [{str(float(time_interval.original_start))}, {str(float(time_interval.original_end))}].')
|
|
1958
|
+
|
|
1959
|
+
def _validate_new_time_interval_current_limits(
|
|
1960
|
+
time_interval: NewTimeInterval,
|
|
1961
|
+
t: Number
|
|
1962
|
+
) -> None:
|
|
1963
|
+
"""
|
|
1964
|
+
*For internal use only*
|
|
1965
|
+
|
|
1966
|
+
This method will raise an exception if the `t` time moment
|
|
1967
|
+
parameter value provided is out of the `time_interval`
|
|
1968
|
+
current limits (current `start` and `end`).
|
|
1969
|
+
|
|
1970
|
+
This method is useful when we are cutting or splitting the
|
|
1971
|
+
time interval so the parameter value must be always within
|
|
1972
|
+
the current time range.
|
|
1973
|
+
|
|
1974
|
+
TODO: How and where to put this (?)
|
|
1975
|
+
"""
|
|
1976
|
+
if (
|
|
1977
|
+
t < time_interval.start or
|
|
1978
|
+
t > time_interval.end
|
|
1979
|
+
):
|
|
1980
|
+
raise Exception(f'The "t" parameter value provided ({str(float(t))}) is out of the time interval current limits [{str(float(time_interval.start))}, {str(float(time_interval.end))}].')
|
|
1981
|
+
|
|
1982
|
+
|
|
1756
1983
|
# TODO: Maybe add some 'extend' functionality
|
|
1757
1984
|
|
|
1758
1985
|
# # TODO: This method is interesting if we don't want only to
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
yta_video_frame_time/__init__.py,sha256=-YOa7lOKdiA3FwDEHHU1tHobnmhjFpTaVLfJQLZqoMI,22252
|
|
2
|
+
yta_video_frame_time/decorators.py,sha256=tPFaDP7Iu9SXVg6raJ26QfHJ-81uzgFZv88SvBZ5RnE,2848
|
|
3
|
+
yta_video_frame_time/interval.py,sha256=LWJtUycyu8LZ3SfzC4XjgAU3teP3rQGl679kBbaDB0c,69643
|
|
4
|
+
yta_video_frame_time/t_fraction.py,sha256=YBOnH-Shs2YKSKFvm84EbFfvzXmg4AyNnyKd_hzF3Uk,29216
|
|
5
|
+
yta_video_frame_time-0.0.17.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
6
|
+
yta_video_frame_time-0.0.17.dist-info/METADATA,sha256=I0yY3Havxt5unlEmTlSDdu3ztlqd3TfzTqzapUQTHxM,538
|
|
7
|
+
yta_video_frame_time-0.0.17.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
|
|
8
|
+
yta_video_frame_time-0.0.17.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
yta_video_frame_time/__init__.py,sha256=-YOa7lOKdiA3FwDEHHU1tHobnmhjFpTaVLfJQLZqoMI,22252
|
|
2
|
-
yta_video_frame_time/decorators.py,sha256=tPFaDP7Iu9SXVg6raJ26QfHJ-81uzgFZv88SvBZ5RnE,2848
|
|
3
|
-
yta_video_frame_time/interval.py,sha256=2Ru5QMT1Une3TPMyX1h-PnZduTYe76PqlF_nisfENqU,62489
|
|
4
|
-
yta_video_frame_time/t_fraction.py,sha256=YBOnH-Shs2YKSKFvm84EbFfvzXmg4AyNnyKd_hzF3Uk,29216
|
|
5
|
-
yta_video_frame_time-0.0.16.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
6
|
-
yta_video_frame_time-0.0.16.dist-info/METADATA,sha256=b4WIjTN2oziXRwUt4bakBqClD_rCoEZJ9fUDlyMKPqs,538
|
|
7
|
-
yta_video_frame_time-0.0.16.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
|
|
8
|
-
yta_video_frame_time-0.0.16.dist-info/RECORD,,
|
|
File without changes
|
{yta_video_frame_time-0.0.16.dist-info → yta_video_frame_time-0.0.17.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|