Skip to content

Commit b660736

Browse files
committed
preview: print correct num of cuts
1 parent 4dd823f commit b660736

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 28.0.2
2+
3+
## Fixes
4+
- preview: print correct number of cuts
5+
16
# 28.0.1
27

38
## Fixes

auto_editor/preview.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,24 @@ def time_frame(
2828
def all_cuts(tl: v3, in_len: int) -> list[int]:
2929
# Calculate cuts
3030
tb = tl.tb
31-
oe: list[tuple[int, int]] = []
31+
clip_spans: list[tuple[int, int]] = []
3232

3333
for clip in tl.a[0]:
3434
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)))
3636

3737
cut_lens = []
3838
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])
4242

43-
cut_lens.append(oe[i + 1][0] - oe[i][1])
43+
cut_lens.append(clip_spans[i + 1][0] - clip_spans[i][1])
4444
i += 1
4545

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+
4849
return cut_lens
4950

5051

@@ -53,19 +54,9 @@ def preview(tl: v3, log: Log) -> None:
5354
tb = tl.tb
5455

5556
# 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-
6657
in_len = 0
6758
bar = initBar("none")
68-
for src in all_sources:
59+
for src in tl.unique_sources():
6960
in_len += initLevels(src, tb, bar, False, log).media_length
7061

7162
out_len = len(tl)
@@ -90,7 +81,7 @@ def preview(tl: v3, log: Log) -> None:
9081

9182
cut_lens = all_cuts(tl, in_len)
9283
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")
9485
if len(cut_lens) > 0:
9586
time_frame(fp, "smallest", min(cut_lens), tb)
9687
time_frame(fp, "largest", max(cut_lens), tb)

0 commit comments

Comments
 (0)