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] filldrops - Replace dupe frames with exact dupe frames
#4
Create a AddDuplicates.py file in your Hybrid/64bit/vsscripts folder with the following content:
import vapoursynth as vs
core = vs.core

def addDup(clip, thresh=0.3, debug=False):
    core = vs.core
    if not isinstance(clip, vs.VideoNode):
        raise ValueError('This is not a clip')
        
    def selectFunc(n, f):
        if f.props['PlaneStatsDiff'] > thresh or n == 0:
            if debug:
                return core.text.Text(clip=clip, text="Org, diff: "+str(f.props['PlaneStatsDiff']), alignment=8)
            return clip
        else:
            added = addingDups(clip, n)
            if debug:
                return core.text.Text(clip=added, text="addingDups, diff: "+str(f.props['PlaneStatsDiff'])+" < "+str(thresh), alignment=8)
            return added
              
    diffclip = core.std.PlaneStats(clip, clip[0] + clip)
    fixed = core.std.FrameEval(clip, selectFunc, prop_src=diffclip)
    return fixed

def addingDups(clip, firstframe=None):
    if firstframe is None or firstframe == 0:
        return clip
    
    clip1 = core.std.AssumeFPS(clip, fpsnum=1, fpsden=1)
    r = core.std.Trim(clip1, first=firstframe-1, length=1) # predecessor of current frame
    a = core.std.Trim(clip1, first=0, last=firstframe-1) # frames before current frame
    b = core.std.Trim(clip1, first=firstframe+1) #frames after current frame
    join = a + r + b
    return core.std.AssumeFPS(join, src=clip)

In Hybrid go to "Filtering->Vapoursynth->Custom" set 'Insert before' to 'End' and enter:
# getting Vapoursynth core
import sys
import os
# Import scripts folder
sys.path.insert(0, os.path.abspath('%SCRIPTPATH%'))

import AddDuplicates
clip = AddDuplicates.addDup(clip,thresh=0.3, debug=True)
(adjust 'thresh' and 'debug' to your liking)
If I have not overlooked anything, this should insert single duplicate frames if the previous and the current frame differ less than thresh.

Cu Selur

Ps.: this will only work for single inserts, not multiple in a row.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Messages In This Thread
RE: filldrops - Replace dupe frames with exact dupe frames - by Selur - 02.12.2023, 22:03

Forum Jump:


Users browsing this thread: 1 Guest(s)