yta-video-frame-time 0.0.7__py3-none-any.whl → 0.0.8__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.
- yta_video_frame_time/t_fraction.py +100 -4
- {yta_video_frame_time-0.0.7.dist-info → yta_video_frame_time-0.0.8.dist-info}/METADATA +1 -1
- yta_video_frame_time-0.0.8.dist-info/RECORD +6 -0
- yta_video_frame_time-0.0.7.dist-info/RECORD +0 -6
- {yta_video_frame_time-0.0.7.dist-info → yta_video_frame_time-0.0.8.dist-info}/LICENSE +0 -0
- {yta_video_frame_time-0.0.7.dist-info → yta_video_frame_time-0.0.8.dist-info}/WHEEL +0 -0
|
@@ -238,6 +238,8 @@ def round_pts(
|
|
|
238
238
|
and 'time_base', but here is an easier
|
|
239
239
|
example using the time moments.
|
|
240
240
|
|
|
241
|
+
(!) This is valid only for video.
|
|
242
|
+
|
|
241
243
|
Examples below, with `time_base = 1/5`:
|
|
242
244
|
- `t = 0.25` => `0.2` (truncated or rounded)
|
|
243
245
|
- `t = 0.35` => `0.2` (truncated)
|
|
@@ -256,8 +258,6 @@ def round_pts(
|
|
|
256
258
|
|
|
257
259
|
return int(frame_index * ticks_per_frame)
|
|
258
260
|
|
|
259
|
-
# TODO: Create a 'round_pts'
|
|
260
|
-
|
|
261
261
|
"""
|
|
262
262
|
When we are working with the 't' time
|
|
263
263
|
moment we need to use the fps, and when
|
|
@@ -306,6 +306,18 @@ class _T:
|
|
|
306
306
|
The formula:
|
|
307
307
|
- `pts * time_base`
|
|
308
308
|
"""
|
|
309
|
+
t = Fraction(pts * self._t_handler.time_base)
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
self._t_handler.t.truncated(t)
|
|
313
|
+
if do_truncate is True else
|
|
314
|
+
self._t_handler.t.rounded(t)
|
|
315
|
+
if do_truncate is False else
|
|
316
|
+
t # if None
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
# TODO: Remove this below in the next
|
|
320
|
+
# commit
|
|
309
321
|
pts = (
|
|
310
322
|
self._t_handler.pts.truncated(pts)
|
|
311
323
|
if do_truncate is True else
|
|
@@ -552,6 +564,16 @@ class _Pts:
|
|
|
552
564
|
t = self._t_handler.t.from_index(index),
|
|
553
565
|
do_truncate = True
|
|
554
566
|
)
|
|
567
|
+
|
|
568
|
+
"""
|
|
569
|
+
This about the pts is not 100% sure as it
|
|
570
|
+
is only a value to display the frames but
|
|
571
|
+
not accurate and depends on the encoder.
|
|
572
|
+
|
|
573
|
+
Maybe we don't want all this functionality
|
|
574
|
+
but only the one that is 100% sure its
|
|
575
|
+
working properly.
|
|
576
|
+
"""
|
|
555
577
|
|
|
556
578
|
def truncated(
|
|
557
579
|
self,
|
|
@@ -563,6 +585,8 @@ class _Pts:
|
|
|
563
585
|
This means that if 't' is in a
|
|
564
586
|
[start, end) range, we will obtain the
|
|
565
587
|
'start' value always.
|
|
588
|
+
|
|
589
|
+
(!) This is valid only for video
|
|
566
590
|
"""
|
|
567
591
|
return round_pts(
|
|
568
592
|
pts = pts,
|
|
@@ -583,6 +607,8 @@ class _Pts:
|
|
|
583
607
|
the 'start' or the 'end' value according
|
|
584
608
|
to which one is closer to the that 't'
|
|
585
609
|
value provided.
|
|
610
|
+
|
|
611
|
+
(!) This is valid only for video.
|
|
586
612
|
"""
|
|
587
613
|
return round_pts(
|
|
588
614
|
pts = pts,
|
|
@@ -591,7 +617,7 @@ class _Pts:
|
|
|
591
617
|
do_truncate = False
|
|
592
618
|
)
|
|
593
619
|
|
|
594
|
-
def
|
|
620
|
+
def next_video(
|
|
595
621
|
self,
|
|
596
622
|
pts: int,
|
|
597
623
|
n: int = 1,
|
|
@@ -606,6 +632,8 @@ class _Pts:
|
|
|
606
632
|
Useful when you need the next value for a
|
|
607
633
|
range in an iteration or similar.
|
|
608
634
|
|
|
635
|
+
(!) This is valid only for video.
|
|
636
|
+
|
|
609
637
|
The formula:
|
|
610
638
|
- `pts + n * ticks_per_frame`
|
|
611
639
|
"""
|
|
@@ -617,7 +645,32 @@ class _Pts:
|
|
|
617
645
|
|
|
618
646
|
return pts + n * get_ticks_per_frame(self._t_handler.fps, self._t_handler.time_base)
|
|
619
647
|
|
|
620
|
-
def
|
|
648
|
+
def next_audio(
|
|
649
|
+
self,
|
|
650
|
+
pts: int,
|
|
651
|
+
samples_per_frame: int,
|
|
652
|
+
n: int = 1
|
|
653
|
+
) -> int:
|
|
654
|
+
"""
|
|
655
|
+
Get the value that is 'n' times ahead of
|
|
656
|
+
the 'pts' value provided according to the
|
|
657
|
+
number of 'samples_per_frame' each frame
|
|
658
|
+
has.
|
|
659
|
+
|
|
660
|
+
TODO: Are we sure that the number of
|
|
661
|
+
samples per frame is always the same (?)
|
|
662
|
+
|
|
663
|
+
Useful when you need the next value for a
|
|
664
|
+
range in an iteration or similar.
|
|
665
|
+
|
|
666
|
+
(!) This is valid only for audio.
|
|
667
|
+
|
|
668
|
+
The formula:
|
|
669
|
+
- `pts + (n * samples_per_frame)`
|
|
670
|
+
"""
|
|
671
|
+
return pts + (n * samples_per_frame)
|
|
672
|
+
|
|
673
|
+
def previous_video(
|
|
621
674
|
self,
|
|
622
675
|
pts: int,
|
|
623
676
|
n: int = 1,
|
|
@@ -637,6 +690,8 @@ class _Pts:
|
|
|
637
690
|
this will give you an unexpected negative
|
|
638
691
|
value.
|
|
639
692
|
|
|
693
|
+
(!) This is valid only for video.
|
|
694
|
+
|
|
640
695
|
The formula:
|
|
641
696
|
- `pts - n * ticks_per_frame`
|
|
642
697
|
"""
|
|
@@ -647,6 +702,31 @@ class _Pts:
|
|
|
647
702
|
)
|
|
648
703
|
|
|
649
704
|
return pts - n * get_ticks_per_frame(self._t_handler.fps, self._t_handler.time_base)
|
|
705
|
+
|
|
706
|
+
def previous_audio(
|
|
707
|
+
self,
|
|
708
|
+
pts: int,
|
|
709
|
+
samples_per_frame: int,
|
|
710
|
+
n: int = 1
|
|
711
|
+
) -> int:
|
|
712
|
+
"""
|
|
713
|
+
Get the value that is 'n' times before
|
|
714
|
+
the 'pts' value provided according to the
|
|
715
|
+
number of 'samples_per_frame' each frame
|
|
716
|
+
has.
|
|
717
|
+
|
|
718
|
+
TODO: Are we sure that the number of
|
|
719
|
+
samples per frame is always the same (?)
|
|
720
|
+
|
|
721
|
+
Useful when you need the next value for a
|
|
722
|
+
range in an iteration or similar.
|
|
723
|
+
|
|
724
|
+
(!) This is valid only for audio.
|
|
725
|
+
|
|
726
|
+
The formula:
|
|
727
|
+
- `pts - (n * samples_per_frame)`
|
|
728
|
+
"""
|
|
729
|
+
return pts - (n * samples_per_frame)
|
|
650
730
|
|
|
651
731
|
class THandler:
|
|
652
732
|
"""
|
|
@@ -745,6 +825,8 @@ def frame_t_to_pts(
|
|
|
745
825
|
moment provided, based on the also provided
|
|
746
826
|
'fps' and 'time_base'.
|
|
747
827
|
|
|
828
|
+
(!) This is valid only for videos.
|
|
829
|
+
|
|
748
830
|
The formula:
|
|
749
831
|
- `frame_index * ticks_per_frame`
|
|
750
832
|
"""
|
|
@@ -764,6 +846,20 @@ def frame_pts_to_t(
|
|
|
764
846
|
- `pts * time_base`
|
|
765
847
|
"""
|
|
766
848
|
return parse_fraction(pts * time_base)
|
|
849
|
+
|
|
850
|
+
def get_audio_frame_duration(
|
|
851
|
+
samples: int,
|
|
852
|
+
fps: Fraction
|
|
853
|
+
) -> Fraction:
|
|
854
|
+
"""
|
|
855
|
+
Get the audio frame duration by giving the
|
|
856
|
+
number of '.samples' and also the rate (that
|
|
857
|
+
we call 'fps').
|
|
858
|
+
|
|
859
|
+
This is useful when trying to guess the next
|
|
860
|
+
pts or t.
|
|
861
|
+
"""
|
|
862
|
+
return Fraction(samples / fps)
|
|
767
863
|
|
|
768
864
|
def get_ticks_per_frame(
|
|
769
865
|
fps: Union[float, int, Fraction],
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
yta_video_frame_time/__init__.py,sha256=-YOa7lOKdiA3FwDEHHU1tHobnmhjFpTaVLfJQLZqoMI,22252
|
|
2
|
+
yta_video_frame_time/t_fraction.py,sha256=RQwZ2-ko0m4HIbf35bV107I9k2n-C0qWv-pJGmvNUOI,24799
|
|
3
|
+
yta_video_frame_time-0.0.8.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
4
|
+
yta_video_frame_time-0.0.8.dist-info/METADATA,sha256=VpvV6zRnEK5B0y37UYdH7U94iLtATHwsEAhYARkqVnw,515
|
|
5
|
+
yta_video_frame_time-0.0.8.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
6
|
+
yta_video_frame_time-0.0.8.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=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,,
|
|
File without changes
|
|
File without changes
|