Create a AddDuplicates.py file in your Hybrid/64bit/vsscripts folder with the following content:
In Hybrid go to "Filtering->Vapoursynth->Custom" set 'Insert before' to 'End' and enter:
(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.
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)
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.
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.