This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] ReplaceSingle (to replace multi)
#11
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?


Attached Files
.zip   HybridDebugOutput.zip (Size: 21,76 KB / Downloads: 31)
Reply
#12
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
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#13
btw. for amusement:
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.
Reply
#14
(19.05.2025, 14:54)Selur Wrote: Do:
# 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
Reply
#15
Added an DuplicateFrames option to the latest dev.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#16
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.
Reply
#17
Argh, must be a typo somewhere, I'll look at it.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#18
Should be fixed now (udated dev). (small index mistake)

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)