Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th December 2018, 03:33   #61  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Below, Bottom left is a copy of previous frame, due to being too different (seen as scene change, Blend=False) and was using MRecalculate via Super clip.
Bottom right, MRecalculate via SuperFilt is not a copy of prev frame (not seen as scene change) and so presume that Superfilt is indeed the better option for MRecalculate.
EDIT: Or maybe rather that so much identical grey, and harder to figure out what goes where (rather than scene change), but same conclusion, SuperFilt better.



Script
Code:
VideoFileName   ="D:\STARWARS\VIDEO_TS\StarWars.d2v"
Mpeg2Source(VideoFileName)
Crop(0,72,0,-72)    # strip borders
ORG=Last
#return last
AMP=true
#FRAME=6995      # -1 = NO TRIM, else return trimmed single FRAME
FRAME=-1
FPS=250.0        # Lower to play slower (Also set FRAME = -1)
AMP_MARGIN=8     # for AMP Levels
TXT=RT_GetFullPathName(".\SWFrame.TXT")
RT_FileDelete(TXT)
LIMIT=1.0
#######################
SelectEven                              # Half framerate
J1   = jm_fps(fps=ORG.FrameRate)        # Doubled to same as original, recalc on super
J2   = jm_fps2(fps=ORG.FrameRate)       # Doubled to same as original, recalc on superfilt
ORG=RTSub(ORG,"Source")
d=Subtract(j1,j2) # Centered on TV Levels Y = 126.0
d=(AMP) ? d.levels(126-AMP_MARGIN,1.0,126+AMP_MARGIN,126-126,126+126,coring=false).GreyScale : d.GreyScale
BigDif= -1
BigDifFrm=-1
SSS="""
    dif=RT_AverageLuma
    Curdif=Abs(dif - 126.0) # TV Levels mid point(126.0)
    if(Curdif>BigDif) {
        BigDifFrm=current_frame
        BigDif=Curdif
        if(BigDif > LIMIT) {
            RT_WriteFile(TXT,"%d] %.3f",current_frame,BigDif,Append=True)
        }
    }
    return RT_Subtitle("BigDifFrm=%d BigDif=%.3f Curdif=%.3f",BigDifFrm,BigDif,Curdif)
"""
d=(FRAME<0) ? d.ScriptClip(SSS) : d

# Return d.Assumefps(FPS) # show only difference clip

d=RTSub(d,AMP?"diff AMP=True":"diff AMP=False")
J1E=J1.SelectEven.RTSub("Recalc Super")
J1O=J1.SelectOdd.RTSub("Recalc Super Interpolated")
J1=Interleave(J1E,J1O)
J2E=J2.SelectEven.RTSub("Recalc SuperFilt")
J2O=J2.SelectOdd.RTSub("Recalc SuperFilt Interpolated")
J2=Interleave(J2E,J2O)
V=ORG.BlankClip(Width=4,Color=$FF00FF)
TOP   = StackHorizontal(ORG,V,D)
BOT   = StackHorizontal(J1,v,J2)
H=TOP.BlankClip(Height=4,Color=$FF00FF)
StackVertical(TOP,H,BOT)
(FRAME==-1) ? Last : Trim(FRAME,-1)
Return Assumefps(FPS)
#######################

Function jm_fps(clip source, float "fps", int "BlkSize", int "Dct") {
    fps = default(fps, 25.000)
    fps_num = int(fps * 1000)
    fps_den = 1000
    BlkSize = default(BlkSize, 16)
    Dct = default(Dct, 0)

    prefiltered = RemoveGrain(source, 22)
    super = MSuper(source, hpad = 16, vpad = 16, levels = 1, sharp = 1, rfilter = 4) # one level is enough for MRecalculate
    superfilt = MSuper(prefiltered, hpad = 16, vpad = 16, sharp = 1, rfilter = 4) # all levels for MAnalyse
    backward = MAnalyse(superfilt, isb = true, blksize = BlkSize, overlap = 4, search = 3, dct = Dct)
    forward = MAnalyse(superfilt, isb = false, blksize = BlkSize, overlap = 4, search = 3, dct = Dct)
    forward_re = MRecalculate(super, forward, blksize = 8, overlap = 2, thSAD = 100)
    backward_re = MRecalculate(super, backward, blksize = 8, overlap = 2, thSAD = 100)
    return MFlowFps(source, super, backward_re, forward_re, num = fps_num, den = fps_den, blend = false, ml = 200, mask = 2)
}

Function jm_fps2(clip source, float "fps", int "BlkSize", int "Dct") {
    fps = default(fps, 25.000)
    fps_num = int(fps * 1000)
    fps_den = 1000
    BlkSize = default(BlkSize, 16)
    Dct = default(Dct, 0)

    prefiltered = RemoveGrain(source, 22)
    super = MSuper(source, hpad = 16, vpad = 16, levels = 1, sharp = 1, rfilter = 4) # one level is enough for MRecalculate
    superfilt = MSuper(prefiltered, hpad = 16, vpad = 16, sharp = 1, rfilter = 4) # all levels for MAnalyse
    backward = MAnalyse(superfilt, isb = true, blksize = BlkSize, overlap = 4, search = 3, dct = Dct)
    forward = MAnalyse(superfilt, isb = false, blksize = BlkSize, overlap = 4, search = 3, dct = Dct)
    forward_re = MRecalculate(superfilt, forward, blksize = 8, overlap = 2, thSAD = 100)
    backward_re = MRecalculate(superfilt, backward, blksize = 8, overlap = 2, thSAD = 100)
    return MFlowFps(source, super, backward_re, forward_re, num = fps_num, den = fps_den, blend = false, ml = 200, mask = 2)
}

# Stack Overhead RT_Subtitle Text, with optional FrameNumber shown.
Function RtSub(clip c,string Tit, Bool "ShowFrameNo") {
    c.BlankClip(height=20)
    (Default(ShowFrameNo,False)) ? ScriptClip("""RT_Subtitle("%d] %s",current_frame,""""+Tit+"""")""") : RT_Subtitle("%s",Tit)
    Return StackVertical(c).AudioDubEx(c)
}
EDIT: Some Mods
EDIT: Can probably just play clip until you see a massive difference frame with AMP=true. (as I did). [Maybe slow down via Assumefps() at end of script]
EDIT: So it seems that many scripts need be amended.
EDIT: Added FPS.
EDIT: Setting jp_fps() MFlowFPS(ThSCD2=255) to switch off scene change detection stuff results in frame that is pretty much identical
to jp_fps2(), I cant really see much difference, but the metrics sure do. Anyways, SuperFilt probably still better.

EDIT: Although, in above case, would copy prev frame or blend be better option with fewer artefacts, any views ?
EDIT: Think I'm sticking with original conclusion, too much of a jerk if copying prev frame, superfilt version is more fluid and will just look better playing normal speed.

EDIT: More mods, writes file of bad frames.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 16th December 2018 at 22:48.
StainlessS is offline   Reply With Quote
Old 16th December 2018, 22:33   #62  |  Link
zorr
Registered User
 
Join Date: Mar 2018
Posts: 447
Quote:
Originally Posted by StainlessS View Post
...but same conclusion, SuperFilt better.
It would make sense that the filtered super works better for both, if it works better for the first MAnalyze. But I think I will do a more comprehensive test of this... some day.

There's also an option to do filtering for both MAnalyze and MRecalculate but use different kind of filtering (or different parameters) for MRecalculate.

So far in my tests I have concluded that doing multiple RemoveGrains can help the quality. In the latest test doing RemoveGrain(16) followed by RemoveGrain(23) was the best combination, but that was just for one source video (VHS quality) and might be different with other kind of videos. MRecalculate was not used in that test so it tells nothing about what kind of filtering to use with it.
zorr is offline   Reply With Quote
Old 16th December 2018, 22:38   #63  |  Link
zorr
Registered User
 
Join Date: Mar 2018
Posts: 447
abolibibelot, will you accept my offer to search the optimal MVTools parameters for some of your bad frames? In that case could you please share a short video segment (10-20 frames), preferably in original size and using lossless compression which includes at least one bad frame you'd like to replace. Thanks!
zorr is offline   Reply With Quote
Reply

Tags
avisynth, bad frame, interpolate, morph, stabilizer

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:44.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.