Selur's Little Message Board

Full Version: ReplaceSingle (to replace multi)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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?
Quote:As soon as I add the video Hybrid exists
no clue, why Hybrid would close, don't see anything in the debug output.

Quote:Will Replaceframe with Duplicate ever become part of Hybrid as you have done with ReplaceMultiple?
Maybe, not sure.

Cu Selur
btw. for amusement:
Code:
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,..
Code:
clip = duplicateFrames(clip,[7361, 7447])
would replace 7362 with a duplicate of 7361 and 7448 with a duplicate of 7747.

Cu Selur
(19.05.2025, 14:54)Selur Wrote: [ -> ]Do:
Code:
# 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:
Code:
# 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
Pages: 1 2