yta-video-frame-time 0.0.6__py3-none-any.whl → 0.0.7__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.

Potentially problematic release.


This version of yta-video-frame-time might be problematic. Click here for more details.

@@ -302,6 +302,9 @@ class _T:
302
302
  None, we will not make any conversion
303
303
  and the value received could be useless
304
304
  because it is in the middle of a range.
305
+
306
+ The formula:
307
+ - `pts * time_base`
305
308
  """
306
309
  pts = (
307
310
  self._t_handler.pts.truncated(pts)
@@ -322,8 +325,47 @@ class _T:
322
325
  Transform the given 't' to a 'pts' value
323
326
  truncating, rounding or applying no
324
327
  variation.
328
+
329
+ The formula:
330
+ - `int(t / time_base)`
325
331
  """
326
332
  return self._t_handler.pts.from_t(t, do_truncate)
333
+
334
+ def to_index(
335
+ self,
336
+ t: Union[int, float, Fraction],
337
+ do_truncate: Union[bool, None] = True
338
+ ) -> int:
339
+ """
340
+ Transform the given 't' to a index value
341
+ truncating, rounding or applying no
342
+ variation.
343
+
344
+ The formula:
345
+ - `int(t * fps)`
346
+ """
347
+ t = (
348
+ self.truncated(t)
349
+ if do_truncate is True else
350
+ self.rounded(t)
351
+ if do_truncate is False else
352
+ t
353
+ )
354
+
355
+ return frame_t_to_index(t, self.fps)
356
+
357
+ def from_index(
358
+ self,
359
+ index: int
360
+ ) -> Fraction:
361
+ """
362
+ Transform the given index to a 't' time
363
+ moment value.
364
+
365
+ The formula:
366
+ - `frame_index * (1 / fps)`
367
+ """
368
+ return frame_index_to_t(index, self.fps)
327
369
 
328
370
  def truncated(
329
371
  self,
@@ -367,6 +409,9 @@ class _T:
367
409
 
368
410
  Useful when you need the next value for a
369
411
  range in an iteration or similar.
412
+
413
+ The formula:
414
+ - `t + n * (1 / fps)`
370
415
  """
371
416
  t = (
372
417
  self.truncated(t)
@@ -374,7 +419,7 @@ class _T:
374
419
  self.rounded(t)
375
420
  )
376
421
 
377
- return t + n * self._t_handler.time_base
422
+ return t + n * (1 / self._t_handler.fps)
378
423
 
379
424
  def previous(
380
425
  self,
@@ -395,6 +440,9 @@ class _T:
395
440
  Be careful, if the 'truncated' value is 0
396
441
  this will give you an unexpected negative
397
442
  value.
443
+
444
+ The formula:
445
+ - `t - n * (1 / fps)`
398
446
  """
399
447
  t = (
400
448
  self.truncated(t)
@@ -402,7 +450,7 @@ class _T:
402
450
  self.rounded(t)
403
451
  )
404
452
 
405
- return t - n * self._t_handler.time_base
453
+ return t - n * (1 / self._t_handler.fps)
406
454
 
407
455
  class _Pts:
408
456
  """
@@ -442,6 +490,9 @@ class _Pts:
442
490
  None, we will not make any conversion
443
491
  and the value received could be useless
444
492
  because it is in the middle of a range.
493
+
494
+ The formula:
495
+ - `int(t / time_base)`
445
496
  """
446
497
  t = (
447
498
  self._t_handler.t.truncated(t)
@@ -462,8 +513,45 @@ class _Pts:
462
513
  Transform the given 'pts' to a 't' value
463
514
  truncating, rounding or applying no
464
515
  variation.
516
+
517
+ The formula:
518
+ - `pts * time_base`
465
519
  """
466
520
  return self._t_handler.t.from_pts(pts, do_truncate)
521
+
522
+ def to_index(
523
+ self,
524
+ pts: int,
525
+ do_truncate: Union[bool, None] = True
526
+ ) -> int:
527
+ """
528
+ Transform the given 'pts' to a index value
529
+ truncating, rounding or applying no
530
+ variation.
531
+
532
+ The formula:
533
+ - `int((pts * time_base) * fps)`
534
+ """
535
+ return self._t_handler.t.to_index(
536
+ self.to_t(pts, do_truncate = None),
537
+ do_truncate = do_truncate
538
+ )
539
+
540
+ def from_index(
541
+ self,
542
+ index: int
543
+ ) -> Fraction:
544
+ """
545
+ Transform the given index to a 't' time
546
+ moment value.
547
+
548
+ The formula:
549
+ - `int((frame_index * (1 / fps)) * time_base)`
550
+ """
551
+ return self.from_t(
552
+ t = self._t_handler.t.from_index(index),
553
+ do_truncate = True
554
+ )
467
555
 
468
556
  def truncated(
469
557
  self,
@@ -517,6 +605,9 @@ class _Pts:
517
605
 
518
606
  Useful when you need the next value for a
519
607
  range in an iteration or similar.
608
+
609
+ The formula:
610
+ - `pts + n * ticks_per_frame`
520
611
  """
521
612
  pts = (
522
613
  self.truncated(pts)
@@ -545,6 +636,9 @@ class _Pts:
545
636
  Be careful, if the 'truncated' value is 0
546
637
  this will give you an unexpected negative
547
638
  value.
639
+
640
+ The formula:
641
+ - `pts - n * ticks_per_frame`
548
642
  """
549
643
  pts = (
550
644
  self.truncated(pts)
@@ -680,6 +774,9 @@ def get_ticks_per_frame(
680
774
  tick is the minimum amount of time we
681
775
  spend from one frame to the next.
682
776
 
777
+ (!) This is only valid for video
778
+ apparently.
779
+
683
780
  The formula:
684
781
  - `1 / (fps * time_base)`
685
782
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yta-video-frame-time
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: Youtube Autonomous Video Frame Time Module
5
5
  Author: danialcala94
6
6
  Author-email: danielalcalavalera@gmail.com
@@ -0,0 +1,6 @@
1
+ yta_video_frame_time/__init__.py,sha256=-YOa7lOKdiA3FwDEHHU1tHobnmhjFpTaVLfJQLZqoMI,22252
2
+ yta_video_frame_time/t_fraction.py,sha256=hsCNZajG98XGnWYI0T6wSfBnAK3vf7ZiFI_GZHO8yRI,22254
3
+ yta_video_frame_time-0.0.7.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
+ yta_video_frame_time-0.0.7.dist-info/METADATA,sha256=ooHYnwkytyyjpKRKLKakXhDJJD-HAmpXxvWuaXfVrZo,515
5
+ yta_video_frame_time-0.0.7.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
+ yta_video_frame_time-0.0.7.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- yta_video_frame_time/__init__.py,sha256=-YOa7lOKdiA3FwDEHHU1tHobnmhjFpTaVLfJQLZqoMI,22252
2
- yta_video_frame_time/t_fraction.py,sha256=c0sz-ncVV_Qt--rM2k1xKyjZpPF_pH5bFKPFx6WmxQc,20027
3
- yta_video_frame_time-0.0.6.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
- yta_video_frame_time-0.0.6.dist-info/METADATA,sha256=is6UfhRMg48ToFwXBgwHOuPT2K6aqGTSt05KedCnAiw,515
5
- yta_video_frame_time-0.0.6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
- yta_video_frame_time-0.0.6.dist-info/RECORD,,