@@ -28,23 +28,24 @@ def time_frame(
28
28
def all_cuts (tl : v3 , in_len : int ) -> list [int ]:
29
29
# Calculate cuts
30
30
tb = tl .tb
31
- oe : list [tuple [int , int ]] = []
31
+ clip_spans : list [tuple [int , int ]] = []
32
32
33
33
for clip in tl .a [0 ]:
34
34
old_offset = clip .offset * clip .speed
35
- oe .append ((round (old_offset * clip . speed ), round (old_offset + clip .dur )))
35
+ clip_spans .append ((round (old_offset ), round (old_offset + clip .dur )))
36
36
37
37
cut_lens = []
38
38
i = 0
39
- while i < len (oe ) - 1 :
40
- if i == 0 and oe [i ][0 ] != 0 :
41
- cut_lens .append (oe [i ][1 ])
39
+ while i < len (clip_spans ) - 1 :
40
+ if i == 0 and clip_spans [i ][0 ] != 0 :
41
+ cut_lens .append (clip_spans [i ][0 ])
42
42
43
- cut_lens .append (oe [i + 1 ][0 ] - oe [i ][1 ])
43
+ cut_lens .append (clip_spans [i + 1 ][0 ] - clip_spans [i ][1 ])
44
44
i += 1
45
45
46
- if len (oe ) > 0 and oe [- 1 ][1 ] < round (in_len * tb ):
47
- cut_lens .append (in_len - oe [- 1 ][1 ])
46
+ if len (clip_spans ) > 0 and clip_spans [- 1 ][1 ] < round (in_len / tb ):
47
+ cut_lens .append (in_len - clip_spans [- 1 ][1 ])
48
+
48
49
return cut_lens
49
50
50
51
@@ -53,19 +54,9 @@ def preview(tl: v3, log: Log) -> None:
53
54
tb = tl .tb
54
55
55
56
# Calculate input videos length
56
- all_sources = set ()
57
- for vlayer in tl .v :
58
- for vclip in vlayer :
59
- if hasattr (vclip , "src" ):
60
- all_sources .add (vclip .src )
61
- for alayer in tl .a :
62
- for aclip in alayer :
63
- if hasattr (aclip , "src" ):
64
- all_sources .add (aclip .src )
65
-
66
57
in_len = 0
67
58
bar = initBar ("none" )
68
- for src in all_sources :
59
+ for src in tl . unique_sources () :
69
60
in_len += initLevels (src , tb , bar , False , log ).media_length
70
61
71
62
out_len = len (tl )
@@ -90,7 +81,7 @@ def preview(tl: v3, log: Log) -> None:
90
81
91
82
cut_lens = all_cuts (tl , in_len )
92
83
log .debug (cut_lens )
93
- fp .write (f"cuts:\n - amount: { len (clip_lens )} \n " )
84
+ fp .write (f"cuts:\n - amount: { len (cut_lens )} \n " )
94
85
if len (cut_lens ) > 0 :
95
86
time_frame (fp , "smallest" , min (cut_lens ), tb )
96
87
time_frame (fp , "largest" , max (cut_lens ), tb )
0 commit comments