Skip to content

Commit

Permalink
replace_ranges: Duplicate final frame for plugin use
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Nov 16, 2024
1 parent 48b66c8 commit a1fc1ab
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions vstools/utils/ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,22 @@ def _func(n: int) -> vs.VideoNode: # type: ignore
b_ranges = normalize_ranges(clip_b, ranges)
do_splice_trim = len(b_ranges) <= 15

if clip_a.num_frames != clip_b.num_frames:
warnings.warn(
f"replace_ranges: 'The number of frames of the clips don't match! "
f"({clip_a.num_frames=}, {clip_b.num_frames=})\n"
"The function will still work, but you may run into undefined behavior, or a broken output clip!'"
)

if not do_splice_trim:
if clip_a.num_frames != clip_b.num_frames:
diff = abs(clip_a.num_frames - clip_b.num_frames)

if clip_a.num_frames < clip_b.num_frames:
clip_a = clip_a + clip_a[-1] * diff
else:
clip_b = clip_b + clip_b[-1] * diff

try:
if hasattr(vs.core, 'julek'):
return vs.core.julek.RFS(
Expand All @@ -204,13 +219,6 @@ def _func(n: int) -> vs.VideoNode: # type: ignore
case _:
raise CustomValueError(msg, replace_ranges)

if clip_a.num_frames != clip_b.num_frames:
warnings.warn(
f"replace_ranges: 'The number of frames of the clips don't match! "
f"({clip_a.num_frames=}, {clip_b.num_frames=})\n"
"The function will still work, but you may run into undefined behavior, or a broken output clip!'"
)

if do_splice_trim:
shift = 1 - exclusive

Expand Down

0 comments on commit a1fc1ab

Please sign in to comment.