Thank you for providing a solution.
I was ready to test this, but Hybrid doesn't accept the video anymore.
I am on Hybrid_dev_2025.05.18-84550
As soon as I add the video Hybrid exists
Will Replaceframe with Duplicate ever become part of Hybrid as you have done with ReplaceMultiple?
def duplicateFrames(clip: vs.VideoNode, positions: list[int]) -> vs.VideoNode:
# Sort and deduplicate positions in descending order to prevent index shifts
positions = sorted(set(positions), reverse=True)
for pos in positions:
if pos < 0 or pos >= clip.num_frames - 1:
raise ValueError(f"Position {pos} is invalid (must be between 0 and {clip.num_frames - 2}).")
part1 = core.std.Trim(clip, 0, pos + 1) # Frames 0 to pos (inclusive)
dup = core.std.Trim(clip, pos + 1, pos + 1) # Frame at pos + 1 to duplicate
part3 = core.std.Trim(clip, pos + 2, None) # Frames from pos + 2 to end
clip = core.std.Splice([part1, dup, part3], mismatch=True)
return clip
this would allow multiple frames,..
clip = duplicateFrames(clip,[7361, 7447])
would replace 7362 with a duplicate of 7361 and 7448 with a duplicate of 7747.
Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
# replaces frame x +1 with a duplicate of x
def duplicate(clip: vs.VideoNode, x: int) -> vs.VideoNode:
part1 = core.std.Trim(clip, 0, x) # Frames 0 to x (inclusive)
replacement = core.std.Trim(clip, x, x) # Only frame x (duplicate)
part3 = core.std.Trim(clip, x + 2, None) # Frames x+2 to end
return core.std.Splice([part1, replacement, part3], mismatch=True)
return duplicate(clip, 7361)
is faster and works.
If you wanted to duplicate 7361 and 7447 you would use:
# replaces frame x +1 with a duplicate of x
def duplicate(clip: vs.VideoNode, x: int) -> vs.VideoNode:
part1 = core.std.Trim(clip, 0, x) # Frames 0 to x (inclusive)
replacement = core.std.Trim(clip, x, x) # Only frame x (duplicate)
part3 = core.std.Trim(clip, x + 2, None) # Frames x+2 to end
return core.std.Splice([part1, replacement, part3], mismatch=True)
clip = duplicate(clip, 7361)
clip = duplicate(clip, 7447)
return clip
Cu Selur
It works great!!! Thank you for helping. A useful tool, on a wish list to be part of Hybrid someday
Thank you for adding this feature.
There is still a problem. If I put frame 7361 in the field. I get 7361 and a duplicate 7362 (which is perfect), however old bad frame 7362 became new 7363 and old good frame 7363 becomes new frame 7364. The video has one more frame than the original.