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 3
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
Added an DuplicateFrames option to the latest dev.

Cu Selur
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.
Argh, must be a typo somewhere, I'll look at it.
Should be fixed now (udated dev). (small index mistake)

Cu Selur
Hi Selur, DuplicateFrames have been working flawlessly, thank you for including that.
I encountered a clip where frame 100 is good, 101 bad (image halfway up), (new scene)  102 bad (image halfway up) 103, 104 etc good.
Using DuplicateFrames, I can duplicate 101 to be identical to frame 100.
Is there a way to do the same in reverse?  Meaning Duplicate 102 to look like frame 103?
Not with addingMultipleDups.
You could use https://www.vapoursynth.com/doc/function...rames.html in a custom section.
Code:
clip = core.std.FreezeFrames(clip, first=102, last=102, replacement=103)
Should replace frame 102 with 103.
Pages: 1 2 3