Selur's Little Message Board
[HELP] filldrops - Replace dupe frames with exact dupe frames - Printable Version

+- Selur's Little Message Board (https://forum.selur.net)
+-- Forum: Hybrid - Support (https://forum.selur.net/forum-1.html)
+--- Forum: Problems & Questions (https://forum.selur.net/forum-3.html)
+--- Thread: [HELP] filldrops - Replace dupe frames with exact dupe frames (/thread-3482.html)



filldrops - Replace dupe frames with exact dupe frames - fozter - 02.12.2023

Im very fond of the filldrops vs filter, but rife, svp and mv-tools doens't always give to good of a result on frames with certain objects in the frame i.e text, banners etc.
I was thinking of using "chronos fast" or "apollo fast" interpolation in topaz video enhance ai instead, as it gives better results on that kind of content. 
The thing is that the duplicate frame replacer function in VEAI doesn't seems to work very well, only when you got a source with exact/low compression artifacts duplicate frames it works in a good manner.

I was wondering if it's possible to use filldrops to instead of interpolating frames use it to create exact copies of the previous frame?
I would then use that processed video with VEAI's duplicate frame replacer and interpolation to get a good result.

Cheers


RE: filldrops - Replace dupe frames with exact dupe frames - Selur - 02.12.2023

One would need to write a separate function for replacing frames which differ less than X from their predecessor with a copy of it, but in general it's doable.
Maybe I find some time tomorrow to think about it and write a script for this and write some instructions down how one can manually add this to Hybrid, since I do not plan to add this permanently in Hybrid.
Does VEAI's 'duplicate frame replacer' not have some threshold so that frames with less than X difference will be replaced? (seems like an obvious option)

Cu Selur


RE: filldrops - Replace dupe frames with exact dupe frames - fozter - 02.12.2023

Great, thanks!

Yes, VEAI got a slider to adjust the sensitivity of the detection, but it doesn't work very well.
From my experience either it doesn't detect dupes at some lower values or for some reason creates more dupes when increasing that value.

I've read in a lot of their changelogs in recent versions that they've got problmes with the "de-duplication" functions.
Last version(4.0.5) was supposed to get this fixed:

Improvements to frame de-duplication in frame interpolation.

But i haven't got it to work near as good as with filldrops


RE: filldrops - Replace dupe frames with exact dupe frames - Selur - 02.12.2023

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.


RE: filldrops - Replace dupe frames with exact dupe frames - Selur - 02.12.2023

No, there seems to be a mistake in the Custom section,.. -> need to think about it a bit more


RE: filldrops - Replace dupe frames with exact dupe frames - Selur - 02.12.2023

Problem is '%SCRIPTPATH%', there is a bug in Hybrid which does not properly replace the variable.
=> you need to add the full path to Hybrid/64bit/vsscripts there. (and you need to use / not \)


RE: filldrops - Replace dupe frames with exact dupe frames - fozter - 03.12.2023

Excellent! It seems to work like i thought right away Smile
Thank you very much!


RE: filldrops - Replace dupe frames with exact dupe frames - Selur - 03.12.2023

Happy that helped. Smile

Cu Selur


RE: filldrops - Replace dupe frames with exact dupe frames - Hana - 04.12.2023

How can I leverage filldrops in Hybrid to replace duplicate frames with exact copies of the previous frame?
I'm exploring alternatives to interpolation methods like chronos fast or apollo fast in topaz video enhance ai, as they don't always yield satisfactory results, especially with frames containing text or banners.
The duplicate frame replacer function in VEAI doesn't seem effective unless the source has exact or low compression artifacts.
The provided solution involves creating an AddDuplicates.py file and using Vapoursynth in Hybrid. Can someone explain the process and its limitations, especially regarding multiple consecutive inserts?


RE: filldrops - Replace dupe frames with exact dupe frames - Selur - 04.12.2023

Sorry, but at least I have no time and motivation to train a LLM.

Cu Selur